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
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/common/utils/SimpleLunarCalendar.ets
arkts
简化版农历计算系统 专注解决用户报告的核心问题 农历日期接口
export interface SimpleLunarDate { year: number; month: number; day: number; isLeapMonth: boolean; monthName: string; dayName: string; }
AST#export_declaration#Left export AST#interface_declaration#Left interface SimpleLunarDate AST#object_type#Left { AST#type_member#Left year : 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 month : 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 day : 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 isLeapMonth : 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 monthName : 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 dayName : 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 SimpleLunarDate { year: number; month: number; day: number; isLeapMonth: boolean; monthName: string; dayName: string; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/utils/SimpleLunarCalendar.ets#L9-L16
b7398a8a4a28c102c8936529dc1aa234ec540595
github
zqaini002/YaoYaoLingXian.git
5095b12cbeea524a87c42d0824b1702978843d39
YaoYaoLingXian/entry/src/main/ets/pages/auth/RegisterPage.ets
arkts
checkUsernameAvailability
验证用户名是否可用
async checkUsernameAvailability(username: string) { if (!username || username.length < 3) { return; } try { this.isCheckingUsername = true; const response = await checkUsername(username); if (response.code === 200) { if (response.data === true) { this.usernameError = ''; } else { this.usernameError = '用户名已被使用'; } } else { console.error('检查用户名失败:', response.message); } } catch (error) { console.error('检查用户名出错:', error); } finally { this.isCheckingUsername = false; } }
AST#method_declaration#Left async checkUsernameAvailability 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_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 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 username AST#expression#Right AST#binary_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#block_statement#Left { AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isCheckingUsername 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#variable_declaration#Left const AST#variable_declarator#Left response = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left checkUsername AST#expression#Right AST#await_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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . code 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . data AST#member_expression#Right AST#expression#Right === AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#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 . usernameError 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 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 . usernameError 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#if_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '检查用户名失败:' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . message AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '检查用户名出错:' AST#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#finally_clause#Left finally AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isCheckingUsername AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#finally_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async checkUsernameAvailability(username: string) { if (!username || username.length < 3) { return; } try { this.isCheckingUsername = true; const response = await checkUsername(username); if (response.code === 200) { if (response.data === true) { this.usernameError = ''; } else { this.usernameError = '用户名已被使用'; } } else { console.error('检查用户名失败:', response.message); } } catch (error) { console.error('检查用户名出错:', error); } finally { this.isCheckingUsername = false; } }
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/pages/auth/RegisterPage.ets#L47-L70
08b89f209826158fb808510f96549b99f9a60cd3
github
wuyukobe24/HMApp_ArkTS.git
6d09d9b07a4fdc4713e5a13b61b85bc1e7893956
entry/src/main/ets/common/networking/QQNetworkRequest.ets
arkts
post
export function postRequest(url:string, param:Object, success:(str:string)=>void, fail:(error:Error)=>void) { let httpRequest = http.createHttp() let reponseResult = httpRequest.request(url, { method: http.RequestMethod.POST, readTimeout:60000, connectTimeout:60000, header: header, extraData: param, expectDataType:http.HttpDataType.STRING }, (error, data) => { if (!error) { success(data.result.toString()) // data.result为HTTP响应内容,可根据业务需要进行解析 console.info('Networking ===================================='); console.info('Networking Url:' + url); console.info('Networking Result 类型:' + typeof data.result); // console.info('Result 类型:' + typeof JSON.stringify(data.result)); console.info('Networking Result:' + data.result); console.info('Networking code:' + data.responseCode); // data.header为HTTP响应头,可根据业务需要进行解析 console.info('Networking header:' + JSON.stringify(data.header)); console.info('Networking cookies:' + data.cookies); // 8+ console.info('Networking ===================================='); } else { fail(error) console.info('Networking error:' + JSON.stringify(error)); // 当该请求使用完毕时,调用destroy方法主动销毁。 httpRequest.destroy(); } }) }
AST#export_declaration#Left export AST#function_declaration#Left function postRequest AST#parameter_list#Left ( AST#parameter#Left url : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left param : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left success : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left fail : AST#type_annotation#Left AST#function_type#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#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#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left httpRequest = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . createHttp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left reponseResult = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left httpRequest AST#expression#Right . request AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left url AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left method AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . RequestMethod AST#member_expression#Right AST#expression#Right . POST AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left readTimeout AST#property_name#Right : AST#expression#Left 60000 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left connectTimeout AST#property_name#Right : AST#expression#Left 60000 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left header AST#property_name#Right : AST#expression#Left header AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left extraData AST#property_name#Right : AST#expression#Left param AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left expectDataType AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . HttpDataType AST#member_expression#Right AST#expression#Right . STRING AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error AST#parameter#Right , AST#parameter#Left data AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left error AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left success 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#expression_statement#Right AST#statement#Right // data.result为HTTP响应内容,可根据业务需要进行解析 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Networking ====================================' 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#binary_expression#Left AST#expression#Left 'Networking Url:' AST#expression#Right + AST#expression#Left url AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 'Networking Result 类型:' AST#expression#Right + AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left data AST#expression#Right AST#unary_expression#Right 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 // console.info('Result 类型:' + typeof JSON.stringify(data.result)); 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 'Networking 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 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 'Networking code:' AST#expression#Right + AST#expression#Left data AST#expression#Right AST#binary_expression#Right AST#expression#Right . responseCode 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 // data.header为HTTP响应头,可根据业务需要进行解析 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'Networking header:' 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 AST#member_expression#Left AST#expression#Left data AST#expression#Right . header AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right 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 'Networking cookies:' AST#expression#Right + AST#expression#Left data AST#expression#Right AST#binary_expression#Right AST#expression#Right . cookies 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 // 8+ 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 'Networking ====================================' AST#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 fail 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#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'Networking 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 // 当该请求使用完毕时,调用destroy方法主动销毁。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left httpRequest AST#expression#Right . destroy AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#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#function_declaration#Right AST#export_declaration#Right
export function postRequest(url:string, param:Object, success:(str:string)=>void, fail:(error:Error)=>void) { let httpRequest = http.createHttp() let reponseResult = httpRequest.request(url, { method: http.RequestMethod.POST, readTimeout:60000, connectTimeout:60000, header: header, extraData: param, expectDataType:http.HttpDataType.STRING }, (error, data) => { if (!error) { success(data.result.toString()) console.info('Networking ===================================='); console.info('Networking Url:' + url); console.info('Networking Result 类型:' + typeof data.result); console.info('Networking Result:' + data.result); console.info('Networking code:' + data.responseCode); console.info('Networking header:' + JSON.stringify(data.header)); console.info('Networking cookies:' + data.cookies); console.info('Networking ===================================='); } else { fail(error) console.info('Networking error:' + JSON.stringify(error)); httpRequest.destroy(); } }) }
https://github.com/wuyukobe24/HMApp_ArkTS.git/blob/6d09d9b07a4fdc4713e5a13b61b85bc1e7893956/entry/src/main/ets/common/networking/QQNetworkRequest.ets#L20-L50
88e56c28912bd6ba1c97e36dc387f08c677c6930
github
harmonyos/samples
f5d967efaa7666550ee3252d118c3c73a77686f5
ETSUI/AboutSample/entry/src/main/ets/view/TechSupportComponent.ets
arkts
TechSupportComponent
Privacy agreement and copyright statement page.
@Component export struct TechSupportComponent { build() { Column() { Row() { Text($r('app.string.user_protocol')) .fontSize($r('app.float.bottom_font_size')) .fontColor($r('app.color.text_link')) .onClick(() => this.openAgreementPage()) Text($r('app.string.and')) .fontSize($r('app.float.bottom_font_size')) .fontColor($r('app.color.text_opacity')) Text($r('app.string.privacy_statement')) .fontSize($r('app.float.bottom_font_size')) .fontColor($r('app.color.text_link')) .onClick(() => this.openPrivacyPage()) } Text($r('app.string.copyright')) .fontSize($r('app.float.bottom_font_size')) .fontColor($r('app.color.text_opacity')) Text($r('app.string.tech_support')) .fontSize($r('app.float.bottom_font_size')) .fontColor($r('app.color.text_opacity')) } .alignItems(HorizontalAlign.Center) .align(Alignment.Bottom) .margin({ bottom: $r('app.float.bottom_padding_bottom') }) } openAgreementPage() { router.push({ url: CommonConstants.AGREEMENT_PAGE }); } openPrivacyPage() { router.push({ url: CommonConstants.PRIVACY_PAGE }); } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct TechSupportComponent AST#component_body#Left { AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.user_protocol' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.bottom_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_link' 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#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . openAgreementPage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.and' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.bottom_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_opacity' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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.privacy_statement' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.bottom_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_link' 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#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . openPrivacyPage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#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 Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.copyright' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.bottom_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_opacity' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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.tech_support' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.bottom_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_opacity' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . align ( AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . Bottom AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.bottom_padding_bottom' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right AST#method_declaration#Left openAgreementPage 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 router AST#expression#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 url AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . AGREEMENT_PAGE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left openPrivacyPage 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 router AST#expression#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 url AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . PRIVACY_PAGE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export struct TechSupportComponent { build() { Column() { Row() { Text($r('app.string.user_protocol')) .fontSize($r('app.float.bottom_font_size')) .fontColor($r('app.color.text_link')) .onClick(() => this.openAgreementPage()) Text($r('app.string.and')) .fontSize($r('app.float.bottom_font_size')) .fontColor($r('app.color.text_opacity')) Text($r('app.string.privacy_statement')) .fontSize($r('app.float.bottom_font_size')) .fontColor($r('app.color.text_link')) .onClick(() => this.openPrivacyPage()) } Text($r('app.string.copyright')) .fontSize($r('app.float.bottom_font_size')) .fontColor($r('app.color.text_opacity')) Text($r('app.string.tech_support')) .fontSize($r('app.float.bottom_font_size')) .fontColor($r('app.color.text_opacity')) } .alignItems(HorizontalAlign.Center) .align(Alignment.Bottom) .margin({ bottom: $r('app.float.bottom_padding_bottom') }) } openAgreementPage() { router.push({ url: CommonConstants.AGREEMENT_PAGE }); } openPrivacyPage() { router.push({ url: CommonConstants.PRIVACY_PAGE }); } }
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/ETSUI/AboutSample/entry/src/main/ets/view/TechSupportComponent.ets#L7-L50
0e030b2a72c1c8d7f857adcd54a7fae6a503bc23
gitee
Application-Security-Automation/Arktan.git
3ad9cb05235e38b00cd5828476aa59a345afa1c0
dataset/accuracy/context_sensitive/argument_value_passing/argument_passing_003_T.ets
arkts
Introduction 参数传递-参数位置
export function argument_passing_003_T(taint_src : string) { f(taint_src,"_"); }
AST#export_declaration#Left export AST#function_declaration#Left function argument_passing_003_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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left f AST#expression#Right AST#argument_list#Left ( AST#expression#Left taint_src 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#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function argument_passing_003_T(taint_src : string) { f(taint_src,"_"); }
https://github.com/Application-Security-Automation/Arktan.git/blob/3ad9cb05235e38b00cd5828476aa59a345afa1c0/dataset/accuracy/context_sensitive/argument_value_passing/argument_passing_003_T.ets#L6-L8
b90ea184ea55db90123ef857000bb82bd40a914a
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/expandtitle/Index.ets
arkts
TitleExpansionView
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 { TitleExpansionView } from './src/main/ets/page/TitleExpansionView';
AST#export_declaration#Left export { TitleExpansionView } from './src/main/ets/page/TitleExpansionView' ; AST#export_declaration#Right
export { TitleExpansionView } from './src/main/ets/page/TitleExpansionView';
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/expandtitle/Index.ets#L15-L15
f500425269d89e4a3c9736ed25687fa81f3d33fa
gitee
vhall/VHLive_SDK_Harmony
29c820e5301e17ae01bc6bdcc393a4437b518e7c
watchKit/src/main/ets/components/goods/VHGoodsComponent.ets
arkts
openLink
打开链接
private openLink(url: string) { const params = new GoodsWebViewParams("支付", url); this.contentNode = new ComponentContent(this.getUIContext(), wrapBuilder(GoodsWebViewPageBuilder), params); PromptActionClass.setContext(this.getUIContext()); PromptActionClass.setContentNode(this.contentNode); PromptActionClass.setOptions({ alignment: DialogAlignment.Center, offset: { dx: 0, dy: 50 }, isModal: true, maskRect: { x: 0, y: 0, width: '100%', height: '0%' } }); PromptActionClass.openDialog(); }
AST#method_declaration#Left private openLink AST#parameter_list#Left ( AST#parameter#Left url : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left params = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left GoodsWebViewParams AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "支付" AST#expression#Right , AST#expression#Left url AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . contentNode AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ComponentContent AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getUIContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left wrapBuilder AST#expression#Right AST#argument_list#Left ( AST#expression#Left GoodsWebViewPageBuilder AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left params AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PromptActionClass AST#expression#Right . setContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getUIContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PromptActionClass AST#expression#Right . setContentNode AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . contentNode AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PromptActionClass AST#expression#Right . setOptions AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left alignment AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left DialogAlignment AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offset AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left dx AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left dy AST#property_name#Right : AST#expression#Left 50 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left isModal AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left maskRect AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left '100%' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left '0%' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PromptActionClass AST#expression#Right . openDialog AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private openLink(url: string) { const params = new GoodsWebViewParams("支付", url); this.contentNode = new ComponentContent(this.getUIContext(), wrapBuilder(GoodsWebViewPageBuilder), params); PromptActionClass.setContext(this.getUIContext()); PromptActionClass.setContentNode(this.contentNode); PromptActionClass.setOptions({ alignment: DialogAlignment.Center, offset: { dx: 0, dy: 50 }, isModal: true, maskRect: { x: 0, y: 0, width: '100%', height: '0%' } }); PromptActionClass.openDialog(); }
https://github.com/vhall/VHLive_SDK_Harmony/blob/29c820e5301e17ae01bc6bdcc393a4437b518e7c/watchKit/src/main/ets/components/goods/VHGoodsComponent.ets#L915-L932
6967d3ffc4fc5409370802f3c5ec4f84b33ac169
gitee
huaweicloud/huaweicloud-iot-device-sdk-arkts.git
72954bea19e7e7f93567487b036c0664457bdaf3
huaweicloud_iot_device_library/src/main/ets/service/AbstractService.ets
arkts
onWrite
写属性。收到平台下发的写属性操作时此接口被自动调用。 如果用户希望在写属性时增加额外处理,可以重写此接口 @param properties 平台期望属性的值 @return 操作结果
onWrite(properties: object): IotResult { let changeProps: string[] = []; let result = IotResult.SUCCESS; Object.keys(properties).every((propertyName: string) => { const field = this.writeableFields.get(propertyName); if (field === null || field === undefined) { LogUtil.error(`field not found or not writeable ${propertyName}` ); result = { result_code: -1, result_desc: `"field not found or not writeable ${propertyName}`, } return false; } let setMethodName = field; if (field.startsWith("_")) { setMethodName = field.substring(1, field.length); } Reflect.set(this, setMethodName, properties[propertyName]); changeProps.push(field); return true; }) // 上报属性变化 if (changeProps.length > 0) { this.firePropertiesChanged(changeProps); } return result; }
AST#method_declaration#Left onWrite AST#parameter_list#Left ( AST#parameter#Left properties : AST#type_annotation#Left AST#primary_type#Left object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left IotResult AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left changeProps : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left result = AST#expression#Left AST#member_expression#Left AST#expression#Left IotResult AST#expression#Right . SUCCESS 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Object AST#expression#Right . keys AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left properties AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . every 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 propertyName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left field = 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 . writeableFields AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left propertyName AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left field 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 field 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` field not found or not writeable AST#template_substitution#Left $ { AST#expression#Left propertyName 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 result = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left result_code AST#property_name#Right : AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left result_desc AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` "field not found or not writeable AST#template_substitution#Left $ { AST#expression#Left propertyName 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#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left setMethodName = AST#expression#Left field 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 field AST#expression#Right . startsWith AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "_" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left setMethodName = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left field AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1 AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left field 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#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 Reflect AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left this AST#expression#Right , AST#expression#Left setMethodName AST#expression#Right , AST#expression#Left AST#subscript_expression#Left AST#expression#Left properties AST#expression#Right [ AST#expression#Left propertyName AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left changeProps AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left field AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // 上报属性变化 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left changeProps AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . firePropertiesChanged AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left changeProps AST#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 result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
onWrite(properties: object): IotResult { let changeProps: string[] = []; let result = IotResult.SUCCESS; Object.keys(properties).every((propertyName: string) => { const field = this.writeableFields.get(propertyName); if (field === null || field === undefined) { LogUtil.error(`field not found or not writeable ${propertyName}` ); result = { result_code: -1, result_desc: `"field not found or not writeable ${propertyName}`, } return false; } let setMethodName = field; if (field.startsWith("_")) { setMethodName = field.substring(1, field.length); } Reflect.set(this, setMethodName, properties[propertyName]); changeProps.push(field); return true; }) if (changeProps.length > 0) { this.firePropertiesChanged(changeProps); } return result; }
https://github.com/huaweicloud/huaweicloud-iot-device-sdk-arkts.git/blob/72954bea19e7e7f93567487b036c0664457bdaf3/huaweicloud_iot_device_library/src/main/ets/service/AbstractService.ets#L164-L191
53e66dd552855318e32dacc3527f9414a318bf90
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Media/ImageEdit/entry/src/main/ets/viewModel/Rect.ets
arkts
isInRect
Determine whether it is within the rectangle. @param x @param y @returns
isInRect(x: number, y: number): boolean { return (x >= this.left && x <= this.right && y >= this.top && y <= this.bottom); }
AST#method_declaration#Left isInRect AST#parameter_list#Left ( AST#parameter#Left x : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left y : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 x AST#expression#Right >= AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . left AST#member_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left x AST#expression#Right <= AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . right AST#member_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left y AST#expression#Right >= AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . top AST#member_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left y AST#expression#Right <= AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . bottom AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
isInRect(x: number, y: number): boolean { return (x >= this.left && x <= this.right && y >= this.top && y <= this.bottom); }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Media/ImageEdit/entry/src/main/ets/viewModel/Rect.ets#L108-L110
bb0a7d8ef54400c1a703d38cf5e4d672e5507d2b
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/ai/FavoritesService.ets
arkts
removeSavedGift
删除保存的礼物
async removeSavedGift(giftId: string): Promise<boolean> { const index = this.savedGifts.findIndex(g => g.id === giftId); if (index === -1) { return false; } const removed = this.savedGifts.splice(index, 1)[0]; await this.saveData(); hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Removed saved gift: ${removed.id}`); return true; }
AST#method_declaration#Left async removeSavedGift AST#parameter_list#Left ( AST#parameter#Left giftId : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left index = 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 . savedGifts AST#member_expression#Right AST#expression#Right . findIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left g => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left g AST#expression#Right . id AST#member_expression#Right AST#expression#Right === AST#expression#Left giftId 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right === AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left removed = 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 . savedGifts AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#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 . saveData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Removed saved gift: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left removed AST#expression#Right . id AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async removeSavedGift(giftId: string): Promise<boolean> { const index = this.savedGifts.findIndex(g => g.id === giftId); if (index === -1) { return false; } const removed = this.savedGifts.splice(index, 1)[0]; await this.saveData(); hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Removed saved gift: ${removed.id}`); return true; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/ai/FavoritesService.ets#L206-L217
dae350a9fae5669a142ca4ccab9802f3d21c14bb
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationManagementUtil.ets
arkts
cancelNotificationType
取消属于该类型的通知
cancelNotificationType(typeId: number) { console.info(`cancelNotificationType, ${JSON.stringify(this.typeNotifications)}`) this.typeNotifications[typeId].forEach(item => { notification.cancel(item.id); }) }
AST#method_declaration#Left cancelNotificationType AST#parameter_list#Left ( AST#parameter#Left typeId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` cancelNotificationType, AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . typeNotifications AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#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 . typeNotifications AST#member_expression#Right AST#expression#Right [ AST#expression#Left typeId AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left item => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left notification AST#expression#Right . cancel AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#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
cancelNotificationType(typeId: number) { console.info(`cancelNotificationType, ${JSON.stringify(this.typeNotifications)}`) this.typeNotifications[typeId].forEach(item => { notification.cancel(item.id); }) }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationManagementUtil.ets#L53-L58
047105c8a61deb2d17e701537b79fd46569618fe
gitee
liuchao0739/arkTS_universal_starter.git
0ca845f5ae0e78db439dc09f712d100c0dd46ed3
entry/src/main/ets/modules/scanner/ScannerManager.ets
arkts
scan
扫描二维码/条码
async scan(): Promise<ScanResult | null> { try { Logger.info('ScannerManager', 'Starting scan'); // 实际实现需要使用 @ohos.multimedia.image 和相机API // Mock 结果 return { text: 'https://example.com', format: 'QR_CODE', type: 'qr' }; } catch (error) { Logger.error('ScannerManager', `Failed to scan: ${String(error)}`); return null; } }
AST#method_declaration#Left async scan 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#union_type#Left AST#primary_type#Left ScanResult AST#primary_type#Right | AST#primary_type#Left null 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 { 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 'ScannerManager' AST#expression#Right , AST#expression#Left 'Starting scan' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 实际实现需要使用 @ohos.multimedia.image 和相机API // Mock 结果 AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left text AST#property_name#Right : AST#expression#Left 'https://example.com' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left format AST#property_name#Right : AST#expression#Left 'QR_CODE' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left 'qr' 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#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 'ScannerManager' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to scan: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left String AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async scan(): Promise<ScanResult | null> { try { Logger.info('ScannerManager', 'Starting scan'); return { text: 'https://example.com', format: 'QR_CODE', type: 'qr' }; } catch (error) { Logger.error('ScannerManager', `Failed to scan: ${String(error)}`); return null; } }
https://github.com/liuchao0739/arkTS_universal_starter.git/blob/0ca845f5ae0e78db439dc09f712d100c0dd46ed3/entry/src/main/ets/modules/scanner/ScannerManager.ets#L30-L44
51a4aa6c2c2c68d233dbd0d5f10ed6077b871e52
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/data/src/main/ets/repository/OrderRepository.ets
arkts
updateOrder
更新订单信息 @param params 更新参数 @returns 更新结果
async updateOrder(params: Unknown): Promise<NetworkResponse<Unknown>> { return this.networkDataSource.updateOrder(params); }
AST#method_declaration#Left async updateOrder AST#parameter_list#Left ( AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left Unknown AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left NetworkResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Unknown AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . networkDataSource AST#member_expression#Right AST#expression#Right . updateOrder AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left params AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async updateOrder(params: Unknown): Promise<NetworkResponse<Unknown>> { return this.networkDataSource.updateOrder(params); }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/data/src/main/ets/repository/OrderRepository.ets#L47-L49
475212cdea5ec9a9a515d6aa2a6e002766951b3b
github
IceYuanyyy/OxHornCampus.git
bb5686f77fa36db89687502e35898cda218d601f
entry/src/main/ets/common/constants/CommonConstants.ets
arkts
Copyright (c) 2023 Huawei Device Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
export class CommonConstants { /** * Component size. */ static readonly SWIPER_DEFAULT_WIDTH: string = '66%'; static readonly FULL_PERCENT: string = '100%'; static readonly HALF_PERCENT: string = '50%'; static readonly IMAGE_CONTAINER_HEIGHT: string = '42%'; static readonly FULL_SIZE: string = '100%'; static readonly ICON_SIZE: string = '40%'; static readonly BAR_WEIGHT: string = '25%'; static readonly BAR_HEIGHT: string = '10%'; static readonly CONTENT_WIDTH_PERCENT: string = '87%'; static readonly SEARCHBAR_WIDTH: string = '91.1%' static readonly IMAGE_HEIGHT_MIN: string = '78%'; /** * Component location. */ static readonly PERCENTAGE_78: string = '78%'; static readonly PERCENTAGE_15: string = '15%'; static readonly PERCENTAGE_25: string = '25%'; /** * Component constants. */ static readonly OPACITY: number = 0.6; static readonly BORDER_WIDTH: number = 0.5; static readonly COUNTDOWN: number = 5; /** * Time constants. */ static readonly DURATION: number = 1000; static readonly MORNING_TIME: number = 6; static readonly EVENING_TIME: number = 18; static readonly NIGHT_TIME: number = 19; static readonly SPLASH_DURATION: number = 3000; /** * Color constants. */ static readonly TRANSPARENT_COLOR: string = '#00ffffff'; static readonly NAVIGATION_BAR_COLOR: string = '#00ff00'; static readonly STATUS_BAR_CONTENT_COLOR: string = '#ffffff'; static readonly NAVIGATION_BAR_CONTENT_COLOR: string = '#ffffff'; static readonly THEME_COLOR: string = '#c82424'; /** * Title text. */ static readonly SPLASH_DES: Resource = $r('app.string.startup_page_title'); static readonly SPLASH_WELCOME: Resource = $r('app.string.startup_page_desc'); static readonly INTRODUCTION_TITLE: Resource = $r('app.string.top_text_zone'); static readonly TRAIN_TITLE: Resource = $r('app.string.top_text_train'); /** * Default content in the search box. */ static readonly PANEL_PLACEHOLDER: Resource = $r('app.string.default_search'); /** * Number of columns. */ static readonly GRID_COLUMNS: string = '1fr 1fr 1fr 1fr 1fr'; /** * The start time of the line 1. */ static readonly LINE_ONE_START_TIME: string = "08:00"; /** * The end time of the line 1. */ static readonly LINE_ONE_END_TIME: string = "18:30"; /** * The start time of the line 2. */ static readonly LINE_TWO_START_TIME: string = "08:00"; /** * The end time of the line 2. */ static readonly LINE_TWO_END_TIME: string = "18:32"; /** * The weekday start time of the line 3. */ static readonly LINE_THREE_START_TIME: string = "08:00"; /** * The weekday end time of the line 3. */ static readonly LINE_THREE_END_TIME: string = "17:55"; /** * The weekend start time of the line 3. */ static readonly LINE_THREE_WEEKEND_START_TIME: string = "07:57"; /** * The weekend end time of the line 3. */ static readonly LINE_THREE_WEEKEND_END_TIME: string = "18:30"; /** * Introduction page url. */ static readonly INTRODUCTION_URL: string = 'pages/IntroductionPage'; /** * The arrow url of the train. */ static readonly ARROW_URL: string = "common/images/ic_train_arrow.png"; /** * The url of the train. */ static readonly TRAIN_URL: string = "common/images/ic_train.png"; /** * The circle url of the train. */ static readonly CIRCLE_URL: string = "common/images/ic_circle.png"; /** * Icon subtitle array. */ static readonly ICON_SUBTITLE_ARRAY: Array<string> = ['DESIGN STYLE', 'BUILDING INFORMATION', 'GEOGRAPHIC LOCATION']; /** * Geography light. */ static readonly GEOGRAPHY_LIGHT: string = 'geography_light'; /** * Geography dark. */ static readonly GEOGRAPHY_DARK: string = 'geography_dark'; /** * Building text. */ static readonly BUILDING_TEXT: string = 'building'; /** * Page transition exit delay. */ static readonly EXIT_DELAY: number = 100; /** * Swiper transition duration. */ static readonly SWIPER_DURATION: number = 300; /** * Shared transition duration. */ static readonly SHARED_DURATION: number = 800; /** * Image item shadow radius. */ static readonly SHADOW_RADIUS: number = 50; /** * Double number. */ static readonly DOUBLE_NUM: number = 50; /** * Max scale. */ static readonly MAX_SCALE: number = 4; /** * Color scale. */ static readonly COLOR_SCALE_1: number = 0.8; /** * Color scale. */ static readonly COLOR_SCALE_2: number = 1.0; /** * Swiper aspect ratio. */ static readonly SWIPER_ASPECT_RATIO: number = 6 / 5; /** * Constant used to convert angles to radians. */ static readonly RADIAN_CONSTANT: number = Math.PI / 180.0; /** * Bottom Latitude. */ static readonly SOUTH_LATITUDE: number = 22.875142; /** * Top Latitude. */ static readonly NORTH_LATITUDE: number = 22.885136; /** * Left Longitude. */ static readonly WEST_LONGITUDE: number = 113.882035; /** * Right Longitude. */ static readonly EAST_LONGITUDE: number = 113.890274; /** * Pixel width of the base map. */ static readonly MAP_WIDTH: number = 2744; /** * Pixel height of the base map. */ static readonly MAP_HEIGHT: number = 1826; /** * X-axis adjustment value. */ static readonly X_ADJ: number = -480; /** * Y-axis adjustment value. */ static readonly Y_ADJ: number = -78; /** * Quarter circle. */ static readonly QUARTER_CIRCLE: number = Math.PI / 4; /** * Operation constant. */ static readonly DOUBLE_OR_HALF: number = 2; /** * Number of landmarks on the map */ static MAP_LANDMARKS_LENGTH: number = 10; /** * Map Zoom Ratio. */ static readonly MAP_ZOOM_RATIO: number = 1.1; /** * Maximum number of magnifications. */ static readonly ZOOM_MAX_TIMES: number = 4; /** * Coordinate dimension. */ static readonly MAP_LANDMARKS_SIZE: number = 40; /** * Scale precision of kneading gestures. */ static readonly MAP_SCALE_ACCURACY: number = 2; /** * Map font horizontal offset. */ static readonly MAP_TEXT_OFFSET_X: number = 42; /** * Map font vertical offset. */ static readonly MAP_TEXT_OFFSET_Y: number = 8; /** * Map Operation Finger Count. */ static readonly MAP_FINGER_COUNT: number = 2; /** * Transparency at presentation. */ static readonly PANEL_HIGH_OPACITY: number = 0.8; /** * Transparency when folded. */ static readonly PANEL_LOW_OPACITY: number = 0.3; /** * Height when unfolded. */ static readonly PANEL_FULL_HEIGHT: number = 258; /** * Animation duration. */ static readonly ANIMATION_DURATION: number = 750; /** * Normal font color opacity. */ static readonly FONT_COLOR_OPACITY_NORMAL: number = 0.6; /** * Full percent number. */ static readonly FULL_PERCENT_NUMBER: number = 100; /** * Image swiper cache count. */ static readonly IMAGE_SWIPER_CACHE_COUNT: number = 12; /** * Animation duration normal. */ static readonly ANIMATION_DURATION_NORMAL: number = 1000; /** * List position begin. */ static readonly LIST_POSITION_BEGIN: number = 0; /** * List position middle. */ static readonly LIST_POSITION_MIDDLE: number = 1; /** * List position end. */ static readonly LIST_POSITION_END: number = 2; /** * Opacity min. */ static readonly OPACITY_MIN: number = 0; /** * Opacity max. */ static OPACITY_MAX: number = 1; /** * List scroll down threshold. */ static readonly LIST_SCROLL_DOWN_THRESHOLD: number = -40; /** * Home icon margin top. */ static readonly HOME_ICON_MARGIN_TOP: number = 80; /** * Device dpi. */ static readonly DEVICE_DPI: number = 160; /** * Offset sum threshold. */ static readonly OFFSET_SUM_THRESHOLD: number = 10; /** * Offset divide ratio. */ static readonly OFFSET_DIVIDE_RATIO: number = 5; /** * Scroll up top threshold. */ static readonly SCROLL_UP_TOP_THRESHOLD: number = -100; /** * Star icon margin. */ static readonly STAR_ICON_MARGIN: number = 80; /** * Fixed item Height. */ static readonly FIXED_ITEM_HEIGHT: number = 500; /** * Sticky height. */ static readonly STICKY_HEIGHT: number = 229; /** * Second list item height. */ static readonly SECOND_LIST_ITEM_HEIGHT: number = 350; /** * Min image height. */ static readonly MIN_IMAGE_HEIGHT: number = 40; /** * Introduction image count. */ static readonly INTRODUCTION_IMAGE_COUNT: number = 5; /** * Image animation duration. */ static readonly IMAGE_ANIMATION_DURATION: number = 300; /** * Image divide number. */ static readonly HALF_COUNT = Math.floor(CommonConstants.INTRODUCTION_IMAGE_COUNT / CommonConstants.DOUBLE_OR_HALF); /** * Image width offset. */ static readonly IMAGE_WIDTH_OFFSET: number = 6.7; /** * Image x offset max. */ static readonly IMAGE_X_OFFSET_MAX: number = 70; /** * Image x offset min. */ static readonly IMAGE_x_OFFSET_MIN: number = 45; /** * Image opacity reduce. */ static readonly IMAGE_OPACITY_REDUCE: number = 0.1; /** * Image aspect ratio. */ static readonly IMAGE_ASPECT_RATIO: number = 16 / 21; /** * Image blur reduce. */ static readonly IMAGE_BLUR_REDUCE: number = 10; /** * Title icon animation duration. */ static readonly TITLE_ICON_ANIMATION_DURATION: number = 500; /** * No continuation. */ static readonly NO_CONTINUATION: string = 'false'; /** * Can continuation. */ static readonly CAN_CONTINUATION: string = 'true'; /** * The space of the train component. */ static readonly TRAIN_SPACE: number = 12; /** * The aspectRatio of the train map image. */ static readonly TRAIN_ASPECT_RATIO: number = 1.75; /** * The borderRadius of the train map image. */ static readonly TRAIN_BORDER_RADIUS: number = 8; /** * The fontWeight of the train operation. */ static readonly OPERATION_FONT_WEIGHT: number = 500; /** * The fontWeight of the train interval. */ static readonly INTERVAL_FONT_WEIGHT: number = 400; /** * The padding left of the train. */ static readonly TRAIN_PADDING_LEFT: number = 12; /** * The padding right of the train. */ static readonly TRAIN_PADDING_RIGHT: number = 12; /** * The padding top of the train. */ static readonly TRAIN_PADDING_TOP: number = 17; /** * The padding bottom of the train. */ static readonly TRAIN_PADDING_BOTTOM: number = 18; /** * The aspectRatio of the canvas. */ static readonly CANVAS_ASPECT_RADIO: number = 2.22; /** * The borderRadius of the canvas. */ static readonly CANVAS_BORDER_RADIUS: number = 4; /** * The width of the canvas. */ static readonly CANVAS_WIDTH: number = 865; /** * The height of the canvas. */ static readonly CANVAS_HEIGHT: number = 494; /** * The width of the arrow. */ static readonly ARROW_WIDTH: number = 28; /** * The height of the arrow. */ static readonly ARROW_HEIGHT: number = 28; /** * The offset x of the arrow. */ static readonly ARROW_OFFSET_X: number = 28 / 2; /** * The offset y of the arrow. */ static readonly ARROW_OFFSET_Y: number = 28 / 2; /** * The width of the train. */ static readonly TRAIN_WIDTH: number = 10; /** * The height of the train. */ static readonly TRAIN_HEIGHT: number = 10; /** * The offset x of the train. */ static readonly TRAIN_OFFSET_X: number = 5; /** * The offset y of the train. */ static readonly TRAIN_OFFSET_Y: number = 5.5; /** * The width of the circle. */ static readonly CIRCLE_WIDTH: number = 32; /** * The height of the circle. */ static readonly CIRCLE_HEIGHT: number = 32; /** * The offset x of the circle. */ static readonly CIRCLE_OFFSET_X: number = 16; /** * The offset y of the circle. */ static readonly CIRCLE_OFFSET_Y: number = 16; /** * The init rotate angle of the train. */ static readonly INIT_ROTATE_ANGLE: number = -115 - 90; /** * The millisecond of line 1. */ static readonly LINE_ONE_TIME: number = 10 * 60 * 1000; /** * The millisecond of line 2. */ static readonly LINE_TWO_TIME: number = 17 * 60 * 1000; /** * The millisecond of line 3. */ static readonly LINE_THREE_TIME: number = 37 * 60 * 1000; /** * The Horizontal threshold of canvas. */ static readonly HORIZONTAL_THRESHOLD: number = 20; /** * The vertical threshold of canvas. */ static readonly VERTICAL_THRESHOLD: number = 10; /** * The average error of position. */ static readonly AVERAGE_ERROR: number = 2; /** * The basic rotate angle of the train. */ static readonly BASIC_ROTATE_ANGLE: number = -115; /** * The direction angle of the train. */ static readonly DIRECTION: number = 90; /** * The PI angle of the train. */ static readonly PI_ANGLE: number = 180; }
AST#export_declaration#Left export AST#class_declaration#Left class CommonConstants AST#class_body#Left { /** * Component size. */ AST#property_declaration#Left static readonly SWIPER_DEFAULT_WIDTH : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '66%' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly FULL_PERCENT : 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 HALF_PERCENT : AST#type_annotation#Left AST#primary_type#Left string 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 IMAGE_CONTAINER_HEIGHT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '42%' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly FULL_SIZE : 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 ICON_SIZE : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '40%' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly BAR_WEIGHT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '25%' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly BAR_HEIGHT : AST#type_annotation#Left AST#primary_type#Left string 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 CONTENT_WIDTH_PERCENT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '87%' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly SEARCHBAR_WIDTH : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '91.1%' AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left static readonly IMAGE_HEIGHT_MIN : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '78%' AST#expression#Right ; AST#property_declaration#Right /** * Component location. */ AST#property_declaration#Left static readonly PERCENTAGE_78 : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '78%' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly PERCENTAGE_15 : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '15%' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly PERCENTAGE_25 : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '25%' AST#expression#Right ; AST#property_declaration#Right /** * Component constants. */ AST#property_declaration#Left static readonly 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 BORDER_WIDTH : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0.5 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly COUNTDOWN : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 5 AST#expression#Right ; AST#property_declaration#Right /** * Time constants. */ AST#property_declaration#Left static readonly DURATION : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1000 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly MORNING_TIME : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 6 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly EVENING_TIME : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 18 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly NIGHT_TIME : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 19 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly SPLASH_DURATION : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 3000 AST#expression#Right ; AST#property_declaration#Right /** * Color constants. */ AST#property_declaration#Left static readonly TRANSPARENT_COLOR : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '#00ffffff' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly NAVIGATION_BAR_COLOR : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '#00ff00' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly STATUS_BAR_CONTENT_COLOR : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '#ffffff' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly NAVIGATION_BAR_CONTENT_COLOR : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '#ffffff' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly THEME_COLOR : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '#c82424' AST#expression#Right ; AST#property_declaration#Right /** * Title text. */ AST#property_declaration#Left static readonly SPLASH_DES : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.startup_page_title' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly SPLASH_WELCOME : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.startup_page_desc' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly INTRODUCTION_TITLE : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.top_text_zone' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly TRAIN_TITLE : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.top_text_train' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * Default content in the search box. */ AST#property_declaration#Left static readonly PANEL_PLACEHOLDER : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.default_search' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * Number of columns. */ AST#property_declaration#Left static readonly GRID_COLUMNS : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '1fr 1fr 1fr 1fr 1fr' AST#expression#Right ; AST#property_declaration#Right /** * The start time of the line 1. */ AST#property_declaration#Left static readonly LINE_ONE_START_TIME : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "08:00" AST#expression#Right ; AST#property_declaration#Right /** * The end time of the line 1. */ AST#property_declaration#Left static readonly LINE_ONE_END_TIME : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "18:30" AST#expression#Right ; AST#property_declaration#Right /** * The start time of the line 2. */ AST#property_declaration#Left static readonly LINE_TWO_START_TIME : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "08:00" AST#expression#Right ; AST#property_declaration#Right /** * The end time of the line 2. */ AST#property_declaration#Left static readonly LINE_TWO_END_TIME : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "18:32" AST#expression#Right ; AST#property_declaration#Right /** * The weekday start time of the line 3. */ AST#property_declaration#Left static readonly LINE_THREE_START_TIME : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "08:00" AST#expression#Right ; AST#property_declaration#Right /** * The weekday end time of the line 3. */ AST#property_declaration#Left static readonly LINE_THREE_END_TIME : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "17:55" AST#expression#Right ; AST#property_declaration#Right /** * The weekend start time of the line 3. */ AST#property_declaration#Left static readonly LINE_THREE_WEEKEND_START_TIME : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "07:57" AST#expression#Right ; AST#property_declaration#Right /** * The weekend end time of the line 3. */ AST#property_declaration#Left static readonly LINE_THREE_WEEKEND_END_TIME : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "18:30" AST#expression#Right ; AST#property_declaration#Right /** * Introduction page url. */ AST#property_declaration#Left static readonly INTRODUCTION_URL : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'pages/IntroductionPage' AST#expression#Right ; AST#property_declaration#Right /** * The arrow url of the train. */ AST#property_declaration#Left static readonly ARROW_URL : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "common/images/ic_train_arrow.png" AST#expression#Right ; AST#property_declaration#Right /** * The url of the train. */ AST#property_declaration#Left static readonly TRAIN_URL : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "common/images/ic_train.png" AST#expression#Right ; AST#property_declaration#Right /** * The circle url of the train. */ AST#property_declaration#Left static readonly CIRCLE_URL : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "common/images/ic_circle.png" AST#expression#Right ; AST#property_declaration#Right /** * Icon subtitle array. */ AST#property_declaration#Left static readonly ICON_SUBTITLE_ARRAY : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'DESIGN STYLE' AST#expression#Right , AST#expression#Left 'BUILDING INFORMATION' AST#expression#Right , AST#expression#Left 'GEOGRAPHIC LOCATION' AST#expression#Right ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right /** * Geography light. */ AST#property_declaration#Left static readonly GEOGRAPHY_LIGHT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'geography_light' AST#expression#Right ; AST#property_declaration#Right /** * Geography dark. */ AST#property_declaration#Left static readonly GEOGRAPHY_DARK : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'geography_dark' AST#expression#Right ; AST#property_declaration#Right /** * Building text. */ AST#property_declaration#Left static readonly BUILDING_TEXT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'building' AST#expression#Right ; AST#property_declaration#Right /** * Page transition exit delay. */ AST#property_declaration#Left static readonly EXIT_DELAY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 100 AST#expression#Right ; AST#property_declaration#Right /** * Swiper transition duration. */ AST#property_declaration#Left static readonly SWIPER_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 /** * Shared transition duration. */ AST#property_declaration#Left static readonly SHARED_DURATION : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 800 AST#expression#Right ; AST#property_declaration#Right /** * Image item shadow radius. */ AST#property_declaration#Left static readonly SHADOW_RADIUS : 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 /** * Double number. */ AST#property_declaration#Left static readonly DOUBLE_NUM : 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 /** * Max scale. */ AST#property_declaration#Left static readonly MAX_SCALE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 4 AST#expression#Right ; AST#property_declaration#Right /** * Color scale. */ AST#property_declaration#Left static readonly COLOR_SCALE_1 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0.8 AST#expression#Right ; AST#property_declaration#Right /** * Color scale. */ AST#property_declaration#Left static readonly COLOR_SCALE_2 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1.0 AST#expression#Right ; AST#property_declaration#Right /** * Swiper aspect ratio. */ AST#property_declaration#Left static readonly SWIPER_ASPECT_RATIO : 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 6 AST#expression#Right / AST#expression#Left 5 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * Constant used to convert angles to radians. */ AST#property_declaration#Left static readonly RADIAN_CONSTANT : 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 Math AST#expression#Right . PI AST#member_expression#Right AST#expression#Right / AST#expression#Left 180.0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * Bottom Latitude. */ AST#property_declaration#Left static readonly SOUTH_LATITUDE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 22.875142 AST#expression#Right ; AST#property_declaration#Right /** * Top Latitude. */ AST#property_declaration#Left static readonly NORTH_LATITUDE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 22.885136 AST#expression#Right ; AST#property_declaration#Right /** * Left Longitude. */ AST#property_declaration#Left static readonly WEST_LONGITUDE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 113.882035 AST#expression#Right ; AST#property_declaration#Right /** * Right Longitude. */ AST#property_declaration#Left static readonly EAST_LONGITUDE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 113.890274 AST#expression#Right ; AST#property_declaration#Right /** * Pixel width of the base map. */ AST#property_declaration#Left static readonly MAP_WIDTH : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 2744 AST#expression#Right ; AST#property_declaration#Right /** * Pixel height of the base map. */ AST#property_declaration#Left static readonly MAP_HEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1826 AST#expression#Right ; AST#property_declaration#Right /** * X-axis adjustment value. */ AST#property_declaration#Left static readonly X_ADJ : 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 480 AST#expression#Right AST#unary_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * Y-axis adjustment value. */ AST#property_declaration#Left static readonly Y_ADJ : 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 78 AST#expression#Right AST#unary_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * Quarter circle. */ AST#property_declaration#Left static readonly QUARTER_CIRCLE : 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 Math AST#expression#Right . PI AST#member_expression#Right AST#expression#Right / AST#expression#Left 4 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * Operation constant. */ AST#property_declaration#Left static readonly DOUBLE_OR_HALF : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 2 AST#expression#Right ; AST#property_declaration#Right /** * Number of landmarks on the map */ AST#property_declaration#Left static MAP_LANDMARKS_LENGTH : 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 /** * Map Zoom Ratio. */ AST#property_declaration#Left static readonly MAP_ZOOM_RATIO : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1.1 AST#expression#Right ; AST#property_declaration#Right /** * Maximum number of magnifications. */ AST#property_declaration#Left static readonly ZOOM_MAX_TIMES : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 4 AST#expression#Right ; AST#property_declaration#Right /** * Coordinate dimension. */ AST#property_declaration#Left static readonly MAP_LANDMARKS_SIZE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 40 AST#expression#Right ; AST#property_declaration#Right /** * Scale precision of kneading gestures. */ AST#property_declaration#Left static readonly MAP_SCALE_ACCURACY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 2 AST#expression#Right ; AST#property_declaration#Right /** * Map font horizontal offset. */ AST#property_declaration#Left static readonly MAP_TEXT_OFFSET_X : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 42 AST#expression#Right ; AST#property_declaration#Right /** * Map font vertical offset. */ AST#property_declaration#Left static readonly MAP_TEXT_OFFSET_Y : 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 /** * Map Operation Finger Count. */ AST#property_declaration#Left static readonly MAP_FINGER_COUNT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 2 AST#expression#Right ; AST#property_declaration#Right /** * Transparency at presentation. */ AST#property_declaration#Left static readonly PANEL_HIGH_OPACITY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0.8 AST#expression#Right ; AST#property_declaration#Right /** * Transparency when folded. */ AST#property_declaration#Left static readonly PANEL_LOW_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 /** * Height when unfolded. */ AST#property_declaration#Left static readonly PANEL_FULL_HEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 258 AST#expression#Right ; AST#property_declaration#Right /** * Animation duration. */ AST#property_declaration#Left static readonly ANIMATION_DURATION : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 750 AST#expression#Right ; AST#property_declaration#Right /** * Normal font color opacity. */ AST#property_declaration#Left static readonly FONT_COLOR_OPACITY_NORMAL : 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 /** * Full percent number. */ AST#property_declaration#Left static readonly FULL_PERCENT_NUMBER : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 100 AST#expression#Right ; AST#property_declaration#Right /** * Image swiper cache count. */ AST#property_declaration#Left static readonly IMAGE_SWIPER_CACHE_COUNT : 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 /** * Animation duration normal. */ AST#property_declaration#Left static readonly ANIMATION_DURATION_NORMAL : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1000 AST#expression#Right ; AST#property_declaration#Right /** * List position begin. */ AST#property_declaration#Left static readonly LIST_POSITION_BEGIN : 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 /** * List position middle. */ AST#property_declaration#Left static readonly LIST_POSITION_MIDDLE : 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 /** * List position end. */ AST#property_declaration#Left static readonly LIST_POSITION_END : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 2 AST#expression#Right ; AST#property_declaration#Right /** * Opacity min. */ AST#property_declaration#Left static readonly OPACITY_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#property_declaration#Right /** * Opacity max. */ AST#property_declaration#Left static OPACITY_MAX : 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 /** * List scroll down threshold. */ AST#property_declaration#Left static readonly LIST_SCROLL_DOWN_THRESHOLD : 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 40 AST#expression#Right AST#unary_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * Home icon margin top. */ AST#property_declaration#Left static readonly HOME_ICON_MARGIN_TOP : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 80 AST#expression#Right ; AST#property_declaration#Right /** * Device dpi. */ AST#property_declaration#Left static readonly DEVICE_DPI : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 160 AST#expression#Right ; AST#property_declaration#Right /** * Offset sum threshold. */ AST#property_declaration#Left static readonly OFFSET_SUM_THRESHOLD : 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 /** * Offset divide ratio. */ AST#property_declaration#Left static readonly OFFSET_DIVIDE_RATIO : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 5 AST#expression#Right ; AST#property_declaration#Right /** * Scroll up top threshold. */ AST#property_declaration#Left static readonly SCROLL_UP_TOP_THRESHOLD : 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 100 AST#expression#Right AST#unary_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * Star icon margin. */ AST#property_declaration#Left static readonly STAR_ICON_MARGIN : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 80 AST#expression#Right ; AST#property_declaration#Right /** * Fixed item Height. */ AST#property_declaration#Left static readonly FIXED_ITEM_HEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 500 AST#expression#Right ; AST#property_declaration#Right /** * Sticky height. */ AST#property_declaration#Left static readonly STICKY_HEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 229 AST#expression#Right ; AST#property_declaration#Right /** * Second list item height. */ AST#property_declaration#Left static readonly SECOND_LIST_ITEM_HEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 350 AST#expression#Right ; AST#property_declaration#Right /** * Min image height. */ AST#property_declaration#Left static readonly MIN_IMAGE_HEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 40 AST#expression#Right ; AST#property_declaration#Right /** * Introduction image count. */ AST#property_declaration#Left static readonly INTRODUCTION_IMAGE_COUNT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 5 AST#expression#Right ; AST#property_declaration#Right /** * Image animation duration. */ AST#property_declaration#Left static readonly IMAGE_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 /** * Image divide number. */ AST#property_declaration#Left static readonly HALF_COUNT = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . INTRODUCTION_IMAGE_COUNT AST#member_expression#Right AST#expression#Right / AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . DOUBLE_OR_HALF AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * Image width offset. */ AST#property_declaration#Left static readonly IMAGE_WIDTH_OFFSET : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 6.7 AST#expression#Right ; AST#property_declaration#Right /** * Image x offset max. */ AST#property_declaration#Left static readonly IMAGE_X_OFFSET_MAX : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 70 AST#expression#Right ; AST#property_declaration#Right /** * Image x offset min. */ AST#property_declaration#Left static readonly IMAGE_x_OFFSET_MIN : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 45 AST#expression#Right ; AST#property_declaration#Right /** * Image opacity reduce. */ AST#property_declaration#Left static readonly IMAGE_OPACITY_REDUCE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0.1 AST#expression#Right ; AST#property_declaration#Right /** * Image aspect ratio. */ AST#property_declaration#Left static readonly IMAGE_ASPECT_RATIO : 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 16 AST#expression#Right / AST#expression#Left 21 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * Image blur reduce. */ AST#property_declaration#Left static readonly IMAGE_BLUR_REDUCE : 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 /** * Title icon animation duration. */ AST#property_declaration#Left static readonly TITLE_ICON_ANIMATION_DURATION : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 500 AST#expression#Right ; AST#property_declaration#Right /** * No continuation. */ AST#property_declaration#Left static readonly NO_CONTINUATION : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'false' AST#expression#Right ; AST#property_declaration#Right /** * Can continuation. */ AST#property_declaration#Left static readonly CAN_CONTINUATION : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'true' AST#expression#Right ; AST#property_declaration#Right /** * The space of the train component. */ AST#property_declaration#Left static readonly TRAIN_SPACE : 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 /** * The aspectRatio of the train map image. */ AST#property_declaration#Left static readonly TRAIN_ASPECT_RATIO : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1.75 AST#expression#Right ; AST#property_declaration#Right /** * The borderRadius of the train map image. */ AST#property_declaration#Left static readonly TRAIN_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 /** * The fontWeight of the train operation. */ AST#property_declaration#Left static readonly OPERATION_FONT_WEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 500 AST#expression#Right ; AST#property_declaration#Right /** * The fontWeight of the train interval. */ AST#property_declaration#Left static readonly INTERVAL_FONT_WEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 400 AST#expression#Right ; AST#property_declaration#Right /** * The padding left of the train. */ AST#property_declaration#Left static readonly TRAIN_PADDING_LEFT : 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 /** * The padding right of the train. */ AST#property_declaration#Left static readonly TRAIN_PADDING_RIGHT : 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 /** * The padding top of the train. */ AST#property_declaration#Left static readonly TRAIN_PADDING_TOP : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 17 AST#expression#Right ; AST#property_declaration#Right /** * The padding bottom of the train. */ AST#property_declaration#Left static readonly TRAIN_PADDING_BOTTOM : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 18 AST#expression#Right ; AST#property_declaration#Right /** * The aspectRatio of the canvas. */ AST#property_declaration#Left static readonly CANVAS_ASPECT_RADIO : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 2.22 AST#expression#Right ; AST#property_declaration#Right /** * The borderRadius of the canvas. */ AST#property_declaration#Left static readonly CANVAS_BORDER_RADIUS : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 4 AST#expression#Right ; AST#property_declaration#Right /** * The width of the canvas. */ AST#property_declaration#Left static readonly CANVAS_WIDTH : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 865 AST#expression#Right ; AST#property_declaration#Right /** * The height of the canvas. */ AST#property_declaration#Left static readonly CANVAS_HEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 494 AST#expression#Right ; AST#property_declaration#Right /** * The width of the arrow. */ AST#property_declaration#Left static readonly ARROW_WIDTH : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 28 AST#expression#Right ; AST#property_declaration#Right /** * The height of the arrow. */ AST#property_declaration#Left static readonly ARROW_HEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 28 AST#expression#Right ; AST#property_declaration#Right /** * The offset x of the arrow. */ AST#property_declaration#Left static readonly ARROW_OFFSET_X : 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 28 AST#expression#Right / AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * The offset y of the arrow. */ AST#property_declaration#Left static readonly ARROW_OFFSET_Y : 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 28 AST#expression#Right / AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * The width of the train. */ AST#property_declaration#Left static readonly TRAIN_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 /** * The height of the train. */ AST#property_declaration#Left static readonly TRAIN_HEIGHT : 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 /** * The offset x of the train. */ AST#property_declaration#Left static readonly TRAIN_OFFSET_X : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 5 AST#expression#Right ; AST#property_declaration#Right /** * The offset y of the train. */ AST#property_declaration#Left static readonly TRAIN_OFFSET_Y : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 5.5 AST#expression#Right ; AST#property_declaration#Right /** * The width of the circle. */ AST#property_declaration#Left static readonly CIRCLE_WIDTH : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 32 AST#expression#Right ; AST#property_declaration#Right /** * The height of the circle. */ AST#property_declaration#Left static readonly CIRCLE_HEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 32 AST#expression#Right ; AST#property_declaration#Right /** * The offset x of the circle. */ AST#property_declaration#Left static readonly CIRCLE_OFFSET_X : 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 /** * The offset y of the circle. */ AST#property_declaration#Left static readonly CIRCLE_OFFSET_Y : 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 /** * The init rotate angle of the train. */ AST#property_declaration#Left static readonly INIT_ROTATE_ANGLE : 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#unary_expression#Left - AST#expression#Left 115 AST#expression#Right AST#unary_expression#Right AST#expression#Right - AST#expression#Left 90 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * The millisecond of line 1. */ AST#property_declaration#Left static readonly LINE_ONE_TIME : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 10 AST#expression#Right * AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right * AST#expression#Left 1000 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * The millisecond of line 2. */ AST#property_declaration#Left static readonly LINE_TWO_TIME : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 17 AST#expression#Right * AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right * AST#expression#Left 1000 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * The millisecond of line 3. */ AST#property_declaration#Left static readonly LINE_THREE_TIME : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 37 AST#expression#Right * AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right * AST#expression#Left 1000 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * The Horizontal threshold of canvas. */ AST#property_declaration#Left static readonly HORIZONTAL_THRESHOLD : 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 /** * The vertical threshold of canvas. */ AST#property_declaration#Left static readonly VERTICAL_THRESHOLD : 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 /** * The average error of position. */ AST#property_declaration#Left static readonly AVERAGE_ERROR : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 2 AST#expression#Right ; AST#property_declaration#Right /** * The basic rotate angle of the train. */ AST#property_declaration#Left static readonly BASIC_ROTATE_ANGLE : 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 115 AST#expression#Right AST#unary_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * The direction angle of the train. */ AST#property_declaration#Left static readonly DIRECTION : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 90 AST#expression#Right ; AST#property_declaration#Right /** * The PI angle of the train. */ AST#property_declaration#Left static readonly PI_ANGLE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 180 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_DEFAULT_WIDTH: string = '66%'; static readonly FULL_PERCENT: string = '100%'; static readonly HALF_PERCENT: string = '50%'; static readonly IMAGE_CONTAINER_HEIGHT: string = '42%'; static readonly FULL_SIZE: string = '100%'; static readonly ICON_SIZE: string = '40%'; static readonly BAR_WEIGHT: string = '25%'; static readonly BAR_HEIGHT: string = '10%'; static readonly CONTENT_WIDTH_PERCENT: string = '87%'; static readonly SEARCHBAR_WIDTH: string = '91.1%' static readonly IMAGE_HEIGHT_MIN: string = '78%'; static readonly PERCENTAGE_78: string = '78%'; static readonly PERCENTAGE_15: string = '15%'; static readonly PERCENTAGE_25: string = '25%'; static readonly OPACITY: number = 0.6; static readonly BORDER_WIDTH: number = 0.5; static readonly COUNTDOWN: number = 5; static readonly DURATION: number = 1000; static readonly MORNING_TIME: number = 6; static readonly EVENING_TIME: number = 18; static readonly NIGHT_TIME: number = 19; static readonly SPLASH_DURATION: number = 3000; static readonly TRANSPARENT_COLOR: string = '#00ffffff'; static readonly NAVIGATION_BAR_COLOR: string = '#00ff00'; static readonly STATUS_BAR_CONTENT_COLOR: string = '#ffffff'; static readonly NAVIGATION_BAR_CONTENT_COLOR: string = '#ffffff'; static readonly THEME_COLOR: string = '#c82424'; static readonly SPLASH_DES: Resource = $r('app.string.startup_page_title'); static readonly SPLASH_WELCOME: Resource = $r('app.string.startup_page_desc'); static readonly INTRODUCTION_TITLE: Resource = $r('app.string.top_text_zone'); static readonly TRAIN_TITLE: Resource = $r('app.string.top_text_train'); static readonly PANEL_PLACEHOLDER: Resource = $r('app.string.default_search'); static readonly GRID_COLUMNS: string = '1fr 1fr 1fr 1fr 1fr'; static readonly LINE_ONE_START_TIME: string = "08:00"; static readonly LINE_ONE_END_TIME: string = "18:30"; static readonly LINE_TWO_START_TIME: string = "08:00"; static readonly LINE_TWO_END_TIME: string = "18:32"; static readonly LINE_THREE_START_TIME: string = "08:00"; static readonly LINE_THREE_END_TIME: string = "17:55"; static readonly LINE_THREE_WEEKEND_START_TIME: string = "07:57"; static readonly LINE_THREE_WEEKEND_END_TIME: string = "18:30"; static readonly INTRODUCTION_URL: string = 'pages/IntroductionPage'; static readonly ARROW_URL: string = "common/images/ic_train_arrow.png"; static readonly TRAIN_URL: string = "common/images/ic_train.png"; static readonly CIRCLE_URL: string = "common/images/ic_circle.png"; static readonly ICON_SUBTITLE_ARRAY: Array<string> = ['DESIGN STYLE', 'BUILDING INFORMATION', 'GEOGRAPHIC LOCATION']; static readonly GEOGRAPHY_LIGHT: string = 'geography_light'; static readonly GEOGRAPHY_DARK: string = 'geography_dark'; static readonly BUILDING_TEXT: string = 'building'; static readonly EXIT_DELAY: number = 100; static readonly SWIPER_DURATION: number = 300; static readonly SHARED_DURATION: number = 800; static readonly SHADOW_RADIUS: number = 50; static readonly DOUBLE_NUM: number = 50; static readonly MAX_SCALE: number = 4; static readonly COLOR_SCALE_1: number = 0.8; static readonly COLOR_SCALE_2: number = 1.0; static readonly SWIPER_ASPECT_RATIO: number = 6 / 5; static readonly RADIAN_CONSTANT: number = Math.PI / 180.0; static readonly SOUTH_LATITUDE: number = 22.875142; static readonly NORTH_LATITUDE: number = 22.885136; static readonly WEST_LONGITUDE: number = 113.882035; static readonly EAST_LONGITUDE: number = 113.890274; static readonly MAP_WIDTH: number = 2744; static readonly MAP_HEIGHT: number = 1826; static readonly X_ADJ: number = -480; static readonly Y_ADJ: number = -78; static readonly QUARTER_CIRCLE: number = Math.PI / 4; static readonly DOUBLE_OR_HALF: number = 2; static MAP_LANDMARKS_LENGTH: number = 10; static readonly MAP_ZOOM_RATIO: number = 1.1; static readonly ZOOM_MAX_TIMES: number = 4; static readonly MAP_LANDMARKS_SIZE: number = 40; static readonly MAP_SCALE_ACCURACY: number = 2; static readonly MAP_TEXT_OFFSET_X: number = 42; static readonly MAP_TEXT_OFFSET_Y: number = 8; static readonly MAP_FINGER_COUNT: number = 2; static readonly PANEL_HIGH_OPACITY: number = 0.8; static readonly PANEL_LOW_OPACITY: number = 0.3; static readonly PANEL_FULL_HEIGHT: number = 258; static readonly ANIMATION_DURATION: number = 750; static readonly FONT_COLOR_OPACITY_NORMAL: number = 0.6; static readonly FULL_PERCENT_NUMBER: number = 100; static readonly IMAGE_SWIPER_CACHE_COUNT: number = 12; static readonly ANIMATION_DURATION_NORMAL: number = 1000; static readonly LIST_POSITION_BEGIN: number = 0; static readonly LIST_POSITION_MIDDLE: number = 1; static readonly LIST_POSITION_END: number = 2; static readonly OPACITY_MIN: number = 0; static OPACITY_MAX: number = 1; static readonly LIST_SCROLL_DOWN_THRESHOLD: number = -40; static readonly HOME_ICON_MARGIN_TOP: number = 80; static readonly DEVICE_DPI: number = 160; static readonly OFFSET_SUM_THRESHOLD: number = 10; static readonly OFFSET_DIVIDE_RATIO: number = 5; static readonly SCROLL_UP_TOP_THRESHOLD: number = -100; static readonly STAR_ICON_MARGIN: number = 80; static readonly FIXED_ITEM_HEIGHT: number = 500; static readonly STICKY_HEIGHT: number = 229; static readonly SECOND_LIST_ITEM_HEIGHT: number = 350; static readonly MIN_IMAGE_HEIGHT: number = 40; static readonly INTRODUCTION_IMAGE_COUNT: number = 5; static readonly IMAGE_ANIMATION_DURATION: number = 300; static readonly HALF_COUNT = Math.floor(CommonConstants.INTRODUCTION_IMAGE_COUNT / CommonConstants.DOUBLE_OR_HALF); static readonly IMAGE_WIDTH_OFFSET: number = 6.7; static readonly IMAGE_X_OFFSET_MAX: number = 70; static readonly IMAGE_x_OFFSET_MIN: number = 45; static readonly IMAGE_OPACITY_REDUCE: number = 0.1; static readonly IMAGE_ASPECT_RATIO: number = 16 / 21; static readonly IMAGE_BLUR_REDUCE: number = 10; static readonly TITLE_ICON_ANIMATION_DURATION: number = 500; static readonly NO_CONTINUATION: string = 'false'; static readonly CAN_CONTINUATION: string = 'true'; static readonly TRAIN_SPACE: number = 12; static readonly TRAIN_ASPECT_RATIO: number = 1.75; static readonly TRAIN_BORDER_RADIUS: number = 8; static readonly OPERATION_FONT_WEIGHT: number = 500; static readonly INTERVAL_FONT_WEIGHT: number = 400; static readonly TRAIN_PADDING_LEFT: number = 12; static readonly TRAIN_PADDING_RIGHT: number = 12; static readonly TRAIN_PADDING_TOP: number = 17; static readonly TRAIN_PADDING_BOTTOM: number = 18; static readonly CANVAS_ASPECT_RADIO: number = 2.22; static readonly CANVAS_BORDER_RADIUS: number = 4; static readonly CANVAS_WIDTH: number = 865; static readonly CANVAS_HEIGHT: number = 494; static readonly ARROW_WIDTH: number = 28; static readonly ARROW_HEIGHT: number = 28; static readonly ARROW_OFFSET_X: number = 28 / 2; static readonly ARROW_OFFSET_Y: number = 28 / 2; static readonly TRAIN_WIDTH: number = 10; static readonly TRAIN_HEIGHT: number = 10; static readonly TRAIN_OFFSET_X: number = 5; static readonly TRAIN_OFFSET_Y: number = 5.5; static readonly CIRCLE_WIDTH: number = 32; static readonly CIRCLE_HEIGHT: number = 32; static readonly CIRCLE_OFFSET_X: number = 16; static readonly CIRCLE_OFFSET_Y: number = 16; static readonly INIT_ROTATE_ANGLE: number = -115 - 90; static readonly LINE_ONE_TIME: number = 10 * 60 * 1000; static readonly LINE_TWO_TIME: number = 17 * 60 * 1000; static readonly LINE_THREE_TIME: number = 37 * 60 * 1000; static readonly HORIZONTAL_THRESHOLD: number = 20; static readonly VERTICAL_THRESHOLD: number = 10; static readonly AVERAGE_ERROR: number = 2; static readonly BASIC_ROTATE_ANGLE: number = -115; static readonly DIRECTION: number = 90; static readonly PI_ANGLE: number = 180; }
https://github.com/IceYuanyyy/OxHornCampus.git/blob/bb5686f77fa36db89687502e35898cda218d601f/entry/src/main/ets/common/constants/CommonConstants.ets#L16-L534
25599fe9424de0da35e37e4ee2a25959e7845cc0
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/bottomdrawerslidecase/src/main/ets/view/BottomDrawerSlideCase.ets
arkts
searchAddress
搜索视图
@Builder searchAddress() { Column() { Row() { Text($r("app.string.bottomdrawerslidecase_set_out")) .fontSize($r("app.integer.bottomdrawerslidecase_number_15")) Text($r("app.string.bottomdrawerslidecase_destination_new")) .fontSize($r("app.integer.bottomdrawerslidecase_number_15")) .fontColor(Color.Green) Text($r("app.string.bottomdrawerslidecase_get_on_the_car")) .fontSize($r("app.integer.bottomdrawerslidecase_number_15")) } .margin({ left: $r("app.integer.bottomdrawerslidecase_number_10") }) .height($r("app.integer.bottomdrawerslidecase_height_50")) .width($r('app.string.bottom_drawer_slide_full_percent')) Text($r("app.string.bottomdrawerslidecase_please_destination")) .padding({ left: $r("app.integer.bottomdrawerslidecase_number_10") }) .fontSize($r("app.integer.bottomdrawerslidecase_number_20")) .fontWeight(2) .height($r("app.integer.bottomdrawerslidecase_number_60")) .backgroundColor($r("app.color.bottomdrawerslidecase_list_first_backgroundcolor")) .borderRadius($r("app.integer.bottomdrawerslidecase_number_10")) .width($r('app.string.bottom_drawer_slide_full_percent')) .onClick(() => { promptAction.showToast({ message: $r("app.string.bottomdrawerslidecase_promotion"), duration: 2000 }) }) } .height(this.bottomDrawerHeight.minHeight) .width($r('app.string.bottom_drawer_slide_90_percent')) .padding({ left: $r("app.integer.bottomdrawerslidecase_number_15"), right: $r("app.integer.bottomdrawerslidecase_number_15") }) .justifyContent(FlexAlign.Center) .borderRadius($r("app.integer.bottomdrawerslidecase_number_10")) .shadow({ radius: $r("app.integer.bottomdrawerslidecase_number_30"), // 阴影模糊半径 color: $r("app.color.bottomdrawerslidecase_list_first_backgroundcolor"), offsetY: $r("app.integer.bottomdrawerslidecase_number_5") // Y轴偏移量 }) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right searchAddress AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.bottomdrawerslidecase_set_out" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.bottomdrawerslidecase_number_15" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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.bottomdrawerslidecase_destination_new" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.bottomdrawerslidecase_number_15" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Green AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.bottomdrawerslidecase_get_on_the_car" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.bottomdrawerslidecase_number_15" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.bottomdrawerslidecase_number_10" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.bottomdrawerslidecase_height_50" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.bottom_drawer_slide_full_percent' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.bottomdrawerslidecase_please_destination" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.bottomdrawerslidecase_number_10" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.bottomdrawerslidecase_number_20" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left 2 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.bottomdrawerslidecase_number_60" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.color.bottomdrawerslidecase_list_first_backgroundcolor" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.bottomdrawerslidecase_number_10" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.bottom_drawer_slide_full_percent' 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.bottomdrawerslidecase_promotion" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left 2000 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bottomDrawerHeight AST#member_expression#Right AST#expression#Right . minHeight AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.bottom_drawer_slide_90_percent' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.bottomdrawerslidecase_number_15" 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.bottomdrawerslidecase_number_15" 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 . 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 . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.bottomdrawerslidecase_number_10" AST#expression#Right ) AST#resource_expression#Right 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 AST#resource_expression#Left $r ( AST#expression#Left "app.integer.bottomdrawerslidecase_number_30" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , // 阴影模糊半径 AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.color.bottomdrawerslidecase_list_first_backgroundcolor" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetY AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.bottomdrawerslidecase_number_5" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right // Y轴偏移量 } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder searchAddress() { Column() { Row() { Text($r("app.string.bottomdrawerslidecase_set_out")) .fontSize($r("app.integer.bottomdrawerslidecase_number_15")) Text($r("app.string.bottomdrawerslidecase_destination_new")) .fontSize($r("app.integer.bottomdrawerslidecase_number_15")) .fontColor(Color.Green) Text($r("app.string.bottomdrawerslidecase_get_on_the_car")) .fontSize($r("app.integer.bottomdrawerslidecase_number_15")) } .margin({ left: $r("app.integer.bottomdrawerslidecase_number_10") }) .height($r("app.integer.bottomdrawerslidecase_height_50")) .width($r('app.string.bottom_drawer_slide_full_percent')) Text($r("app.string.bottomdrawerslidecase_please_destination")) .padding({ left: $r("app.integer.bottomdrawerslidecase_number_10") }) .fontSize($r("app.integer.bottomdrawerslidecase_number_20")) .fontWeight(2) .height($r("app.integer.bottomdrawerslidecase_number_60")) .backgroundColor($r("app.color.bottomdrawerslidecase_list_first_backgroundcolor")) .borderRadius($r("app.integer.bottomdrawerslidecase_number_10")) .width($r('app.string.bottom_drawer_slide_full_percent')) .onClick(() => { promptAction.showToast({ message: $r("app.string.bottomdrawerslidecase_promotion"), duration: 2000 }) }) } .height(this.bottomDrawerHeight.minHeight) .width($r('app.string.bottom_drawer_slide_90_percent')) .padding({ left: $r("app.integer.bottomdrawerslidecase_number_15"), right: $r("app.integer.bottomdrawerslidecase_number_15") }) .justifyContent(FlexAlign.Center) .borderRadius($r("app.integer.bottomdrawerslidecase_number_10")) .shadow({ radius: $r("app.integer.bottomdrawerslidecase_number_30"), color: $r("app.color.bottomdrawerslidecase_list_first_backgroundcolor"), offsetY: $r("app.integer.bottomdrawerslidecase_number_5") }) }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/bottomdrawerslidecase/src/main/ets/view/BottomDrawerSlideCase.ets#L120-L164
13351776430ec9693494dec7c0081b4c02c02157
gitee
awa_Liny/LinysBrowser_NEXT
a5cd96a9aa8114cae4972937f94a8967e55d4a10
home/src/main/ets/hosts/bunch_of_tabs.ets
arkts
archive_onWorkingTab
Try to archive current main tab into a mht file. Calls the picker for user to save. @param dir Should be this.getUIContext().getHostContext()?.tempDir
archive_onWorkingTab(dir?: string) { // let dir = this.getUIContext().getHostContext()?.tempDir; if (dir) { this.workingMainTab().controller?.storeWebArchive(dir + '/meow_save.mht', false, ((e, filename) => { if (e) { console.error(`[Save Page] Failed: ${e.name}, ${e.message}, ${e.code}`); } if (filename) { console.log('[Save Page] OK: ' + filename); document_save_from_path(filename); } })) } }
AST#method_declaration#Left archive_onWorkingTab AST#parameter_list#Left ( AST#parameter#Left dir ? : 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 { // let dir = this.getUIContext().getHostContext()?.tempDir; AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left dir AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . workingMainTab AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . controller AST#member_expression#Right AST#expression#Right ?. storeWebArchive AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left dir AST#expression#Right + AST#expression#Left '/meow_save.mht' AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right , AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left e AST#parameter#Right , AST#parameter#Left filename AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left e AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [Save Page] Failed: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left e AST#expression#Right . name 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 e AST#expression#Right . message 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 e AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left filename AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left '[Save Page] OK: ' AST#expression#Right + AST#expression#Left filename AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left document_save_from_path AST#expression#Right AST#argument_list#Left ( AST#expression#Left filename AST#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#parenthesized_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
archive_onWorkingTab(dir?: string) { if (dir) { this.workingMainTab().controller?.storeWebArchive(dir + '/meow_save.mht', false, ((e, filename) => { if (e) { console.error(`[Save Page] Failed: ${e.name}, ${e.message}, ${e.code}`); } if (filename) { console.log('[Save Page] OK: ' + filename); document_save_from_path(filename); } })) } }
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/hosts/bunch_of_tabs.ets#L129-L142
ce14c244b17849c52d649424428e3ffdc8f92f12
gitee
chongzi/Lucky-ArkTs.git
84fc104d4a68def780a483e2543ebf9f53e793fd
entry/src/main/ets/component/FlipCard.ets
arkts
buildBackSide
构建卡片背面(答案解析)
@Builder private buildBackSide(): void { Column({ space: 16 }) { // 答案标题 Text('答案解析') .fontSize(16) .fontWeight(FontWeight.Medium) .fontColor('#1890ff') .textAlign(TextAlign.Center) // 答案内容(使用解析内容) // 解析内容 if (this.problem.explanation) { Column({ space: 8 }) { Text('详细解析:') .fontSize(12) .fontColor('#666666') .fontWeight(FontWeight.Medium) Text(this.problem.explanation) .fontSize(12) .fontColor('#666666') .textAlign(TextAlign.Start) .maxLines(6) .textOverflow({ overflow: TextOverflow.Ellipsis }) .lineHeight(18) } .alignItems(HorizontalAlign.Start) .width('100%') } // 翻转提示 Row({ space: 8 }) { Text('点击返回题目') .fontSize(12) .fontColor('#1890ff') } .justifyContent(FlexAlign.Center) } .width('100%') .height('100%') .padding(24) .justifyContent(FlexAlign.SpaceBetween) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right private buildBackSide AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#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 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 '#1890ff' AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 答案内容(使用解析内容) // 解析内容 AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . problem AST#member_expression#Right AST#expression#Right . explanation AST#member_expression#Right AST#expression#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 12 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#666666' AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . problem AST#member_expression#Right AST#expression#Right . explanation AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#666666' AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . maxLines ( AST#expression#Left 6 AST#expression#Right ) AST#modifier_chain_expression#Left . textOverflow ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left overflow AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left TextOverflow AST#expression#Right . Ellipsis AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . lineHeight ( AST#expression#Left 18 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 . 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 . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_control_flow#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 12 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#1890ff' 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 . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#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 24 AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceBetween AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder private buildBackSide(): void { Column({ space: 16 }) { Text('答案解析') .fontSize(16) .fontWeight(FontWeight.Medium) .fontColor('#1890ff') .textAlign(TextAlign.Center) if (this.problem.explanation) { Column({ space: 8 }) { Text('详细解析:') .fontSize(12) .fontColor('#666666') .fontWeight(FontWeight.Medium) Text(this.problem.explanation) .fontSize(12) .fontColor('#666666') .textAlign(TextAlign.Start) .maxLines(6) .textOverflow({ overflow: TextOverflow.Ellipsis }) .lineHeight(18) } .alignItems(HorizontalAlign.Start) .width('100%') } Row({ space: 8 }) { Text('点击返回题目') .fontSize(12) .fontColor('#1890ff') } .justifyContent(FlexAlign.Center) } .width('100%') .height('100%') .padding(24) .justifyContent(FlexAlign.SpaceBetween) }
https://github.com/chongzi/Lucky-ArkTs.git/blob/84fc104d4a68def780a483e2543ebf9f53e793fd/entry/src/main/ets/component/FlipCard.ets#L59-L103
3ff65ff9123d9e8d267957927d24da8018bcd5ec
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/crypto/SM3.ets
arkts
hmacSegment
消息认证码计算,分段,异步 @param data 传入的消息 @param symKey 共享对称密钥(SymKey)。 @param resultCoding 摘要的编码方式(base64/hex),默认不传为hex。 @param len 自定义的数据拆分长度
static async hmacSegment(data: string, symKey: cryptoFramework.SymKey = SM3.symKey, resultCoding: crypto.BhCoding = 'hex', len: number = 128): Promise<string> { return CryptoUtil.hmacSegment(data, 'SM3', symKey, resultCoding, len); }
AST#method_declaration#Left static async hmacSegment AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left symKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . SymKey AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left SM3 AST#expression#Right . symKey AST#member_expression#Right AST#expression#Right AST#parameter#Right , AST#parameter#Left resultCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left crypto . BhCoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'hex' AST#expression#Right AST#parameter#Right , AST#parameter#Left len : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 128 AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 . hmacSegment AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right , AST#expression#Left 'SM3' AST#expression#Right , AST#expression#Left symKey AST#expression#Right , AST#expression#Left resultCoding AST#expression#Right , AST#expression#Left len AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static async hmacSegment(data: string, symKey: cryptoFramework.SymKey = SM3.symKey, resultCoding: crypto.BhCoding = 'hex', len: number = 128): Promise<string> { return CryptoUtil.hmacSegment(data, 'SM3', symKey, resultCoding, len); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/crypto/SM3.ets#L104-L107
bcee0cd5026491f0b21cf56d27523d2721d70bfa
gitee
Active-hue/ArkTS-Accounting.git
c432916d305b407557f08e35017c3fd70668e441
entry/src/main/ets/pages/Settings.ets
arkts
SettingItemWithArrow
带箭头的设置项
@Builder SettingItemWithArrow(icon: string, title: string, subtitle: string) { Row() { Text(icon) .fontSize(24) .margin({ right: 12 }) Column() { Text(title) .fontSize(16) .fontColor('#333333') .margin({ bottom: 4 }) Text(subtitle) .fontSize(13) .fontColor('#999999') } .alignItems(HorizontalAlign.Start) .layoutWeight(1) Text('›') .fontSize(24) .fontColor('#CCCCCC') } .width('100%') .padding({ left: 20, right: 20, top: 16, bottom: 16 }) .onClick(() => { promptAction.showToast({ message: '功能开发中...', duration: 2000 }); }) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right SettingItemWithArrow AST#parameter_list#Left ( AST#parameter#Left icon : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left title : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left subtitle : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left icon AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right 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 title 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 . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 4 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left subtitle AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 13 AST#expression#Right ) AST#modifier_chain_expression#Left . 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 . 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 . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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 24 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#CCCCCC' 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 . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 20 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 20 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right } AST#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 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#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#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#builder_function_body#Right AST#method_declaration#Right
@Builder SettingItemWithArrow(icon: string, title: string, subtitle: string) { Row() { Text(icon) .fontSize(24) .margin({ right: 12 }) Column() { Text(title) .fontSize(16) .fontColor('#333333') .margin({ bottom: 4 }) Text(subtitle) .fontSize(13) .fontColor('#999999') } .alignItems(HorizontalAlign.Start) .layoutWeight(1) Text('›') .fontSize(24) .fontColor('#CCCCCC') } .width('100%') .padding({ left: 20, right: 20, top: 16, bottom: 16 }) .onClick(() => { promptAction.showToast({ message: '功能开发中...', duration: 2000 }); }) }
https://github.com/Active-hue/ArkTS-Accounting.git/blob/c432916d305b407557f08e35017c3fd70668e441/entry/src/main/ets/pages/Settings.ets#L243-L275
e052cb0291e07b7aab7c5a94aa3d7719cd01a2c6
github
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/ets/view/TabNode.ets
arkts
瀑布流子组件WrappedBuilder对象
export const flowItemWrapper: WrappedBuilder<ESObject> = wrapBuilder<ESObject>(flowItemBuilder);
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left flowItemWrapper : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left WrappedBuilder AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left ESObject 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 wrapBuilder AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left ESObject AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left flowItemBuilder AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
export const flowItemWrapper: WrappedBuilder<ESObject> = wrapBuilder<ESObject>(flowItemBuilder);
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/GlobalCustomComponentReuse/ComponentPrebuild/customreusablepool/src/main/ets/view/TabNode.ets#L24-L24
eb86d1efb19b8f3159f168e348f281bcff2c70db
gitee
liuchao0739/arkTS_universal_starter.git
0ca845f5ae0e78db439dc09f712d100c0dd46ed3
entry/src/main/ets/modules/web/WebViewManager.ets
arkts
openThirdPartyApp
打开第三方应用
async openThirdPartyApp(scheme: string): Promise<boolean> { try { Logger.info('WebViewManager', `Opening third party app: ${scheme}`); // 实际实现需要使用 @ohos.app.ability.common 的 startAbility return true; } catch (error) { Logger.error('WebViewManager', `Failed to open third party app: ${String(error)}`); return false; } }
AST#method_declaration#Left async openThirdPartyApp AST#parameter_list#Left ( AST#parameter#Left scheme : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#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 Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'WebViewManager' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Opening third party app: AST#template_substitution#Left $ { AST#expression#Left scheme 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 // 实际实现需要使用 @ohos.app.ability.common 的 startAbility AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'WebViewManager' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to open third party app: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left String AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async openThirdPartyApp(scheme: string): Promise<boolean> { try { Logger.info('WebViewManager', `Opening third party app: ${scheme}`); return true; } catch (error) { Logger.error('WebViewManager', `Failed to open third party app: ${String(error)}`); return false; } }
https://github.com/liuchao0739/arkTS_universal_starter.git/blob/0ca845f5ae0e78db439dc09f712d100c0dd46ed3/entry/src/main/ets/modules/web/WebViewManager.ets#L56-L65
bc28e55d244c359b32dc99e9cf9d8ee595209da4
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/SystemFeature/DeviceManagement/DeviceManagementCollection/feature/capabilities/src/main/ets/util/DeviceUtil.ets
arkts
buildTime
构建时间
static buildTime(): string { return deviceInfo.buildTime }
AST#method_declaration#Left static buildTime 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 . buildTime AST#member_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static buildTime(): string { return deviceInfo.buildTime }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/DeviceManagement/DeviceManagementCollection/feature/capabilities/src/main/ets/util/DeviceUtil.ets#L209-L211
420304cd58769e0f199655531540285329ef5287
gitee
openharmony/applications_settings
aac607310ec30e30d1d54db2e04d055655f72730
product/phone/src/main/ets/model/accessibilityImpl/ExtensionServiceManagementModel.ets
arkts
openExtensionServiceManagementStatusListener
listen extensionService status
openExtensionServiceManagementStatusListener() { try { config.on('enabledAccessibilityExtensionListChange', () => { LogUtil.info(`subscribe enabled accessibility extension list change state success`); this.setExtensionServiceManagementListener(); }); } catch (exception) { LogUtil.info(`failed to subscribe enabled accessibility extension list change state, because ${JSON.stringify(exception)}`); } }
AST#method_declaration#Left openExtensionServiceManagementStatusListener AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'enabledAccessibilityExtensionListChange' AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` subscribe enabled accessibility extension list change state success ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . setExtensionServiceManagementListener AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( exception ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` failed to subscribe enabled accessibility extension list change state, because 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 exception 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
openExtensionServiceManagementStatusListener() { try { config.on('enabledAccessibilityExtensionListChange', () => { LogUtil.info(`subscribe enabled accessibility extension list change state success`); this.setExtensionServiceManagementListener(); }); } catch (exception) { LogUtil.info(`failed to subscribe enabled accessibility extension list change state, because ${JSON.stringify(exception)}`); } }
https://github.com/openharmony/applications_settings/blob/aac607310ec30e30d1d54db2e04d055655f72730/product/phone/src/main/ets/model/accessibilityImpl/ExtensionServiceManagementModel.ets#L80-L89
a53b3aa2d492526f5a0f5be263e5bcfa9831fa8b
gitee
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
core/designsystem/src/main/ets/component/Column.ets
arkts
ColumnSpaceEvenlyEnd
纵向均分 + 水平末尾
@ComponentV2 export struct ColumnSpaceEvenlyEnd { /** * Column 构造参数 */ @Param options: ColumnOptions | ColumnOptionsV2 = {}; /** * 宽度 */ @Param widthValue: Length | undefined = undefined; /** * 高度 */ @Param heightValue: Length | undefined = undefined; /** * 尺寸(对应官方 size 属性) */ @Param sizeValue: SizeOptions | undefined = undefined; /** * 内边距 */ @Param paddingValue: Padding | Length | LocalizedPadding | undefined = undefined; /** * 外边距 */ @Param marginValue: Margin | Length | LocalizedMargin | undefined = undefined; /** * 是否填充最大宽高 */ @Param fillMaxSize: boolean = false; /** * 背景颜色 */ @Param bgColor: ResourceColor | undefined = undefined; /** * 点击事件 */ @Param onTap: ((event: ClickEvent) => void) | undefined = undefined; /** * 内容构建函数 */ @BuilderParam content: CustomBuilder; /** * 渲染布局 * @returns {void} 无返回值 * @example * ColumnSpaceEvenlyEnd() { Text("A"); Text("B"); Text("C"); } */ build(): void { ColumnBase({ options: this.options, justifyContent: FlexAlign.SpaceEvenly, alignItems: HorizontalAlign.End, 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#decorated_export_declaration#Left AST#decorator#Left @ ComponentV2 AST#decorator#Right export struct ColumnSpaceEvenlyEnd AST#component_body#Left { /** * Column 构造参数 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right options : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ColumnOptions AST#primary_type#Right | AST#primary_type#Left ColumnOptionsV2 AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right ; AST#property_declaration#Right /** * 宽度 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right widthValue : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Length AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right /** * 高度 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right heightValue : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Length 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 /** * 尺寸(对应官方 size 属性) */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right sizeValue : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left SizeOptions AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right /** * 内边距 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right paddingValue : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Padding AST#primary_type#Right | AST#primary_type#Left Length AST#primary_type#Right | AST#primary_type#Left LocalizedPadding AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right /** * 外边距 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right marginValue : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Margin AST#primary_type#Right | AST#primary_type#Left Length AST#primary_type#Right | AST#primary_type#Left LocalizedMargin AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right /** * 是否填充最大宽高 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right fillMaxSize : 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 @ Param AST#decorator#Right bgColor : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ResourceColor AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right /** * 点击事件 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right onTap : 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#Left event : AST#type_annotation#Left AST#primary_type#Left ClickEvent AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right ) AST#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 /** * 内容构建函数 */ AST#property_declaration#Left AST#decorator#Left @ BuilderParam AST#decorator#Right content : AST#type_annotation#Left AST#primary_type#Left CustomBuilder AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * 渲染布局 * @returns {void} 无返回值 * @example * ColumnSpaceEvenlyEnd() { Text("A"); Text("B"); Text("C"); } */ 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 . SpaceEvenly 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 . End 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 } AST#component_body#Right AST#decorated_export_declaration#Right
@ComponentV2 export struct ColumnSpaceEvenlyEnd { @Param options: ColumnOptions | ColumnOptionsV2 = {}; @Param widthValue: Length | undefined = undefined; @Param heightValue: Length | undefined = undefined; @Param sizeValue: SizeOptions | undefined = undefined; @Param paddingValue: Padding | Length | LocalizedPadding | undefined = undefined; @Param marginValue: Margin | Length | LocalizedMargin | undefined = undefined; @Param fillMaxSize: boolean = false; @Param bgColor: ResourceColor | undefined = undefined; @Param onTap: ((event: ClickEvent) => void) | undefined = undefined; @BuilderParam content: CustomBuilder; build(): void { ColumnBase({ options: this.options, justifyContent: FlexAlign.SpaceEvenly, alignItems: HorizontalAlign.End, 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#L1345-L1420
00f4afc767417156a6424c173d7cd477597ee5c7
github
pangpang20/wavecast.git
d3da8a0009eb44a576a2b9d9d9fe6195a2577e32
entry/src/main/ets/service/PlayerService.ets
arkts
updateSessionPlaybackState
更新 AVSession 播放状态
private async updateSessionPlaybackState(): Promise<void> { if (!this.session) { return; } try { let sessionState: avSession.PlaybackState = avSession.PlaybackState.PLAYBACK_STATE_STOP; switch (this.state) { case PlayerState.PLAYING: sessionState = avSession.PlaybackState.PLAYBACK_STATE_PLAY;
AST#method_declaration#Left private async updateSessionPlaybackState AST#parameter_list#Left ( ) AST#parameter_list#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right { AST#ERROR#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 . session 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 try { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left sessionState : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left avSession . PlaybackState AST#qualified_type#Right 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 avSession AST#expression#Right . PlaybackState AST#member_expression#Right AST#expression#Right . PLAYBACK_STATE_STOP 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 switch AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . state AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right { AST#property_name#Left case AST#property_name#Right Player State AST#ERROR#Right AST#modifier_chain_expression#Left . PLAYING AST#modifier_chain_expression#Right AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left sessionState AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left = avSession . Playback State . PLAYBACK_STATE_PLAY AST#ERROR#Right ; AST#method_declaration#Right
private async updateSessionPlaybackState(): Promise<void> { if (!this.session) { return; } try { let sessionState: avSession.PlaybackState = avSession.PlaybackState.PLAYBACK_STATE_STOP; switch (this.state) { case PlayerState.PLAYING: sessionState = avSession.PlaybackState.PLAYBACK_STATE_PLAY;
https://github.com/pangpang20/wavecast.git/blob/d3da8a0009eb44a576a2b9d9d9fe6195a2577e32/entry/src/main/ets/service/PlayerService.ets#L140-L149
4ba98c057bddd26a1104d8ca5100807e4949ef25
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_core/src/main/ets/core/util/PhoneUtil.ets
arkts
isTel400800
验证是否为座机号码(中国)+ 400 + 800 @param content 手机号码
static isTel400800(content: string): OutDTO<string> { if (content == null || content == '') { // 提供null的字符串为不匹配 return OutDTO.Error("验证号码不能为空"); } if (new RegExp(Const.TEL_400_800).test(content)) { return OutDTO.OK("号码为400800格式的座机") } else { return OutDTO.Error("号码非400800格式的座机,请检查") } }
AST#method_declaration#Left static isTel400800 AST#parameter_list#Left ( AST#parameter#Left content : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left OutDTO AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left content AST#expression#Right == AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left content AST#expression#Right == AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // 提供null的字符串为不匹配 AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left OutDTO AST#expression#Right . Error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "验证号码不能为空" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left RegExp AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . TEL_400_800 AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . test AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left content AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left OutDTO AST#expression#Right . OK AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "号码为400800格式的座机" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left OutDTO AST#expression#Right . Error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "号码非400800格式的座机,请检查" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static isTel400800(content: string): OutDTO<string> { if (content == null || content == '') { return OutDTO.Error("验证号码不能为空"); } if (new RegExp(Const.TEL_400_800).test(content)) { return OutDTO.OK("号码为400800格式的座机") } else { return OutDTO.Error("号码非400800格式的座机,请检查") } }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_core/src/main/ets/core/util/PhoneUtil.ets#L117-L127
016948dc80a4b459f3a3733a2bba6fcaa0548a63
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/sync/CloudSyncService.ets
arkts
uploadDataType
上传指定类型的数据
private async uploadDataType(dataType: DataType, options: SyncOptions): Promise<number> { let count = 0; switch (dataType) { case DataType.CONTACTS: const contacts = await this.contactService.searchContacts({ pageSize: 10000 }); for (const contact of contacts) { await this.uploadData(`contacts/${contact.id}`, contact); count++; } break; case DataType.GREETINGS: const greetings = await this.greetingService.searchGreetings({ pageSize: 10000 }); for (const greeting of greetings) { await this.uploadData(`greetings/${greeting.id}`, greeting); count++; } break; case DataType.SETTINGS: const settings = await this.settingsService.getSettings(); await this.uploadData('settings/user_settings', settings); count++; break; }
AST#method_declaration#Left private async uploadDataType AST#parameter_list#Left ( AST#parameter#Left dataType : AST#type_annotation#Left AST#primary_type#Left DataType AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left SyncOptions 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 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#ERROR#Left AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left count = AST#expression#Left 0 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 dataType 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 Data Type AST#modifier_chain_expression#Left . CONTACTS AST#modifier_chain_expression#Right : AST#ERROR#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left contacts = 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 . contactService AST#member_expression#Right AST#expression#Right . searchContacts 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 pageSize AST#property_name#Right : AST#expression#Left 10000 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( const contact of AST#expression#Left contacts AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . uploadData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` contacts/ AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left contact AST#expression#Right . id AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right , AST#expression#Left contact 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#update_expression#Left AST#expression#Left count AST#expression#Right ++ AST#update_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#break_statement#Left break ; AST#break_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DataType AST#expression#Right . GREETINGS AST#member_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left : AST#ERROR#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left greetings = 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 . greetingService AST#member_expression#Right AST#expression#Right . searchGreetings 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 pageSize AST#property_name#Right : AST#expression#Left 10000 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( const greeting of AST#expression#Left greetings AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . uploadData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` greetings/ AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left greeting AST#expression#Right . id AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right , AST#expression#Left greeting 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#update_expression#Left AST#expression#Left count AST#expression#Right ++ AST#update_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#break_statement#Left break ; AST#break_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DataType AST#expression#Right . SETTINGS AST#member_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left : AST#ERROR#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#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 . settingsService AST#member_expression#Right AST#expression#Right . getSettings AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#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 . uploadData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'settings/user_settings' AST#expression#Right , AST#expression#Left settings 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#update_expression#Left AST#expression#Left count AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#break_statement#Left break ; AST#break_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private async uploadDataType(dataType: DataType, options: SyncOptions): Promise<number> { let count = 0; switch (dataType) { case DataType.CONTACTS: const contacts = await this.contactService.searchContacts({ pageSize: 10000 }); for (const contact of contacts) { await this.uploadData(`contacts/${contact.id}`, contact); count++; } break; case DataType.GREETINGS: const greetings = await this.greetingService.searchGreetings({ pageSize: 10000 }); for (const greeting of greetings) { await this.uploadData(`greetings/${greeting.id}`, greeting); count++; } break; case DataType.SETTINGS: const settings = await this.settingsService.getSettings(); await this.uploadData('settings/user_settings', settings); count++; break; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/sync/CloudSyncService.ets#L300-L325
a2bb42982819186090a42355c9dfaadfecc9377f
github
bigbear20240612/planner_build-.git
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
entry/src/main/ets/viewmodel/LLMConfigManager.ets
arkts
getDefaultConfig
获取默认配置
getDefaultConfig(): LLMConfig | null { const defaultConfig = this.configs.find(config => config.isDefault); return defaultConfig || null; }
AST#method_declaration#Left getDefaultConfig AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left LLMConfig 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 defaultConfig = 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 . configs 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 config => AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . isDefault 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#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left defaultConfig 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
getDefaultConfig(): LLMConfig | null { const defaultConfig = this.configs.find(config => config.isDefault); return defaultConfig || null; }
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/viewmodel/LLMConfigManager.ets#L185-L188
aa417f5b65df4c3460b71f6847fccfba568dc071
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/videotrimmer/src/main/ets/videotrimmer/RangeSeekBarView.ets
arkts
touchInThumb
判断触碰事件有效
touchInThumb(event?: GestureEvent): boolean { if (this.touchInLeftThumb(event) || this.touchInRightThumb(event)) { return true; } else { return false; } }
AST#method_declaration#Left touchInThumb AST#parameter_list#Left ( AST#parameter#Left event ? : AST#type_annotation#Left AST#primary_type#Left GestureEvent AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . touchInLeftThumb AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left event AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . touchInRightThumb AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left event AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#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
touchInThumb(event?: GestureEvent): boolean { if (this.touchInLeftThumb(event) || this.touchInRightThumb(event)) { return true; } else { return false; } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/videotrimmer/src/main/ets/videotrimmer/RangeSeekBarView.ets#L432-L438
c7f4264aaa16121185ab8ec63f3e395175f92de7
gitee
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/charts/PieChartModel.ets
arkts
isDrawCenterTextEnabled
returns true if drawing the center text is enabled @return
public isDrawCenterTextEnabled(): boolean { return this.mDrawCenterText; }
AST#method_declaration#Left public isDrawCenterTextEnabled 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 . mDrawCenterText AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public isDrawCenterTextEnabled(): boolean { return this.mDrawCenterText; }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/charts/PieChartModel.ets#L512-L514
541e86f038dd5f45210cb407027eff497e1991fc
gitee
harmonyos/samples
f5d967efaa7666550ee3252d118c3c73a77686f5
HarmonyOS_NEXT/BackgroundTaskManagement/ResourceManager/entry/src/main/ets/pages/Index.ets
arkts
createTestResources
创建订阅者回调
function createTestResources(err: BusinessError, commonEventSubscriber: CommonEventManager.CommonEventSubscriber) { if(!err) { subscriber = commonEventSubscriber; try { CommonEventManager.subscribe(subscriber, JumpToResApiExample); } catch (error) { let code = (error as BusinessError).code; let message = (error as BusinessError).message; console.error(`subscribe failed, code is ${code}, message is ${message}`); } } else { console.error(`createSubscriber failed, code is ${err.code}, message is ${err.message}`); } }
AST#function_declaration#Left function createTestResources AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left commonEventSubscriber : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left CommonEventManager . CommonEventSubscriber AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left err AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left subscriber = AST#expression#Left commonEventSubscriber AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CommonEventManager AST#expression#Right . subscribe AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left subscriber AST#expression#Right , AST#expression#Left JumpToResApiExample AST#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 let AST#variable_declarator#Left code = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . code AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left message = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#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 ` subscribe failed, code is AST#template_substitution#Left $ { AST#expression#Left code AST#expression#Right } AST#template_substitution#Right , message is AST#template_substitution#Left $ { AST#expression#Left message AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#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 . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` createSubscriber failed, code is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , message is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
function createTestResources(err: BusinessError, commonEventSubscriber: CommonEventManager.CommonEventSubscriber) { if(!err) { subscriber = commonEventSubscriber; try { CommonEventManager.subscribe(subscriber, JumpToResApiExample); } catch (error) { let code = (error as BusinessError).code; let message = (error as BusinessError).message; console.error(`subscribe failed, code is ${code}, message is ${message}`); } } else { console.error(`createSubscriber failed, code is ${err.code}, message is ${err.message}`); } }
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/HarmonyOS_NEXT/BackgroundTaskManagement/ResourceManager/entry/src/main/ets/pages/Index.ets#L33-L46
5ed902d2ca0542c4b79584cd2da40385e3d80f0e
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/listexchange/src/main/ets/model/ListExchangeCtrl.ets
arkts
addItem
添加列表项 @param item: 列表项
addItem(item: T): void { this.deductionData.push(item); this.modifier.push(new ListItemModifier()); }
AST#method_declaration#Left addItem AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#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 . deductionData AST#member_expression#Right 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#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 . modifier 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 ListItemModifier AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
addItem(item: T): void { this.deductionData.push(item); this.modifier.push(new ListItemModifier()); }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/listexchange/src/main/ets/model/ListExchangeCtrl.ets#L207-L210
965952300ea2b4cd0ff9720f4ac4152f2e6a67ae
gitee
openharmony/multimedia_camera_framework
9873dd191f59efda885bc06897acf9b0660de8f2
frameworks/js/camera_napi/cameraAnimSample/entry/src/main/ets/common/utils/DateTimeUtil.ets
arkts
concatTime
时分秒格式修饰 @param hours @param minutes @param seconds
concatTime(hours: number, minutes: number, seconds: number): string { return `${this.fill(hours)}${this.fill(minutes)}${this.fill(seconds)}`; }
AST#method_declaration#Left concatTime AST#parameter_list#Left ( AST#parameter#Left hours : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left minutes : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left seconds : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . fill AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left hours AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . fill AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left minutes AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . fill AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left seconds 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
concatTime(hours: number, minutes: number, seconds: number): string { return `${this.fill(hours)}${this.fill(minutes)}${this.fill(seconds)}`; }
https://github.com/openharmony/multimedia_camera_framework/blob/9873dd191f59efda885bc06897acf9b0660de8f2/frameworks/js/camera_napi/cameraAnimSample/entry/src/main/ets/common/utils/DateTimeUtil.ets#L72-L74
bcd93db45c5acd37819f6be5c51168b5a14107aa
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/order/src/main/ets/component/OrderCard.ets
arkts
构建订单卡片 @returns {void} 无返回值
build(): void { Card({ onTap: (): void => this.toOrderDetail(this.order.id) }) { this.buildHeader(); this.buildGoodsPreview(); this.buildDivider(); this.buildActionBar(); } }
AST#build_method#Left build ( ) : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Card ( AST#component_parameters#Left { AST#component_parameter#Left onTap : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . toOrderDetail 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 . order AST#member_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buildHeader AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buildGoodsPreview AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buildDivider AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buildActionBar AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right
build(): void { Card({ onTap: (): void => this.toOrderDetail(this.order.id) }) { this.buildHeader(); this.buildGoodsPreview(); this.buildDivider(); this.buildActionBar(); } }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/order/src/main/ets/component/OrderCard.ets#L73-L82
af76ba240f9ec95dcd5312be4c0df63c6ca3552e
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/launch/src/main/ets/navigation/LaunchGraph.ets
arkts
register
注册启动模块导航路由
register(): void { RouteBuild.register(LaunchRoutes.Splash, wrapBuilder(SplashNav)); RouteBuild.register(LaunchRoutes.Guide, wrapBuilder(GuideNav)); }
AST#method_declaration#Left register 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 RouteBuild AST#expression#Right . register AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LaunchRoutes AST#expression#Right . Splash AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left wrapBuilder AST#expression#Right AST#argument_list#Left ( AST#expression#Left SplashNav AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left RouteBuild AST#expression#Right . register AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LaunchRoutes AST#expression#Right . Guide AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left wrapBuilder AST#expression#Right AST#argument_list#Left ( AST#expression#Left GuideNav AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
register(): void { RouteBuild.register(LaunchRoutes.Splash, wrapBuilder(SplashNav)); RouteBuild.register(LaunchRoutes.Guide, wrapBuilder(GuideNav)); }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/launch/src/main/ets/navigation/LaunchGraph.ets#L14-L17
c77d77d67154c82cfed953a1ca800028f35a4097
github
ThePivotPoint/ArkTS-LSP-Server-Plugin.git
6231773905435f000d00d94b26504433082ba40b
packages/declarations/ets/api/@ohos.arkui.advanced.ToolBar.d.ets
arkts
backgroundColor
Sets the backgroundColor of the toolBar. @param { ResourceColor } backgroundColor - toolBar's backgroundColor. @returns { ToolBarModifier } returns the instance of the ToolBarModifier. @syscap SystemCapability.ArkUI.ArkUI.Full @atomicservice @since 13
backgroundColor(backgroundColor: ResourceColor): ToolBarModifier;
AST#method_declaration#Left backgroundColor AST#parameter_list#Left ( AST#parameter#Left backgroundColor : AST#type_annotation#Left AST#primary_type#Left ResourceColor AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left ToolBarModifier AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right
backgroundColor(backgroundColor: ResourceColor): ToolBarModifier;
https://github.com/ThePivotPoint/ArkTS-LSP-Server-Plugin.git/blob/6231773905435f000d00d94b26504433082ba40b/packages/declarations/ets/api/@ohos.arkui.advanced.ToolBar.d.ets#L251-L251
b4d81a71e53ca190dd32b7a421a6cdef79139707
github
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
feature/demo/src/main/ets/view/ScreenAdaptDemoPage.ets
arkts
CardDesc
卡片说明样式 @param {Resource | string} text - 说明文本 @returns {void} 无返回值
@Builder private CardDesc(text: Resource | string): void { Text(text) .fontSize($r("app.float.body_medium")) .fontColor($r("app.color.text_subtitle")); }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right private CardDesc AST#parameter_list#Left ( AST#parameter#Left text : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Resource AST#primary_type#Right | AST#primary_type#Left string AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left text AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.float.body_medium" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.color.text_subtitle" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder private CardDesc(text: Resource | string): void { Text(text) .fontSize($r("app.float.body_medium")) .fontColor($r("app.color.text_subtitle")); }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/feature/demo/src/main/ets/view/ScreenAdaptDemoPage.ets#L289-L294
a2fbb01586ff487a54a9019daa8031239df393c5
github
Piagari/arkts_example.git
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
hmos_app-main/hmos_app-main/MoneyTrack-master/components/bill_base/src/main/ets/utils/ResourceUtil.ets
arkts
getResourceList
获取账单来源列表
public getResourceList() { if (!this._resource?.income?.length && !this._resource?.expense?.length) { this._createResourceMap(); return this._resource; } return this._resource; }
AST#method_declaration#Left public getResourceList AST#parameter_list#Left ( ) 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#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 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 . _resource AST#member_expression#Right AST#expression#Right ?. income AST#member_expression#Right AST#expression#Right ?. length AST#member_expression#Right AST#expression#Right && AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . _resource AST#member_expression#Right AST#expression#Right ?. expense AST#member_expression#Right AST#expression#Right ?. length AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _createResourceMap AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _resource 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#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _resource AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public getResourceList() { if (!this._resource?.income?.length && !this._resource?.expense?.length) { this._createResourceMap(); return this._resource; } return this._resource; }
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/MoneyTrack-master/components/bill_base/src/main/ets/utils/ResourceUtil.ets#L71-L77
0119ef415b3c575e7bd06ba139e07495c179172a
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/AuthUtil.ets
arkts
TODO 手机的生物认证(指纹、人脸、密码)工具类 需要权限 ohos.permission.ACCESS_BIOMETRIC author: 桃花镇童长老ᥫ᭡ since: 2024/05/01
export class AuthUtil { private static userAuthInstance: userAuth.UserAuthInstance; //认证对象 /** * 查询指定类型和等级的认证能力是否支持。 * @param authType * @param authTrustLevel * @returns */ static getAvailableStatus(authType: userAuth.UserAuthType, authTrustLevel: userAuth.AuthTrustLevel): StatusResult { try { userAuth.getAvailableStatus(authType, authTrustLevel); return { status: true }; } catch (err) { let error = err as BusinessError; LogUtil.error(`AuthUtil-getAvailableStatus-异常 ~ code: ${error.code} -·- message: ${error.message}`); return { status: false, errorCode: error.code, errorMsg: AuthUtil.getErrorMsg(error.code) }; } } /** * 开始认证,使用指纹和密码认证 * @param showTip 是否显示提示语 * @param callBack */ static onStartEasy(showTip: boolean = false, callBack: Callback<userAuth.UserAuthResult>) { const options: AuthOptions = new AuthOptions(); LogUtil.error(JSON.stringify(options, null, 2)); options.showTip = showTip; AuthUtil.onStart(options, callBack); } /** * 开始认证,用户指定类型认证 * @param options * @param callBack */ static onStart(options: AuthOptions, callBack: Callback<userAuth.UserAuthResult>) { try { if (options.challenge === undefined) { options.challenge = AuthUtil.generateChallenge(); //挑战值,用来防重放攻击。最大长度为32字节,可传Uint8Array([]) } if (options.authType === undefined || options.authType.length <= 0) { options.authType = [userAuth.UserAuthType.FINGERPRINT, userAuth.UserAuthType.FACE, userAuth.UserAuthType.PIN]; //认证类型列表,用来指定用户认证界面提供的认证方法。 } if (options.authTrustLevel === undefined) { options.authTrustLevel = userAuth.AuthTrustLevel.ATL3; //认证信任等级。 } if (options.title === undefined) { options.title = '请验证身份'; //用户认证界面的标题,最大长度为500字符。 } if (options.showTip === undefined) { options.showTip = false; //默认不显示提示语 } const authParam: userAuth.AuthParam = { challenge: options.challenge, authType: options.authType, authTrustLevel: options.authTrustLevel, }; if (options.navigationButtonText) { AuthUtil.userAuthInstance = userAuth.getUserAuthInstance(authParam, { title: options.title, navigationButtonText: options.navigationButtonText }); } else { AuthUtil.userAuthInstance = userAuth.getUserAuthInstance(authParam, { title: options.title }); } AuthUtil.userAuthInstance.on('result', { onResult(result) { callBack?.(result); if (userAuth.UserAuthResultCode.SUCCESS === result.result && options.showTip) { const errorTip = AuthUtil.getErrorMsg(result.result, ''); if (StrUtil.isNotEmpty(errorTip)) { ToastUtil.showToast(errorTip); } } } }); AuthUtil.userAuthInstance.start(); //开始认证 } catch (err) { let error = err as BusinessError; LogUtil.error(`AuthUtil-onStart-异常 ~ code: ${error.code} -·- message: ${error.message}`); if (options.showTip) { ToastUtil.showToast(AuthUtil.getErrorMsg(error.code, '认证失败:' + error.message)); } } } /** * 取消认证 */ static cancel() { try { if (AuthUtil.userAuthInstance) { AuthUtil.userAuthInstance.cancel(); //取消认证 AuthUtil.userAuthInstance.off('result'); //取消订阅用户身份认证结果 } } catch (err) { let error = err as BusinessError; LogUtil.error(`AuthUtil-cancel-异常 ~ code: ${error.code} -·- message: ${error.message}`); } } /** * 生成挑战值,用来防重放攻击。 * @param len 最大长度为32 * @returns */ static generateChallenge(len: number = 16) { const rand = cryptoFramework.createRandom(); const randData: Uint8Array = rand.generateRandomSync((len > 0 && len <= 32) ? len : 16).data; return randData; } /** * 获取错误msg * @param code * @param defaultMsg */ static getErrorMsg(code: number, defaultMsg: string = ''): string { if (201 == code) { return '权限校验失败!' } else if (202 == code) { return '系统API权限校验失败!' } else if (401 == code) { return '参数检查失败!' } else if (801 == code) { return '该设备不支持此API!' } else if (12500001 == code) { return '认证失败!' } else if (12500002 == code) { return '一般的操作错误!' } else if (12500003 == code) { return '认证被取消!' } else if (12500004 == code) { return '认证操作超时!' } else if (12500005 == code) { return '认证类型不支持!' } else if (12500006 == code) { return '认证信任等级不支持!' } else if (12500007 == code) { return '认证服务已经繁忙!' } else if (12500009 == code) { return '认证被锁定!' } else if (12500010 == code) { return '该类型的凭据没有录入!' } else if (12500011 == code) { return '认证被控件取消!' } else if (12700001 == code) { return '人脸录入过程中的操作失败!' } else { return defaultMsg } } }
AST#export_declaration#Left export AST#class_declaration#Left class AuthUtil AST#class_body#Left { AST#property_declaration#Left private static userAuthInstance : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left userAuth . UserAuthInstance AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right //认证对象 /** * 查询指定类型和等级的认证能力是否支持。 * @param authType * @param authTrustLevel * @returns */ AST#method_declaration#Left static getAvailableStatus AST#parameter_list#Left ( AST#parameter#Left authType : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left userAuth . UserAuthType AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left authTrustLevel : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left userAuth . AuthTrustLevel 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 StatusResult 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 userAuth AST#expression#Right . getAvailableStatus AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left authType AST#expression#Right , AST#expression#Left authTrustLevel AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left status AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left error = 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` AuthUtil-getAvailableStatus-异常 ~ code: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right -·- message: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left status 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 errorCode AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . code AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left errorMsg AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AuthUtil AST#expression#Right . getErrorMsg AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . code 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#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 showTip 是否显示提示语 * @param callBack */ AST#method_declaration#Left static onStartEasy AST#parameter_list#Left ( AST#parameter#Left showTip : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#parameter#Right , AST#parameter#Left callBack : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left userAuth . UserAuthResult AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left options : AST#type_annotation#Left AST#primary_type#Left AuthOptions 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 AuthOptions AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil 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 JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left options AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right , AST#expression#Left 2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#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 options AST#expression#Right . showTip AST#member_expression#Right = AST#expression#Left showTip 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 AuthUtil AST#expression#Right . onStart AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left options 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 /** * 开始认证,用户指定类型认证 * @param options * @param callBack */ AST#method_declaration#Left static onStart AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left AuthOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left callBack : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left userAuth . UserAuthResult AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . challenge AST#member_expression#Right AST#expression#Right === AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . challenge AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AuthUtil AST#expression#Right . generateChallenge 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 //挑战值,用来防重放攻击。最大长度为32字节,可传Uint8Array([]) } 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 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 options AST#expression#Right . authType AST#member_expression#Right AST#expression#Right === AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left options AST#expression#Right AST#binary_expression#Right AST#expression#Right . authType AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right <= AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . authType AST#member_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 userAuth AST#expression#Right . UserAuthType AST#member_expression#Right AST#expression#Right . FINGERPRINT AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left userAuth AST#expression#Right . UserAuthType AST#member_expression#Right AST#expression#Right . FACE AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left userAuth AST#expression#Right . UserAuthType AST#member_expression#Right AST#expression#Right . PIN AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //认证类型列表,用来指定用户认证界面提供的认证方法。 } AST#block_statement#Right AST#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 options AST#expression#Right . authTrustLevel AST#member_expression#Right AST#expression#Right === AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . authTrustLevel AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left userAuth AST#expression#Right . AuthTrustLevel AST#member_expression#Right AST#expression#Right . ATL3 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 AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . title AST#member_expression#Right AST#expression#Right === AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . title AST#member_expression#Right = AST#expression#Left '请验证身份' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //用户认证界面的标题,最大长度为500字符。 } 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 options AST#expression#Right . showTip AST#member_expression#Right AST#expression#Right === AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . showTip AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //默认不显示提示语 } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left authParam : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left userAuth . AuthParam 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 challenge AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . challenge AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left authType AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . authType AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left authTrustLevel AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . authTrustLevel AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . navigationButtonText 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 AuthUtil AST#expression#Right . userAuthInstance AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left userAuth AST#expression#Right . getUserAuthInstance AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left authParam AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . title AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left navigationButtonText AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . navigationButtonText 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#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 AuthUtil AST#expression#Right . userAuthInstance AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left userAuth AST#expression#Right . getUserAuthInstance AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left authParam AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . title 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#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 AuthUtil AST#expression#Right . userAuthInstance AST#member_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'result' AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left onResult AST#property_name#Right AST#parameter_list#Left ( AST#parameter#Left result AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left callBack AST#expression#Right ?. AST#argument_list#Left ( AST#expression#Left result AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left userAuth AST#expression#Right . UserAuthResultCode AST#member_expression#Right AST#expression#Right . SUCCESS AST#member_expression#Right AST#expression#Right === AST#expression#Left result AST#expression#Right AST#binary_expression#Right AST#expression#Right . result AST#member_expression#Right AST#expression#Right && AST#expression#Left options AST#expression#Right AST#binary_expression#Right AST#expression#Right . showTip AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left errorTip = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AuthUtil AST#expression#Right . getErrorMsg AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . result 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#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 StrUtil AST#expression#Right . isNotEmpty AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left errorTip 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 ToastUtil AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left errorTip AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#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 AST#member_expression#Left AST#expression#Left AuthUtil AST#expression#Right . userAuthInstance AST#member_expression#Right AST#expression#Right . start AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //开始认证 } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left error = 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` AuthUtil-onStart-异常 ~ code: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right -·- message: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error 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#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . showTip 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 ToastUtil AST#expression#Right . showToast 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 AuthUtil AST#expression#Right . getErrorMsg AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . code AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '认证失败:' AST#expression#Right + AST#expression#Left error AST#expression#Right AST#binary_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 取消认证 */ AST#method_declaration#Left static cancel 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#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AuthUtil AST#expression#Right . userAuthInstance AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AuthUtil AST#expression#Right . userAuthInstance AST#member_expression#Right AST#expression#Right . cancel AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //取消认证 AST#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 AuthUtil AST#expression#Right . userAuthInstance AST#member_expression#Right AST#expression#Right . off 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_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#variable_declaration#Left let AST#variable_declarator#Left error = 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` AuthUtil-cancel-异常 ~ code: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right -·- message: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error 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 /** * 生成挑战值,用来防重放攻击。 * @param len 最大长度为32 * @returns */ AST#method_declaration#Left static generateChallenge AST#parameter_list#Left ( AST#parameter#Left len : 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#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left rand = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createRandom 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 randData : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left rand AST#expression#Right . generateRandomSync AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right AST#ERROR#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 len AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left len AST#expression#Right <= AST#expression#Left 32 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#member_expression#Left AST#expression#Left len AST#expression#Right AST#ERROR#Left : 16 ) AST#ERROR#Right . data AST#member_expression#Right AST#expression#Right AST#ERROR#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left randData AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取错误msg * @param code * @param defaultMsg */ AST#method_declaration#Left static getErrorMsg AST#parameter_list#Left ( AST#parameter#Left code : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left defaultMsg : 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#binary_expression#Left AST#expression#Left 201 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 202 AST#expression#Right == AST#expression#Left code 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 '系统API权限校验失败!' AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 401 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 801 AST#expression#Right == AST#expression#Left code 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 '该设备不支持此API!' AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 12500001 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 12500002 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 12500003 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 12500004 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 12500005 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 12500006 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 12500007 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 12500009 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 12500010 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 12500011 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 12700001 AST#expression#Right == AST#expression#Left code 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#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 defaultMsg 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#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class AuthUtil { private static userAuthInstance: userAuth.UserAuthInstance; static getAvailableStatus(authType: userAuth.UserAuthType, authTrustLevel: userAuth.AuthTrustLevel): StatusResult { try { userAuth.getAvailableStatus(authType, authTrustLevel); return { status: true }; } catch (err) { let error = err as BusinessError; LogUtil.error(`AuthUtil-getAvailableStatus-异常 ~ code: ${error.code} -·- message: ${error.message}`); return { status: false, errorCode: error.code, errorMsg: AuthUtil.getErrorMsg(error.code) }; } } static onStartEasy(showTip: boolean = false, callBack: Callback<userAuth.UserAuthResult>) { const options: AuthOptions = new AuthOptions(); LogUtil.error(JSON.stringify(options, null, 2)); options.showTip = showTip; AuthUtil.onStart(options, callBack); } static onStart(options: AuthOptions, callBack: Callback<userAuth.UserAuthResult>) { try { if (options.challenge === undefined) { options.challenge = AuthUtil.generateChallenge(); } if (options.authType === undefined || options.authType.length <= 0) { options.authType = [userAuth.UserAuthType.FINGERPRINT, userAuth.UserAuthType.FACE, userAuth.UserAuthType.PIN]; } if (options.authTrustLevel === undefined) { options.authTrustLevel = userAuth.AuthTrustLevel.ATL3; } if (options.title === undefined) { options.title = '请验证身份'; } if (options.showTip === undefined) { options.showTip = false; } const authParam: userAuth.AuthParam = { challenge: options.challenge, authType: options.authType, authTrustLevel: options.authTrustLevel, }; if (options.navigationButtonText) { AuthUtil.userAuthInstance = userAuth.getUserAuthInstance(authParam, { title: options.title, navigationButtonText: options.navigationButtonText }); } else { AuthUtil.userAuthInstance = userAuth.getUserAuthInstance(authParam, { title: options.title }); } AuthUtil.userAuthInstance.on('result', { onResult(result) { callBack?.(result); if (userAuth.UserAuthResultCode.SUCCESS === result.result && options.showTip) { const errorTip = AuthUtil.getErrorMsg(result.result, ''); if (StrUtil.isNotEmpty(errorTip)) { ToastUtil.showToast(errorTip); } } } }); AuthUtil.userAuthInstance.start(); } catch (err) { let error = err as BusinessError; LogUtil.error(`AuthUtil-onStart-异常 ~ code: ${error.code} -·- message: ${error.message}`); if (options.showTip) { ToastUtil.showToast(AuthUtil.getErrorMsg(error.code, '认证失败:' + error.message)); } } } static cancel() { try { if (AuthUtil.userAuthInstance) { AuthUtil.userAuthInstance.cancel(); AuthUtil.userAuthInstance.off('result'); } } catch (err) { let error = err as BusinessError; LogUtil.error(`AuthUtil-cancel-异常 ~ code: ${error.code} -·- message: ${error.message}`); } } static generateChallenge(len: number = 16) { const rand = cryptoFramework.createRandom(); const randData: Uint8Array = rand.generateRandomSync((len > 0 && len <= 32) ? len : 16).data; return randData; } static getErrorMsg(code: number, defaultMsg: string = ''): string { if (201 == code) { return '权限校验失败!' } else if (202 == code) { return '系统API权限校验失败!' } else if (401 == code) { return '参数检查失败!' } else if (801 == code) { return '该设备不支持此API!' } else if (12500001 == code) { return '认证失败!' } else if (12500002 == code) { return '一般的操作错误!' } else if (12500003 == code) { return '认证被取消!' } else if (12500004 == code) { return '认证操作超时!' } else if (12500005 == code) { return '认证类型不支持!' } else if (12500006 == code) { return '认证信任等级不支持!' } else if (12500007 == code) { return '认证服务已经繁忙!' } else if (12500009 == code) { return '认证被锁定!' } else if (12500010 == code) { return '该类型的凭据没有录入!' } else if (12500011 == code) { return '认证被控件取消!' } else if (12700001 == code) { return '人脸录入过程中的操作失败!' } else { return defaultMsg } } }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/AuthUtil.ets#L31-L191
38ddca81734ad6eb14a6bf4849b35f9080b0a293
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/RandomUtil.ets
arkts
TODO 随机工具类 author: 桃花镇童长老ᥫ᭡ since: 2024/05/01
export class RandomUtil { /** * 生成随机Boolean值 * @return true or false */ static getRandomBoolean(): boolean { return Math.random() >= 0.5; } /** * 生成随机整数(可指定范围) * @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; } /** * 生成指定范围内的随机数 * @return 随机数 */ static getRandomNumber(min: number, max: number): number { return Math.floor(Math.random() * (max - min) + min); } /** * 生成指定范围内的随机数 [0,limit) * @param limit 限制随机数的范围,不包括这个数 * @return 随机数 */ static getRandomLimit(limit: number): number { return Math.floor(Math.random() * limit); } /** * 生成一个随机汉字('\u4E00'-'\u9FFF') * @return 随机的汉字字符 */ static getRandomChineseChar(): string { const start = 0x4E00; //汉字起始Unicode编码,'\u4E00' const end = 0x9FFF; //汉字结束Unicode编码,'\u9FFF' const randomCode = start + Math.floor(Math.random() * (end - start + 1)); //生成一个随机码点 return String.fromCharCode(randomCode); //将随机码点转换为对应的汉字字符 } /** * 生成随机汉字 * @param length 目标长度 * @return 随机的汉字字符串 */ static getRandomChinese(length: number): string { length = Math.floor(length); let chineseArray = new Array<string>(length); for (let i = 0; i < length; i++) { chineseArray[i] = RandomUtil.getRandomChineseChar(); }
AST#export_declaration#Left export AST#class_declaration#Left class RandomUtil AST#class_body#Left { /** * 生成随机Boolean值 * @return true or false */ AST#method_declaration#Left static getRandomBoolean AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#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 0.5 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 /** * 生成随机整数(可指定范围) * @return 随机数 */ 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 /** * 生成指定范围内的随机数 * @return 随机数 */ AST#method_declaration#Left static getRandomNumber 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#parameter#Right , AST#parameter#Left max : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#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#expression#Left min AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 生成指定范围内的随机数 [0,limit) * @param limit 限制随机数的范围,不包括这个数 * @return 随机数 */ AST#method_declaration#Left static getRandomLimit AST#parameter_list#Left ( AST#parameter#Left limit : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#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 limit AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 生成一个随机汉字('\u4E00'-'\u9FFF') * @return 随机的汉字字符 */ AST#method_declaration#Left static getRandomChineseChar AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left start = AST#expression#Left 0x4E00 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //汉字起始Unicode编码,'\u4E00' AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left end = AST#expression#Left 0x9FFF AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //汉字结束Unicode编码,'\u9FFF' AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left randomCode = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left start AST#expression#Right + AST#expression#Left Math AST#expression#Right AST#binary_expression#Right 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 AST#binary_expression#Left AST#expression#Left end AST#expression#Right - AST#expression#Left start AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_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 String AST#expression#Right . fromCharCode AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left randomCode 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 length 目标长度 * @return 随机的汉字字符串 */ AST#property_declaration#Left static getRandomChinese AST#ERROR#Left AST#parameter_list#Left ( AST#parameter#Left length : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left length = 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 length 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 chineseArray = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left length 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 for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left length AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) { AST#expression#Left AST#subscript_expression#Left AST#expression#Left chineseArray AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left RandomUtil AST#expression#Right . getRandomChineseChar 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#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class RandomUtil { static getRandomBoolean(): boolean { return Math.random() >= 0.5; } 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; } static getRandomNumber(min: number, max: number): number { return Math.floor(Math.random() * (max - min) + min); } static getRandomLimit(limit: number): number { return Math.floor(Math.random() * limit); } static getRandomChineseChar(): string { const start = 0x4E00; const end = 0x9FFF; const randomCode = start + Math.floor(Math.random() * (end - start + 1)); return String.fromCharCode(randomCode); } static getRandomChinese(length: number): string { length = Math.floor(length); let chineseArray = new Array<string>(length); for (let i = 0; i < length; i++) { chineseArray[i] = RandomUtil.getRandomChineseChar(); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/RandomUtil.ets#L24-L85
3f43108f0145a6a1003ff1b0b29589f01a4f4f45
gitee
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
ETSUI/FlexLayout/entry/src/main/ets/viewmodel/SearchViewModel.ets
arkts
getSearchArrData
Get search arr data.
getSearchArrData() { let listItems: Array<string> = [ 'Text', 'Button', 'TextField', 'Image', 'Switch', 'Checkbox', 'RadioButton', 'ProgressBar', 'ScrollView' ]; return listItems; }
AST#method_declaration#Left getSearchArrData AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left listItems : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'Text' AST#expression#Right , AST#expression#Left 'Button' AST#expression#Right , AST#expression#Left 'TextField' AST#expression#Right , AST#expression#Left 'Image' AST#expression#Right , AST#expression#Left 'Switch' AST#expression#Right , AST#expression#Left 'Checkbox' AST#expression#Right , AST#expression#Left 'RadioButton' AST#expression#Right , AST#expression#Left 'ProgressBar' AST#expression#Right , AST#expression#Left 'ScrollView' 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 listItems AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
getSearchArrData() { let listItems: Array<string> = [ 'Text', 'Button', 'TextField', 'Image', 'Switch', 'Checkbox', 'RadioButton', 'ProgressBar', 'ScrollView' ]; return listItems; }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/ETSUI/FlexLayout/entry/src/main/ets/viewmodel/SearchViewModel.ets#L23-L30
3890393f0b849ff967245d5cd567e68b1a496175
gitee
ashcha0/line-inspection-terminal-frontend_arkts.git
c82616097e8a3b257b7b01e75b6b83ce428b518c
entry/src/main/ets/pages/TaskReviewView.ets
arkts
closeFlawDetail
关闭故障详情
closeFlawDetail() { this.flawDetailDialogController.close(); this.selectedFlaw = null; }
AST#method_declaration#Left closeFlawDetail AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . flawDetailDialogController 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedFlaw 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#builder_function_body#Right AST#method_declaration#Right
closeFlawDetail() { this.flawDetailDialogController.close(); this.selectedFlaw = null; }
https://github.com/ashcha0/line-inspection-terminal-frontend_arkts.git/blob/c82616097e8a3b257b7b01e75b6b83ce428b518c/entry/src/main/ets/pages/TaskReviewView.ets#L270-L273
7bb47555e92cac44bf5a4a53be9260285416e862
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/database/src/main/ets/datasource/cart/CartLocalDataSourceImpl.ets
arkts
findEntityByGoodsId
根据商品ID查询实体 @param {number} goodsId 商品ID @returns {CartEntity | undefined} 匹配实体
private findEntityByGoodsId(goodsId: number): CartEntity | undefined { const result: CartEntity[] = this.orm.query(CartEntity).where("goodsId", goodsId).find(); return result[0]; }
AST#method_declaration#Left private findEntityByGoodsId AST#parameter_list#Left ( AST#parameter#Left goodsId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left CartEntity 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#variable_declaration#Left const AST#variable_declarator#Left result : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left CartEntity [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#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 . orm AST#member_expression#Right AST#expression#Right . query AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left CartEntity AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . where AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "goodsId" AST#expression#Right , AST#expression#Left goodsId AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . find 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#subscript_expression#Left AST#expression#Left result 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
private findEntityByGoodsId(goodsId: number): CartEntity | undefined { const result: CartEntity[] = this.orm.query(CartEntity).where("goodsId", goodsId).find(); return result[0]; }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/database/src/main/ets/datasource/cart/CartLocalDataSourceImpl.ets#L156-L159
8f1b507997e5127262b73cbb66ad287a098af9a7
github
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
ComponentReuse/entry/src/main/ets/view/UpdaterComponent.ets
arkts
OneMomentNoModifier
[EndExclude opt_updater]
@Reusable @Component export struct OneMomentNoModifier { @State text: string = ''; color: string | number | Resource | Color = ''; textUpdater: MyTextUpdater | null = null; aboutToAppear(): void { this.textUpdater = new MyTextUpdater(this.color); } aboutToReuse(params: Record<string, Object>): void { this.color = params.color as string; this.text = params.text as string; this.textUpdater?.attribute?.fontColor(this.color); } build() { Column() { Text(this.text) .fontSize(18) .textAlign(TextAlign.Center) .fontWeight(500) .lineHeight(24) .fontColor(Color.Black) .opacity(0.6) Column() { Text('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA') .attributeModifier(this.textUpdater) // Precise refresh .textAlign(TextAlign.Start) .fontSize(16) .fontWeight(400) .lineHeight(21) } // [StartExclude opt_updater] .borderRadius(16) .margin({ top: 14 }) .padding({ left: 16, right: 16, top: 8, bottom: 8 }) .backgroundColor('#0D000000') // [EndExclude opt_updater] } // [StartExclude opt_updater] .alignItems(HorizontalAlign.Start) .margin({ left: 16, right: 16 }) // [EndExclude opt_updater] } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Reusable AST#decorator#Right AST#decorator#Left @ Component AST#decorator#Right export struct OneMomentNoModifier AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right text : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left color : 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 Resource AST#primary_type#Right | AST#primary_type#Left Color AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left textUpdater : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left MyTextUpdater AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . textUpdater AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left MyTextUpdater 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 . color AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left aboutToReuse AST#parameter_list#Left ( AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#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 . color AST#member_expression#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . color AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#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 . text AST#member_expression#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . text AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . textUpdater AST#member_expression#Right AST#expression#Right ?. attribute AST#member_expression#Right AST#expression#Right ?. fontColor 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 . color AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#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#member_expression#Left AST#expression#Left this AST#expression#Right . text AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 18 AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left 500 AST#expression#Right ) AST#modifier_chain_expression#Left . lineHeight ( 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 . Black AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left 0.6 AST#expression#Right ) AST#modifier_chain_expression#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 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 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . attributeModifier ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . textUpdater AST#member_expression#Right AST#expression#Right ) // Precise refresh 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 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left 400 AST#expression#Right ) AST#modifier_chain_expression#Left . lineHeight ( AST#expression#Left 21 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 // [StartExclude opt_updater] AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 16 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 14 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 8 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 8 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#0D000000' 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 // [EndExclude opt_updater] } AST#container_content_body#Right AST#ui_component#Right // [StartExclude opt_updater] 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 . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right } AST#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 // [EndExclude opt_updater] } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Reusable @Component export struct OneMomentNoModifier { @State text: string = ''; color: string | number | Resource | Color = ''; textUpdater: MyTextUpdater | null = null; aboutToAppear(): void { this.textUpdater = new MyTextUpdater(this.color); } aboutToReuse(params: Record<string, Object>): void { this.color = params.color as string; this.text = params.text as string; this.textUpdater?.attribute?.fontColor(this.color); } build() { Column() { Text(this.text) .fontSize(18) .textAlign(TextAlign.Center) .fontWeight(500) .lineHeight(24) .fontColor(Color.Black) .opacity(0.6) Column() { Text('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA') .attributeModifier(this.textUpdater) .textAlign(TextAlign.Start) .fontSize(16) .fontWeight(400) .lineHeight(21) } .borderRadius(16) .margin({ top: 14 }) .padding({ left: 16, right: 16, top: 8, bottom: 8 }) .backgroundColor('#0D000000') } .alignItems(HorizontalAlign.Start) .margin({ left: 16, right: 16 }) } }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ComponentReuse/entry/src/main/ets/view/UpdaterComponent.ets#L71-L125
bd74297cf160c822f570043d8d5d8bc50cb1b66c
gitee
awa_Liny/LinysBrowser_NEXT
a5cd96a9aa8114cae4972937f94a8967e55d4a10
home/src/main/ets/utils/ui_tools.ets
arkts
Infers the id of window. @param w The windowClass (window.Window).
export function window_id_of_windowClass(w: window.Window) { let windowIds = AppStorage.get('windowIds') as string[]; let window_id = windowIds[window_index_of_windowClass(w)]; return window_id; }
AST#export_declaration#Left export AST#function_declaration#Left function window_id_of_windowClass AST#parameter_list#Left ( AST#parameter#Left w : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left windowIds = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'windowIds' 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 window_id = AST#expression#Left AST#subscript_expression#Left AST#expression#Left windowIds AST#expression#Right [ AST#expression#Left AST#call_expression#Left AST#expression#Left window_index_of_windowClass AST#expression#Right AST#argument_list#Left ( AST#expression#Left w AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left window_id AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function window_id_of_windowClass(w: window.Window) { let windowIds = AppStorage.get('windowIds') as string[]; let window_id = windowIds[window_index_of_windowClass(w)]; return window_id; }
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/utils/ui_tools.ets#L512-L516
96acb0e32e0c723411a2f9818be95a3fc8f122f1
gitee
wangjinyuan/JS-TS-ArkTS-database.git
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
npm/alprazolamdiv/11.5.1/package/src/client/websocket/packets/handlers/MessageReactionRemove.ets
arkts
应用约束60:使用export default代替module.exports
export default MessageReactionRemove;
AST#export_declaration#Left export default AST#expression#Left MessageReactionRemove AST#expression#Right ; AST#export_declaration#Right
export default MessageReactionRemove;
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/client/websocket/packets/handlers/MessageReactionRemove.ets#L19-L19
6c69b455985127be955812847c9881283e045234
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/dbUtils/DBAccessor.ets
arkts
isExistWithSql
检查查询结果是否存在记录 @param sql - 存在性查询语句(如:"SELECT 1 FROM users WHERE id = ?") @param params - 查询参数(可选) @returns Promise<boolean> 返回是否存在记录
async isExistWithSql(sql: string, params: ParamType[] = []): Promise<boolean> { if (!await this.initDatabase()) return false; try { const resultSet = await this.rdbStore!.querySql(sql, params); DebugLog.d(sql +' 参数: ' + params) // 只需检查是否有第一条记录 const exists = resultSet.goToNextRow(); resultSet.close(); return exists; } catch (err) { console.error(`DBAccessor: 存在性查询失败 [${sql}] - ${err}`); return false; } finally { this.closeDatabase(); // 确保关闭连接 } }
AST#method_declaration#Left async isExistWithSql AST#parameter_list#Left ( AST#parameter#Left sql : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ParamType [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right AST#unary_expression#Right AST#expression#Right . initDatabase 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#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#try_statement#Left try AST#block_statement#Left { 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#non_null_assertion_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 ! AST#non_null_assertion_expression#Right AST#expression#Right . querySql AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sql AST#expression#Right , AST#expression#Left params 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 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 AST#binary_expression#Left AST#expression#Left sql AST#expression#Right + AST#expression#Left ' 参数: ' AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left params AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // 只需检查是否有第一条记录 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left exists = 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#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 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 exists 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 ` DBAccessor: 存在性查询失败 [ AST#template_substitution#Left $ { AST#expression#Left sql AST#expression#Right } AST#template_substitution#Right ] - 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 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#finally_clause#Left finally AST#block_statement#Left { 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 . closeDatabase 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#finally_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async isExistWithSql(sql: string, params: ParamType[] = []): Promise<boolean> { if (!await this.initDatabase()) return false; try { const resultSet = await this.rdbStore!.querySql(sql, params); DebugLog.d(sql +' 参数: ' + params) const exists = resultSet.goToNextRow(); resultSet.close(); return exists; } catch (err) { console.error(`DBAccessor: 存在性查询失败 [${sql}] - ${err}`); return false; } finally { this.closeDatabase(); } }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/dbUtils/DBAccessor.ets#L315-L332
8e992b2cf11bb14b0b8fb4dc19e026f95d8e4cf2
github
lime-zz/Ark-ui_RubbishRecycleApp.git
c2a9bff8fbb5bc46d922934afad0327cc1696969
rubbish/rubbish/entry/src/main/ets/pages/rephone.ets
arkts
aboutToAppear
页面加载时获取用户数据
aboutToAppear() { this.getUserData(); }
AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getUserData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
aboutToAppear() { this.getUserData(); }
https://github.com/lime-zz/Ark-ui_RubbishRecycleApp.git/blob/c2a9bff8fbb5bc46d922934afad0327cc1696969/rubbish/rubbish/entry/src/main/ets/pages/rephone.ets#L40-L42
aa4d8e1194821db8cf919ac3b035a648ef613cec
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/common/types/GreetingTypes.ets
arkts
AI提供商扩展配置
export interface AIProviderExtendedConfig { provider: AIProvider; displayName: string; supportedModels: string[]; defaultModel: string; requiresApiKey: boolean; apiKeyFormat: string; supportsStreaming: boolean; maxTokensLimit: number; pricingInfo?: PricingInfo; }
AST#export_declaration#Left export AST#interface_declaration#Left interface AIProviderExtendedConfig AST#object_type#Left { AST#type_member#Left provider : AST#type_annotation#Left AST#primary_type#Left AIProvider AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left displayName : 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 supportedModels : 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 defaultModel : 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 requiresApiKey : 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 apiKeyFormat : 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 supportsStreaming : 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 maxTokensLimit : 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 pricingInfo ? : AST#type_annotation#Left AST#primary_type#Left PricingInfo 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 AIProviderExtendedConfig { provider: AIProvider; displayName: string; supportedModels: string[]; defaultModel: string; requiresApiKey: boolean; apiKeyFormat: string; supportsStreaming: boolean; maxTokensLimit: number; pricingInfo?: PricingInfo; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/GreetingTypes.ets#L671-L681
4db473f684a60e3d4ee079273ecc586e1581bf0e
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/imagetheft/src/main/ets/view/ImageTheft.ets
arkts
ImageTheftComponent
功能描述: 使用第三方库imageknife,通过在请求头中添加Referer来实现防盗链图片的功能。 推荐场景: 网络图片资源需要防盗链的场景 核心组件: 1. imageknife 实现步骤: 1. 新建imageKnifeOption变量,作为ImageKnifeComponent的入参配置。 2. 新建RequestOption对象实例,并在里面配置请求头,缓存规则,以及请求成功和回调等配置。 3. 在imageknife实例调用call函数,传入步骤2里面的实例。
@Component export struct ImageTheftComponent { @State imgUrl: string = DEFAULT_IMG_URL; // 图片image的url @State refer: string = DEFAULT_REFER; // 图片image的refer @State imageKnifeOption: ImageKnifeOption = { // 图片组件ImageKnifeComponent的配置项 loadSrc: '', isCacheable: false, }; @StorageLink('avoidAreaBottomToModule') avoidAreaBottomToModule: number = 0; emptyPixel: image.PixelMap | null = null; // 存储重置用的空白图片 focusController = this.getUIContext().getFocusController(); // 组件焦点控制器 build() { Column() { // 场景描述组件 FunctionDescription({ content: $r("app.string.image_theft_content") }) // 输入框和按钮 Column({ space: IMAGE_THEFT_COLUMN_SPACE }) { Row() { Text($r("app.string.image_theft_image_url")) .width($r("app.integer.image_theft_text_width")) .height($r("app.integer.image_theft_text_height")) TextArea({ text: $$this.imgUrl }) .width($r("app.string.image_theft_textarea_width")) .enableKeyboardOnFocus(false) } .alignItems(VerticalAlign.Top) Row() { Text($r("app.string.image_theft_image_refer")) .width($r("app.integer.image_theft_text_width")) .height($r("app.integer.image_theft_text_height")) TextArea({ text: $$this.refer }) .width($r("app.string.image_theft_textarea_width")) .enableKeyboardOnFocus(false) } .alignItems(VerticalAlign.Top) Row({ space: IMAGE_THEFT_COLUMN_SPACE }) { Button($r("app.string.image_theft_button_request")) .width($r("app.integer.image_theft_button_width")) .clickEffect({ level: ClickEffectLevel.HEAVY, scale: IMAGE_THEFT_BUTTON_CLICK_SCALE }) .onClick(() => { this.sendRequest(this.imgUrl, this.refer); // 清除输入框焦点 this.focusController.clearFocus(); }) Button($r("app.string.image_theft_button_reset")) .width($r("app.integer.image_theft_button_width")) .clickEffect({ level: ClickEffectLevel.HEAVY, scale: IMAGE_THEFT_BUTTON_CLICK_SCALE }) .onClick(() => { // 清除输入框焦点 this.focusController.clearFocus(); this.imgUrl = DEFAULT_IMG_URL; this.refer = DEFAULT_REFER; if (this.emptyPixel) { // 如果已经有空白Pixel,则将其赋值,否则生成空白Pixel this.imageKnifeOption.loadSrc = this.emptyPixel; } else { const color: ArrayBuffer = new ArrayBuffer(4); // 4为需要创建的像素buffer大小,取值为:height * width * 4 const opts: image.InitializationOptions = { size: { height: 1, width: 1 } }; // 为了展示空白,需要生成1*1像素的图片 image.createPixelMap(color, opts).then(result => { this.imageKnifeOption.loadSrc = result; }); } }) } } .margin({ top: $r('app.integer.image_theft_column_margin_top'), bottom: $r('app.integer.image_theft_column_margin_bottom') }) .width($r('app.string.image_theft_column_margin_width')) // 图片展示组件 ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption }) .width(IMAGE_THEFT_IMAGEKNIFE_COMPONENT_HEIGHT) .border({ width: $r("app.integer.image_theft_imageknife_component_border_width"), color: Color.Gray }) .borderRadius($r('app.integer.image_theft_imageknife_component_border_radius')) .clip(true) .id('myImage') .layoutWeight(1) } .padding({ top: $r('app.integer.image_theft_outer_column_padding'), bottom: px2vp(this.avoidAreaBottomToModule), left: $r('app.integer.image_theft_outer_column_padding'), right: $r('app.integer.image_theft_outer_column_padding') }) } /** * 发送请求 * @param url 图片url * @param ref 图片来源 */ sendRequest(url: string, ref: string): void { const imageKnife: ImageKnife | undefined = ImageKnifeGlobal.getInstance().getImageKnife(); if (imageKnife !== undefined) { imageKnife.removeAllMemoryCache() // 清理全部缓存 imageKnife.removeAllFileCache() // 清理全部缓存 // TODO: 知识点:自定义RequestOption来获取image图片。 const request: RequestOption = new RequestOption(); // TODO: 知识点:使用addHeader添加请求头。 request.addHeader('Referer', ref); request.skipMemoryCache(true) .diskCacheStrategy(new NONE())// 取消磁盘缓存 .errorholder($r("app.media.image_theft_failed"), { asyncSuccess: (data: ImageKnifeData) => { if (data.isPixelMap()) { this.imageKnifeOption.loadSrc = data.drawPixelMap?.imagePixelMap; } } }) .load(url)// TODO: 知识点:添加请求url。 .addListener({ // TODO: 知识点:添加请求回调监听器。 callback: (err: BusinessError | string, data: ImageKnifeData) => { if (data.isPixelMap()) { if (data.drawPixelMap) { // TODO: 知识点:在这里获取到请求返回的图片,将图片赋值给imageKnifeOption.loadSrc。 this.imageKnifeOption.loadSrc = data.drawPixelMap.imagePixelMap; } else { this.imageKnifeOption.loadSrc = $r("app.media.image_theft_failed"); } } return true; } }) const compSize: Size = { width: IMAGE_THEFT_IMAGEKNIFE_COMPONENT_WIDTH, height: IMAGE_THEFT_IMAGEKNIFE_COMPONENT_HEIGHT }; // (必传)这里setImageViewSize函数必传初始组件大小,因为涉及到图片变换效果都需要适配图像源和组件大小。 // TODO: 知识点:如果是自适应组件等不确定初始图片宽高的情况,可以通过getInspectorByKey获取,参考https://developer.huawei.com/consumer/cn/doc/harmonyos-faqs/faqs-arkui-kit-0000001769732210#section10880155113412。 request.setImageViewSize(compSize); // 磁盘Lru缓存数量设置成0张,0字节 imageKnife.setLruCacheSize(0, 0); // 最后使用ImageKnife的call函数调用request即可 imageKnife.call(request); } } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ImageTheftComponent AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right imgUrl : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left DEFAULT_IMG_URL AST#expression#Right ; AST#property_declaration#Right // 图片image的url AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right refer : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left DEFAULT_REFER AST#expression#Right ; AST#property_declaration#Right // 图片image的refer AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right imageKnifeOption : AST#type_annotation#Left AST#primary_type#Left ImageKnifeOption AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { // 图片组件ImageKnifeComponent的配置项 AST#property_assignment#Left AST#property_name#Left loadSrc AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left isCacheable 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#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ StorageLink ( AST#expression#Left 'avoidAreaBottomToModule' AST#expression#Right ) AST#decorator#Right avoidAreaBottomToModule : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left emptyPixel : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#qualified_type#Left image . PixelMap AST#qualified_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right // 存储重置用的空白图片 AST#property_declaration#Left focusController = 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 . getFocusController 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#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 FunctionDescription ( AST#component_parameters#Left { AST#component_parameter#Left content : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.image_theft_content" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 输入框和按钮 AST#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 IMAGE_THEFT_COLUMN_SPACE AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.image_theft_image_url" 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.image_theft_text_width" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.image_theft_text_height" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left TextArea ( AST#component_parameters#Left { AST#component_parameter#Left text : AST#expression#Left AST#member_expression#Left AST#expression#Left $$this AST#expression#Right . imgUrl 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 AST#resource_expression#Left $r ( AST#expression#Left "app.string.image_theft_textarea_width" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . enableKeyboardOnFocus ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_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#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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.image_theft_image_refer" 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.image_theft_text_width" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.image_theft_text_height" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left TextArea ( AST#component_parameters#Left { AST#component_parameter#Left text : AST#expression#Left AST#member_expression#Left AST#expression#Left $$this AST#expression#Right . refer 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 AST#resource_expression#Left $r ( AST#expression#Left "app.string.image_theft_textarea_width" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . enableKeyboardOnFocus ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_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#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#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 IMAGE_THEFT_COLUMN_SPACE AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.image_theft_button_request" 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.image_theft_button_width" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . clickEffect ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left level AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left ClickEffectLevel AST#expression#Right . HEAVY AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left scale AST#property_name#Right : AST#expression#Left IMAGE_THEFT_BUTTON_CLICK_SCALE 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 this AST#expression#Right . sendRequest 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 . imgUrl AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . refer AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 清除输入框焦点 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . focusController AST#member_expression#Right AST#expression#Right . clearFocus AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.image_theft_button_reset" 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.image_theft_button_width" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . clickEffect ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left level AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left ClickEffectLevel AST#expression#Right . HEAVY AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left scale AST#property_name#Right : AST#expression#Left IMAGE_THEFT_BUTTON_CLICK_SCALE 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 . focusController AST#member_expression#Right AST#expression#Right . clearFocus AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#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 . imgUrl AST#member_expression#Right = AST#expression#Left DEFAULT_IMG_URL 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 . refer AST#member_expression#Right = AST#expression#Left DEFAULT_REFER AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . emptyPixel AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { // 如果已经有空白Pixel,则将其赋值,否则生成空白Pixel AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imageKnifeOption AST#member_expression#Right AST#expression#Right . loadSrc AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . emptyPixel 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#variable_declaration#Left const AST#variable_declarator#Left color : AST#type_annotation#Left AST#primary_type#Left ArrayBuffer 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 ArrayBuffer AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 4 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 4为需要创建的像素buffer大小,取值为:height * width * 4 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left opts : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left image . InitializationOptions 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 size AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left 1 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left width 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#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 为了展示空白,需要生成1*1像素的图片 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 image AST#expression#Right . createPixelMap AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left color AST#expression#Right , AST#expression#Left opts 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imageKnifeOption AST#member_expression#Right AST#expression#Right . loadSrc AST#member_expression#Right = AST#expression#Left result 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#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 . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.image_theft_column_margin_top' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.image_theft_column_margin_bottom' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.image_theft_column_margin_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 图片展示组件 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ImageKnifeComponent ( AST#component_parameters#Left { AST#component_parameter#Left imageKnifeOption : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imageKnifeOption 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 IMAGE_THEFT_IMAGEKNIFE_COMPONENT_HEIGHT AST#expression#Right ) AST#modifier_chain_expression#Left . border ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.image_theft_imageknife_component_border_width" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Gray AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.image_theft_imageknife_component_border_radius' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . clip ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . id ( AST#expression#Left 'myImage' AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.image_theft_outer_column_padding' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left px2vp AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avoidAreaBottomToModule AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#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.image_theft_outer_column_padding' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.image_theft_outer_column_padding' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right /** * 发送请求 * @param url 图片url * @param ref 图片来源 */ AST#method_declaration#Left sendRequest AST#parameter_list#Left ( AST#parameter#Left url : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left ref : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left imageKnife : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ImageKnife 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#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 ImageKnifeGlobal AST#expression#Right . getInstance AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getImageKnife 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 imageKnife AST#expression#Right !== AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left imageKnife AST#expression#Right . removeAllMemoryCache 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 imageKnife AST#expression#Right . removeAllFileCache 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 // 清理全部缓存 // TODO: 知识点:自定义RequestOption来获取image图片。 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left request : AST#type_annotation#Left AST#primary_type#Left RequestOption 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 RequestOption 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 // TODO: 知识点:使用addHeader添加请求头。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left request AST#expression#Right . addHeader AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Referer' AST#expression#Right , AST#expression#Left ref AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 request AST#expression#Right . skipMemoryCache 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 . diskCacheStrategy 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 NONE AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right // 取消磁盘缓存 . errorholder AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.image_theft_failed" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left asyncSuccess AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left ImageKnifeData 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . isPixelMap AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imageKnifeOption AST#member_expression#Right AST#expression#Right . loadSrc AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . drawPixelMap AST#member_expression#Right AST#expression#Right ?. imagePixelMap 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#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 . load AST#member_expression#Right 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 // TODO: 知识点:添加请求url。 . addListener AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { // TODO: 知识点:添加请求回调监听器。 AST#property_assignment#Left AST#property_name#Left callback AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left BusinessError AST#primary_type#Right | AST#primary_type#Left string AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left ImageKnifeData 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . isPixelMap 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#member_expression#Left AST#expression#Left data AST#expression#Right . drawPixelMap AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { // TODO: 知识点:在这里获取到请求返回的图片,将图片赋值给imageKnifeOption.loadSrc。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imageKnifeOption AST#member_expression#Right AST#expression#Right . loadSrc AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . drawPixelMap AST#member_expression#Right AST#expression#Right . imagePixelMap 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . imageKnifeOption AST#member_expression#Right AST#expression#Right . loadSrc AST#member_expression#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.image_theft_failed" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_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#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left compSize : AST#type_annotation#Left AST#primary_type#Left Size AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left IMAGE_THEFT_IMAGEKNIFE_COMPONENT_WIDTH AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left IMAGE_THEFT_IMAGEKNIFE_COMPONENT_HEIGHT 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 // (必传)这里setImageViewSize函数必传初始组件大小,因为涉及到图片变换效果都需要适配图像源和组件大小。 // TODO: 知识点:如果是自适应组件等不确定初始图片宽高的情况,可以通过getInspectorByKey获取,参考https://developer.huawei.com/consumer/cn/doc/harmonyos-faqs/faqs-arkui-kit-0000001769732210#section10880155113412。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left request AST#expression#Right . setImageViewSize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left compSize AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 磁盘Lru缓存数量设置成0张,0字节 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left imageKnife AST#expression#Right . setLruCacheSize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 最后使用ImageKnife的call函数调用request即可 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left imageKnife AST#expression#Right . call AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left request AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export struct ImageTheftComponent { @State imgUrl: string = DEFAULT_IMG_URL; @State refer: string = DEFAULT_REFER; @State imageKnifeOption: ImageKnifeOption = { loadSrc: '', isCacheable: false, }; @StorageLink('avoidAreaBottomToModule') avoidAreaBottomToModule: number = 0; emptyPixel: image.PixelMap | null = null; focusController = this.getUIContext().getFocusController(); build() { Column() { FunctionDescription({ content: $r("app.string.image_theft_content") }) Column({ space: IMAGE_THEFT_COLUMN_SPACE }) { Row() { Text($r("app.string.image_theft_image_url")) .width($r("app.integer.image_theft_text_width")) .height($r("app.integer.image_theft_text_height")) TextArea({ text: $$this.imgUrl }) .width($r("app.string.image_theft_textarea_width")) .enableKeyboardOnFocus(false) } .alignItems(VerticalAlign.Top) Row() { Text($r("app.string.image_theft_image_refer")) .width($r("app.integer.image_theft_text_width")) .height($r("app.integer.image_theft_text_height")) TextArea({ text: $$this.refer }) .width($r("app.string.image_theft_textarea_width")) .enableKeyboardOnFocus(false) } .alignItems(VerticalAlign.Top) Row({ space: IMAGE_THEFT_COLUMN_SPACE }) { Button($r("app.string.image_theft_button_request")) .width($r("app.integer.image_theft_button_width")) .clickEffect({ level: ClickEffectLevel.HEAVY, scale: IMAGE_THEFT_BUTTON_CLICK_SCALE }) .onClick(() => { this.sendRequest(this.imgUrl, this.refer); this.focusController.clearFocus(); }) Button($r("app.string.image_theft_button_reset")) .width($r("app.integer.image_theft_button_width")) .clickEffect({ level: ClickEffectLevel.HEAVY, scale: IMAGE_THEFT_BUTTON_CLICK_SCALE }) .onClick(() => { this.focusController.clearFocus(); this.imgUrl = DEFAULT_IMG_URL; this.refer = DEFAULT_REFER; if (this.emptyPixel) { this.imageKnifeOption.loadSrc = this.emptyPixel; } else { const color: ArrayBuffer = new ArrayBuffer(4); const opts: image.InitializationOptions = { size: { height: 1, width: 1 } }; image.createPixelMap(color, opts).then(result => { this.imageKnifeOption.loadSrc = result; }); } }) } } .margin({ top: $r('app.integer.image_theft_column_margin_top'), bottom: $r('app.integer.image_theft_column_margin_bottom') }) .width($r('app.string.image_theft_column_margin_width')) ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption }) .width(IMAGE_THEFT_IMAGEKNIFE_COMPONENT_HEIGHT) .border({ width: $r("app.integer.image_theft_imageknife_component_border_width"), color: Color.Gray }) .borderRadius($r('app.integer.image_theft_imageknife_component_border_radius')) .clip(true) .id('myImage') .layoutWeight(1) } .padding({ top: $r('app.integer.image_theft_outer_column_padding'), bottom: px2vp(this.avoidAreaBottomToModule), left: $r('app.integer.image_theft_outer_column_padding'), right: $r('app.integer.image_theft_outer_column_padding') }) } sendRequest(url: string, ref: string): void { const imageKnife: ImageKnife | undefined = ImageKnifeGlobal.getInstance().getImageKnife(); if (imageKnife !== undefined) { imageKnife.removeAllMemoryCache() imageKnife.removeAllFileCache() const request: RequestOption = new RequestOption(); request.addHeader('Referer', ref); request.skipMemoryCache(true) .diskCacheStrategy(new NONE()) .errorholder($r("app.media.image_theft_failed"), { asyncSuccess: (data: ImageKnifeData) => { if (data.isPixelMap()) { this.imageKnifeOption.loadSrc = data.drawPixelMap?.imagePixelMap; } } }) .load(url) .addListener({ callback: (err: BusinessError | string, data: ImageKnifeData) => { if (data.isPixelMap()) { if (data.drawPixelMap) { this.imageKnifeOption.loadSrc = data.drawPixelMap.imagePixelMap; } else { this.imageKnifeOption.loadSrc = $r("app.media.image_theft_failed"); } } return true; } }) const compSize: Size = { width: IMAGE_THEFT_IMAGEKNIFE_COMPONENT_WIDTH, height: IMAGE_THEFT_IMAGEKNIFE_COMPONENT_HEIGHT }; request.setImageViewSize(compSize); imageKnife.setLruCacheSize(0, 0); imageKnife.call(request); } } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/imagetheft/src/main/ets/view/ImageTheft.ets#L49-L195
01bfa442cbbd18aa7ac161337142ccd2fe8ede7a
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/imageresizable/src/main/ets/pages/ProductWaterFlowPage.ets
arkts
ProductWaterFlowPageComponent
功能描述:HarmonyOS上不支持.9资源文件进行安全拉伸。 作为替代方案,本案例中商城页面的促销标签边框使用同一张图片资源,通过设置图片的resizable属性,展示不同长度的促销标签效果。 推荐场景:商城页面 核心组件: 1.ProductItemComp, 实现步骤: 1.使用WaterFlow+LazyForEach+组件复用实现高性能瀑布流
@Component export struct ProductWaterFlowPageComponent { @State productsDataSource: ProductsDataSource = new ProductsDataSource(); build() { Column(){ WaterFlow() { LazyForEach(this.productsDataSource, (item: Product) => { FlowItem() { // TODO: 性能知识点:使用@Reusable修饰可复用的组件,并通过设置reuseId提供瀑布流滑动场景中的组件复用能力 ProductItemComp({ product: item }) .reuseId(item.type) } .width('100%') }) } .columnsTemplate(CommonConstants.MAIN_PAGE_WATERFLOW_COLUMNS_TEMPLATE) .width('100%') .height('100%') .edgeEffect(EdgeEffect.Fade) .clip(false) .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) } .width('100%') .height('100%') .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) .clip(true) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ProductWaterFlowPageComponent AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right productsDataSource : AST#type_annotation#Left AST#primary_type#Left ProductsDataSource 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 ProductsDataSource 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#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 WaterFlow ( ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#lazy_for_each_statement#Left LazyForEach ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . productsDataSource 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 Product 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 FlowItem ( ) AST#container_content_body#Left { // TODO: 性能知识点:使用@Reusable修饰可复用的组件,并通过设置reuseId提供瀑布流滑动场景中的组件复用能力 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ProductItemComp ( AST#component_parameters#Left { AST#component_parameter#Left product : AST#expression#Left item AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . reuseId ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . type 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#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#lazy_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 CommonConstants AST#expression#Right . MAIN_PAGE_WATERFLOW_COLUMNS_TEMPLATE AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . edgeEffect ( AST#expression#Left AST#member_expression#Left AST#expression#Left EdgeEffect AST#expression#Right . Fade AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . clip ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#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#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 . expandSafeArea ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left SafeAreaType AST#expression#Right . SYSTEM AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left SafeAreaEdge AST#expression#Right . BOTTOM AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . clip ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 ProductWaterFlowPageComponent { @State productsDataSource: ProductsDataSource = new ProductsDataSource(); build() { Column(){ WaterFlow() { LazyForEach(this.productsDataSource, (item: Product) => { FlowItem() { ProductItemComp({ product: item }) .reuseId(item.type) } .width('100%') }) } .columnsTemplate(CommonConstants.MAIN_PAGE_WATERFLOW_COLUMNS_TEMPLATE) .width('100%') .height('100%') .edgeEffect(EdgeEffect.Fade) .clip(false) .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) } .width('100%') .height('100%') .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) .clip(true) } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/imageresizable/src/main/ets/pages/ProductWaterFlowPage.ets#L32-L62
0683462cb620e55f0dd6d55921af71c372a30b1a
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/crypto/SM3.ets
arkts
digestSegmentSync
SM3分段摘要,同步 @param data 待摘要的数据 @param resultCoding 摘要的编码方式(base64/hex),默认不传为hex。 @param len 自定义的数据拆分长度 @returns
static digestSegmentSync(data: string, resultCoding: crypto.BhCoding = 'hex', len: number = 128): string { return CryptoUtil.digestSegmentSync(data, 'SM3', resultCoding, len); }
AST#method_declaration#Left static digestSegmentSync AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left resultCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left crypto . BhCoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'hex' AST#expression#Right AST#parameter#Right , AST#parameter#Left len : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 128 AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CryptoUtil AST#expression#Right . digestSegmentSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right , AST#expression#Left 'SM3' AST#expression#Right , AST#expression#Left resultCoding AST#expression#Right , AST#expression#Left len AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static digestSegmentSync(data: string, resultCoding: crypto.BhCoding = 'hex', len: number = 128): string { return CryptoUtil.digestSegmentSync(data, 'SM3', resultCoding, len); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/crypto/SM3.ets#L69-L71
7cea6fc11f3ca2485ccc2684fe3a9d6cecfe30b3
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1/RSAPKCS1Sync.ets
arkts
encryptMessage
加密消息
function encryptMessage(publicKey: cryptoFramework.PubKey, plainText: cryptoFramework.DataBlob) { let cipher = cryptoFramework.createCipher('RSA1024|PKCS1'); cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, publicKey, null); let encryptData = cipher.doFinalSync(plainText); return encryptData; }
AST#function_declaration#Left function encryptMessage AST#parameter_list#Left ( AST#parameter#Left publicKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . PubKey AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left plainText : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left cipher = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createCipher AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'RSA1024|PKCS1' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cipher AST#expression#Right . initSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . CryptoMode AST#member_expression#Right AST#expression#Right . ENCRYPT_MODE AST#member_expression#Right AST#expression#Right , AST#expression#Left publicKey AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left encryptData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cipher AST#expression#Right . doFinalSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left plainText 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 encryptData AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
function encryptMessage(publicKey: cryptoFramework.PubKey, plainText: cryptoFramework.DataBlob) { let cipher = cryptoFramework.createCipher('RSA1024|PKCS1'); cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, publicKey, null); let encryptData = cipher.doFinalSync(plainText); return encryptData; }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceRSA/entry/src/main/ets/pages/rsa_pkcs1/RSAPKCS1Sync.ets#L20-L25
2b827aead67df9da559e5517b0dd9c55587e54f3
gitee
wuyukobe24/HMApp_ArkTS.git
6d09d9b07a4fdc4713e5a13b61b85bc1e7893956
entry/src/main/ets/pages/home/ViewModel/QQHomeViewModel.ets
arkts
loadHomeRequestSegmentListData
获取首页Segment数据
loadHomeRequestSegmentListData(success:(str:string)=>void, fail:(error:NetError)=>void) { let param:Record<string, string> = { } let url:string = '/go/zone/v3/channel?zone=plat' getRequest(url, param, (jsonStr:string) => { success(jsonStr) }, (error:NetError) => { console.error(`viewmodel Segment error:${JSON.stringify(error)}`) fail(error) }) }
AST#method_declaration#Left loadHomeRequestSegmentListData AST#parameter_list#Left ( AST#parameter#Left success : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left fail : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#primary_type#Left NetError 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#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left param : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left url : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left '/go/zone/v3/channel?zone=plat' AST#expression#Right AST#ERROR#Left getRequest AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left url AST#expression#Right , AST#expression#Left param AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left jsonStr : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left success AST#expression#Right AST#argument_list#Left ( AST#expression#Left jsonStr AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#primary_type#Left NetError 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 ` viewmodel Segment error: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left fail AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
loadHomeRequestSegmentListData(success:(str:string)=>void, fail:(error:NetError)=>void) { let param:Record<string, string> = { } let url:string = '/go/zone/v3/channel?zone=plat' getRequest(url, param, (jsonStr:string) => { success(jsonStr) }, (error:NetError) => { console.error(`viewmodel Segment error:${JSON.stringify(error)}`) fail(error) }) }
https://github.com/wuyukobe24/HMApp_ArkTS.git/blob/6d09d9b07a4fdc4713e5a13b61b85bc1e7893956/entry/src/main/ets/pages/home/ViewModel/QQHomeViewModel.ets#L11-L22
25025e39dc3417ac55af40382f6d637db49ec5e3
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/main/src/main/ets/viewmodel/HomeViewModel.ets
arkts
aboutToAppear
页面出现时初始化页面数据 @returns {void} 无返回值
aboutToAppear(): void { this.loadHomeData(); }
AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . loadHomeData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
aboutToAppear(): void { this.loadHomeData(); }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/main/src/main/ets/viewmodel/HomeViewModel.ets#L42-L44
0436c382b77eaba054a84e1bbce42b4edcd0c7f6
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/SystemFeature/Security/AbilityAccessCtrl/requestPermission/index.ets
arkts
requestModel
Copyright (c) 2023 Huawei Device Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
export { requestModel } from './src/main/ets/components/mainpage/RequestModel'
AST#export_declaration#Left export { requestModel } from './src/main/ets/components/mainpage/RequestModel' AST#export_declaration#Right
export { requestModel } from './src/main/ets/components/mainpage/RequestModel'
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/Security/AbilityAccessCtrl/requestPermission/index.ets#L16-L16
72d5c6cd4e3703678f35b3091087fe9c416b0aa9
gitee
openharmony/xts_acts
5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686
arkui/ace_ets_component_common_attrss/ace_ets_component_common_attrss_aspectRatio/entry/src/main/ets/MainAbility/pages/aspectRatio/AspectRatioHeightPage.ets
arkts
commonStyle
Set common style.
@Styles commonStyle(){ .aspectRatio(this._aspectRatio) .height(this._height) .key(this.componentKey) }
AST#method_declaration#Left AST#decorator#Left @ Styles AST#decorator#Right commonStyle AST#parameter_list#Left ( ) AST#parameter_list#Right AST#extend_function_body#Left { AST#modifier_chain_expression#Left . aspectRatio ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _aspectRatio AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _height AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . key ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . componentKey AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right } AST#extend_function_body#Right AST#method_declaration#Right
@Styles commonStyle(){ .aspectRatio(this._aspectRatio) .height(this._height) .key(this.componentKey) }
https://github.com/openharmony/xts_acts/blob/5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686/arkui/ace_ets_component_common_attrss/ace_ets_component_common_attrss_aspectRatio/entry/src/main/ets/MainAbility/pages/aspectRatio/AspectRatioHeightPage.ets#L44-L49
d375cb22f53fa6f7725a3d3f4b864a49ee8e550e
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/Solutions/InputMethod/KikaInputMethod/entry/src/main/ets/components/KeyMenu.ets
arkts
KeyMenu
key键盘
@Component export struct KeyMenu { @StorageLink('inputStyle') inputStyle: KeyStyle = StyleConfiguration.getSavedInputStyle(); @Consume menuType: number; @Provide keyState: number = KeyState.LOWER_CASE; private keyList: keySourceListType[] = keySourceListData; private spaceWidth: Resource = this.inputStyle.spaceButtonWidth_1; private returnWidth: Resource = this.inputStyle.returnButtonWidthType_1; build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) { Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { ForEach(this.keyList.slice(0, 10), (item: keySourceListType) => { KeyItemNumber({ keyValue: item }) }, (item: keySourceListType) => item.content) } .width('100%') .height(this.inputStyle.basicButtonHeight) .margin({ top: this.inputStyle.paddingTop }) Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { Stack() { }.width('4%').height(0) ForEach(this.keyList.slice(10, 19), (item: keySourceListType) => { KeyItemNumber({ keyValue: item }) }, (item: keySourceListType) => item.content) Stack() { }.width('4%').height(0) } .width('100%') .height(this.inputStyle.basicButtonHeight) .margin({ top: this.inputStyle.paddingTop }) Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { Stack() { Image($rawfile(this.keyState === KeyState.ONCE_UPPER_CASE ? 'shift light.svg' : this.keyState === KeyState.UPPER_CASE ? 'shift light long.svg' : 'shift.svg')) .width(this.inputStyle.featurePicSize) .height(this.inputStyle.featurePicSize) } .backgroundColor($r('app.color.key_item_gray')) .borderRadius(4) .onClick(() => { if (this.keyState === KeyState.LOWER_CASE) { this.keyState = KeyState.ONCE_UPPER_CASE; } else if (this.keyState === KeyState.ONCE_UPPER_CASE) { this.keyState = KeyState.UPPER_CASE; } else if (this.keyState === KeyState.UPPER_CASE) { this.keyState = KeyState.LOWER_CASE; } }) .height('100%') .width(this.inputStyle.switchButtonWidth) .shadow({ radius: 1, color: $r('app.color.shadow'), offsetY: 3 }) .stateStyles({ normal: normalStyles, pressed: pressedStyles }) ForEach(this.keyList.slice(19), (item: keySourceListType) => { KeyItemNumber({ keyValue: item }) }, (item: keySourceListType) => item.content) DeleteItem() } .width('100%') .height(this.inputStyle.basicButtonHeight) .margin({ top: this.inputStyle.paddingTop }) Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { KeyItemGray({ keyValue: MenuKey.NUMBER_KEY }) KeyItem({ keyValue: { content: ',', title: ',', upperContent: ',' } }) SpaceItem({ spaceWith: this.spaceWidth }) KeyItem({ keyValue: { content: '.', title: '.', upperContent: '.' } }) ReturnItem({ returnWidth: this.returnWidth }) } .width('100%') .height(this.inputStyle.basicButtonHeight) .margin({ top: this.inputStyle.paddingTop }) } .width('100%') .height('100%') .padding({ left: this.inputStyle.paddingLeftRight, right: this.inputStyle.paddingLeftRight }) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct KeyMenu AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ StorageLink ( AST#expression#Left 'inputStyle' AST#expression#Right ) AST#decorator#Right inputStyle : AST#type_annotation#Left AST#primary_type#Left KeyStyle AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StyleConfiguration AST#expression#Right . getSavedInputStyle AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Consume AST#decorator#Right menuType : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Provide AST#decorator#Right keyState : 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 KeyState AST#expression#Right . LOWER_CASE AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private keyList : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left keySourceListType [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left keySourceListData AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private spaceWidth : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . spaceButtonWidth_1 AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private returnWidth : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . returnButtonWidthType_1 AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Flex ( AST#component_parameters#Left { AST#component_parameter#Left direction : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexDirection AST#expression#Right . Column AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left alignItems : AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Flex ( AST#component_parameters#Left { AST#component_parameter#Left justifyContent : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceBetween AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left alignItems : AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#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 this AST#expression#Right . keyList 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 10 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 item : AST#type_annotation#Left AST#primary_type#Left keySourceListType 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 KeyItemNumber ( AST#component_parameters#Left { AST#component_parameter#Left keyValue : AST#expression#Left item AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_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 keySourceListType AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . content AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . basicButtonHeight AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . paddingTop 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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Flex ( AST#component_parameters#Left { AST#component_parameter#Left justifyContent : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceBetween AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left alignItems : AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Stack ( ) AST#container_content_body#Left { } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '4%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 0 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ui_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 this AST#expression#Right . keyList AST#member_expression#Right AST#expression#Right . slice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 10 AST#expression#Right , AST#expression#Left 19 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 item : AST#type_annotation#Left AST#primary_type#Left keySourceListType 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 KeyItemNumber ( AST#component_parameters#Left { AST#component_parameter#Left keyValue : AST#expression#Left item AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_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 keySourceListType AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . content AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Stack ( ) AST#container_content_body#Left { } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '4%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 0 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 AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . basicButtonHeight AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . paddingTop 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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Flex ( AST#component_parameters#Left { AST#component_parameter#Left justifyContent : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceBetween AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left alignItems : AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Stack ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#call_expression#Left AST#expression#Left $rawfile AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 . keyState AST#member_expression#Right AST#expression#Right === AST#expression#Left KeyState AST#expression#Right AST#binary_expression#Right AST#expression#Right . ONCE_UPPER_CASE AST#member_expression#Right AST#expression#Right ? AST#expression#Left 'shift light.svg' AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . keyState AST#member_expression#Right AST#expression#Right === AST#expression#Left KeyState AST#expression#Right AST#binary_expression#Right AST#expression#Right . UPPER_CASE AST#member_expression#Right AST#expression#Right ? AST#expression#Left 'shift light long.svg' AST#expression#Right : AST#expression#Left 'shift.svg' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . featurePicSize AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . featurePicSize 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 . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.key_item_gray' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 4 AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . keyState AST#member_expression#Right AST#expression#Right === AST#expression#Left KeyState AST#expression#Right AST#binary_expression#Right AST#expression#Right . LOWER_CASE 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 . keyState AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left KeyState AST#expression#Right . ONCE_UPPER_CASE 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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . keyState AST#member_expression#Right AST#expression#Right === AST#expression#Left KeyState AST#expression#Right AST#binary_expression#Right AST#expression#Right . ONCE_UPPER_CASE 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 . keyState AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left KeyState AST#expression#Right . UPPER_CASE 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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . keyState AST#member_expression#Right AST#expression#Right === AST#expression#Left KeyState AST#expression#Right AST#binary_expression#Right AST#expression#Right . UPPER_CASE 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 . keyState AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left KeyState AST#expression#Right . LOWER_CASE 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#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . switchButtonWidth AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . shadow ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left 1 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.shadow' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetY AST#property_name#Right : AST#expression#Left 3 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . stateStyles ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left normal AST#property_name#Right : AST#expression#Left normalStyles AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left pressed AST#property_name#Right : AST#expression#Left pressedStyles AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ui_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 this AST#expression#Right . keyList AST#member_expression#Right AST#expression#Right . slice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 19 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 item : AST#type_annotation#Left AST#primary_type#Left keySourceListType 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 KeyItemNumber ( AST#component_parameters#Left { AST#component_parameter#Left keyValue : AST#expression#Left item AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_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 keySourceListType AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . content AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left DeleteItem ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . basicButtonHeight AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . paddingTop 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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Flex ( AST#component_parameters#Left { AST#component_parameter#Left justifyContent : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceBetween AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left alignItems : AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left KeyItemGray ( AST#component_parameters#Left { AST#component_parameter#Left keyValue : AST#expression#Left AST#member_expression#Left AST#expression#Left MenuKey AST#expression#Right . NUMBER_KEY AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left KeyItem ( AST#component_parameters#Left { AST#component_parameter#Left keyValue : AST#expression#Left AST#object_literal#Left { 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 title AST#property_name#Right : AST#expression#Left ',' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left upperContent AST#property_name#Right : AST#expression#Left ',' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left SpaceItem ( AST#component_parameters#Left { AST#component_parameter#Left spaceWith : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . spaceWidth AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left KeyItem ( AST#component_parameters#Left { AST#component_parameter#Left keyValue : AST#expression#Left AST#object_literal#Left { 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 title AST#property_name#Right : AST#expression#Left '.' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left upperContent AST#property_name#Right : AST#expression#Left '.' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ReturnItem ( AST#component_parameters#Left { AST#component_parameter#Left returnWidth : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . returnWidth AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . basicButtonHeight AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . paddingTop 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 ) 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#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . paddingLeftRight AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . paddingLeftRight 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#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export struct KeyMenu { @StorageLink('inputStyle') inputStyle: KeyStyle = StyleConfiguration.getSavedInputStyle(); @Consume menuType: number; @Provide keyState: number = KeyState.LOWER_CASE; private keyList: keySourceListType[] = keySourceListData; private spaceWidth: Resource = this.inputStyle.spaceButtonWidth_1; private returnWidth: Resource = this.inputStyle.returnButtonWidthType_1; build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) { Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { ForEach(this.keyList.slice(0, 10), (item: keySourceListType) => { KeyItemNumber({ keyValue: item }) }, (item: keySourceListType) => item.content) } .width('100%') .height(this.inputStyle.basicButtonHeight) .margin({ top: this.inputStyle.paddingTop }) Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { Stack() { }.width('4%').height(0) ForEach(this.keyList.slice(10, 19), (item: keySourceListType) => { KeyItemNumber({ keyValue: item }) }, (item: keySourceListType) => item.content) Stack() { }.width('4%').height(0) } .width('100%') .height(this.inputStyle.basicButtonHeight) .margin({ top: this.inputStyle.paddingTop }) Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { Stack() { Image($rawfile(this.keyState === KeyState.ONCE_UPPER_CASE ? 'shift light.svg' : this.keyState === KeyState.UPPER_CASE ? 'shift light long.svg' : 'shift.svg')) .width(this.inputStyle.featurePicSize) .height(this.inputStyle.featurePicSize) } .backgroundColor($r('app.color.key_item_gray')) .borderRadius(4) .onClick(() => { if (this.keyState === KeyState.LOWER_CASE) { this.keyState = KeyState.ONCE_UPPER_CASE; } else if (this.keyState === KeyState.ONCE_UPPER_CASE) { this.keyState = KeyState.UPPER_CASE; } else if (this.keyState === KeyState.UPPER_CASE) { this.keyState = KeyState.LOWER_CASE; } }) .height('100%') .width(this.inputStyle.switchButtonWidth) .shadow({ radius: 1, color: $r('app.color.shadow'), offsetY: 3 }) .stateStyles({ normal: normalStyles, pressed: pressedStyles }) ForEach(this.keyList.slice(19), (item: keySourceListType) => { KeyItemNumber({ keyValue: item }) }, (item: keySourceListType) => item.content) DeleteItem() } .width('100%') .height(this.inputStyle.basicButtonHeight) .margin({ top: this.inputStyle.paddingTop }) Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { KeyItemGray({ keyValue: MenuKey.NUMBER_KEY }) KeyItem({ keyValue: { content: ',', title: ',', upperContent: ',' } }) SpaceItem({ spaceWith: this.spaceWidth }) KeyItem({ keyValue: { content: '.', title: '.', upperContent: '.' } }) ReturnItem({ returnWidth: this.returnWidth }) } .width('100%') .height(this.inputStyle.basicButtonHeight) .margin({ top: this.inputStyle.paddingTop }) } .width('100%') .height('100%') .padding({ left: this.inputStyle.paddingLeftRight, right: this.inputStyle.paddingLeftRight }) } }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Solutions/InputMethod/KikaInputMethod/entry/src/main/ets/components/KeyMenu.ets#L34-L120
ea885be3f1e1bd47852e556a15b20372d24ce476
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/datastore/src/main/ets/datasource/ordercache/OrderCacheStoreDataSourceImpl.ets
arkts
getCarts
读取选中的购物车项 @returns {Promise<Cart[] | null>} 购物车列表
async getCarts(): Promise<Cart[] | null> { const value: preferences.ValueType = await this.prefs.get(OrderCacheStoreDataSourceImpl.KEY_CARTS, ""); if (typeof value === "string" && value.length > 0) { try { const parsed: CartJson[] = JSON.parse(value) as CartJson[]; return this.parseCartList(parsed); } catch { return null; } } return null; }
AST#method_declaration#Left async getCarts 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#union_type#Left AST#primary_type#Left AST#array_type#Left Cart [ ] 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#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 value : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left preferences . ValueType AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . prefs AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left OrderCacheStoreDataSourceImpl AST#expression#Right . KEY_CARTS 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left value AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left "string" AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left value 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#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left parsed : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left CartJson [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left 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 value 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 CartJson [ ] 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . parseCartList AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left parsed AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async getCarts(): Promise<Cart[] | null> { const value: preferences.ValueType = await this.prefs.get(OrderCacheStoreDataSourceImpl.KEY_CARTS, ""); if (typeof value === "string" && value.length > 0) { try { const parsed: CartJson[] = JSON.parse(value) as CartJson[]; return this.parseCartList(parsed); } catch { return null; } } return null; }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/datastore/src/main/ets/datasource/ordercache/OrderCacheStoreDataSourceImpl.ets#L106-L118
cc646c4c4787a7edb184954eb8c96cee49e56200
github
awa_Liny/LinysBrowser_NEXT
a5cd96a9aa8114cae4972937f94a8967e55d4a10
home/src/main/ets/hosts/bunch_of_defaults.ets
arkts
All window orientation enums. @returns The GRAND list orz.
export function default_window_orientations(): window.Orientation[] { return [ window.Orientation.UNSPECIFIED, window.Orientation.PORTRAIT, window.Orientation.LANDSCAPE, window.Orientation.PORTRAIT_INVERTED, window.Orientation.LANDSCAPE_INVERTED, window.Orientation.AUTO_ROTATION, window.Orientation.AUTO_ROTATION_PORTRAIT, window.Orientation.AUTO_ROTATION_LANDSCAPE, window.Orientation.AUTO_ROTATION_RESTRICTED, window.Orientation.AUTO_ROTATION_PORTRAIT_RESTRICTED, window.Orientation.AUTO_ROTATION_LANDSCAPE_RESTRICTED, window.Orientation.LOCKED, window.Orientation.AUTO_ROTATION_UNSPECIFIED, window.Orientation.USER_ROTATION_PORTRAIT, window.Orientation.USER_ROTATION_LANDSCAPE, window.Orientation.USER_ROTATION_PORTRAIT_INVERTED, window.Orientation.USER_ROTATION_LANDSCAPE_INVERTED, window.Orientation.FOLLOW_DESKTOP ]; }
AST#export_declaration#Left export AST#function_declaration#Left function default_window_orientations AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Orientation AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left [ ] AST#ERROR#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . Orientation AST#member_expression#Right AST#expression#Right . UNSPECIFIED AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . Orientation AST#member_expression#Right AST#expression#Right . PORTRAIT AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . Orientation AST#member_expression#Right AST#expression#Right . LANDSCAPE AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . Orientation AST#member_expression#Right AST#expression#Right . PORTRAIT_INVERTED AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . Orientation AST#member_expression#Right AST#expression#Right . LANDSCAPE_INVERTED AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . Orientation AST#member_expression#Right AST#expression#Right . AUTO_ROTATION AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . Orientation AST#member_expression#Right AST#expression#Right . AUTO_ROTATION_PORTRAIT AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . Orientation AST#member_expression#Right AST#expression#Right . AUTO_ROTATION_LANDSCAPE AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . Orientation AST#member_expression#Right AST#expression#Right . AUTO_ROTATION_RESTRICTED AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . Orientation AST#member_expression#Right AST#expression#Right . AUTO_ROTATION_PORTRAIT_RESTRICTED AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . Orientation AST#member_expression#Right AST#expression#Right . AUTO_ROTATION_LANDSCAPE_RESTRICTED AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . Orientation AST#member_expression#Right AST#expression#Right . LOCKED AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . Orientation AST#member_expression#Right AST#expression#Right . AUTO_ROTATION_UNSPECIFIED AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . Orientation AST#member_expression#Right AST#expression#Right . USER_ROTATION_PORTRAIT AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . Orientation AST#member_expression#Right AST#expression#Right . USER_ROTATION_LANDSCAPE AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . Orientation AST#member_expression#Right AST#expression#Right . USER_ROTATION_PORTRAIT_INVERTED AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . Orientation AST#member_expression#Right AST#expression#Right . USER_ROTATION_LANDSCAPE_INVERTED AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . Orientation AST#member_expression#Right AST#expression#Right . FOLLOW_DESKTOP AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function default_window_orientations(): window.Orientation[] { return [ window.Orientation.UNSPECIFIED, window.Orientation.PORTRAIT, window.Orientation.LANDSCAPE, window.Orientation.PORTRAIT_INVERTED, window.Orientation.LANDSCAPE_INVERTED, window.Orientation.AUTO_ROTATION, window.Orientation.AUTO_ROTATION_PORTRAIT, window.Orientation.AUTO_ROTATION_LANDSCAPE, window.Orientation.AUTO_ROTATION_RESTRICTED, window.Orientation.AUTO_ROTATION_PORTRAIT_RESTRICTED, window.Orientation.AUTO_ROTATION_LANDSCAPE_RESTRICTED, window.Orientation.LOCKED, window.Orientation.AUTO_ROTATION_UNSPECIFIED, window.Orientation.USER_ROTATION_PORTRAIT, window.Orientation.USER_ROTATION_LANDSCAPE, window.Orientation.USER_ROTATION_PORTRAIT_INVERTED, window.Orientation.USER_ROTATION_LANDSCAPE_INVERTED, window.Orientation.FOLLOW_DESKTOP ]; }
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/hosts/bunch_of_defaults.ets#L175-L196
c267f123fe93953d769e86a491fb7257337cb244
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_one.ets
arkts
resourceToString
[StartExclude prefetch_post_request_on_page_end_clear_cache]
function resourceToString(resource: Resource) { return getContext().resourceManager.getStringSync(resource); }
AST#function_declaration#Left function resourceToString AST#parameter_list#Left ( AST#parameter#Left resource : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#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 AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . resourceManager AST#member_expression#Right AST#expression#Right . getStringSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left resource AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
function resourceToString(resource: Resource) { return getContext().resourceManager.getStringSync(resource); }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_one.ets#L18-L20
f6206e530368d7103a1b5ca7f08123254ce28908
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/greetings/GreetingSendPage.ets
arkts
buildHeader
构建页面头部
@Builder buildHeader() { AppHeader({ title: `发送祝福给${this.contact?.name || ''}`, showBack: true, showAction: true, actionText: '预览', onAction: () => { this.showPreview = true; } }) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildHeader 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 AppHeader ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#template_literal#Left ` 发送祝福给 AST#template_substitution#Left $ { AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . contact AST#member_expression#Right 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#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left showBack : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left showAction : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left actionText : AST#expression#Left '预览' AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onAction : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showPreview AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#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 buildHeader() { AppHeader({ title: `发送祝福给${this.contact?.name || ''}`, showBack: true, showAction: true, actionText: '预览', onAction: () => { this.showPreview = true; } }) }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/greetings/GreetingSendPage.ets#L210-L221
78700f810b49f171f8c8003e1dfc9f4d943ba4b2
github
pangpang20/wavecast.git
d3da8a0009eb44a576a2b9d9d9fe6195a2577e32
entry/src/main/ets/pages/SettingsPage.ets
arkts
showLicenseInfo
显示开源许可信息
showLicenseInfo(): void { const buttons: ButtonOptions[] = [ new ButtonOptions('确定', '#007AFF') ]; UIUtils.showDialog(new DialogOptions( 'MIT License', 'MIT License\n\nCopyright (c) 2025 chen yunliang\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.', buttons )); }
AST#method_declaration#Left showLicenseInfo AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left 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#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ButtonOptions AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '确定' AST#expression#Right , AST#expression#Left '#007AFF' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left UIUtils AST#expression#Right . showDialog 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 DialogOptions AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'MIT License' AST#expression#Right , AST#expression#Left 'MIT License\n\nCopyright (c) 2025 chen yunliang\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.' AST#expression#Right , AST#expression#Left buttons 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#method_declaration#Right
showLicenseInfo(): void { const buttons: ButtonOptions[] = [ new ButtonOptions('确定', '#007AFF') ]; UIUtils.showDialog(new DialogOptions( 'MIT License', 'MIT License\n\nCopyright (c) 2025 chen yunliang\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.', buttons )); }
https://github.com/pangpang20/wavecast.git/blob/d3da8a0009eb44a576a2b9d9d9fe6195a2577e32/entry/src/main/ets/pages/SettingsPage.ets#L352-L361
e25d40de841e96d88a70a91c20190d5e56f251a9
github
ashcha0/line-inspection-terminal-frontend_arkts.git
c82616097e8a3b257b7b01e75b6b83ce428b518c
entry/src/main/ets/pages/TaskReviewView.ets
arkts
getFlawLevelColor
获取故障等级颜色
getFlawLevelColor(level: string): string { switch (level) { case '严重': return AppConstants.COLORS.DANGER; case '一般': return AppConstants.COLORS.WARNING; case '轻微': return AppConstants.COLORS.INFO; default: return AppConstants.COLORS.TEXT_REGULAR; }
AST#method_declaration#Left getFlawLevelColor AST#parameter_list#Left ( AST#parameter#Left level : 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#expression_statement#Left AST#expression#Left switch AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left ( AST#expression#Left level AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left '严重' AST#expression#Right AST#expression_statement#Right : AST#ERROR#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 AppConstants AST#expression#Right . COLORS AST#member_expression#Right AST#expression#Right . DANGER AST#member_expression#Right 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#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left : AST#ERROR#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppConstants AST#expression#Right . COLORS AST#member_expression#Right AST#expression#Right . WARNING AST#member_expression#Right 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#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left : AST#ERROR#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppConstants AST#expression#Right . COLORS AST#member_expression#Right AST#expression#Right . INFO AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left default AST#expression#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left return AST#ERROR#Left AppConstants AST#ERROR#Right . COLORS . TEXT_REGULAR AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
getFlawLevelColor(level: string): string { switch (level) { case '严重': return AppConstants.COLORS.DANGER; case '一般': return AppConstants.COLORS.WARNING; case '轻微': return AppConstants.COLORS.INFO; default: return AppConstants.COLORS.TEXT_REGULAR; }
https://github.com/ashcha0/line-inspection-terminal-frontend_arkts.git/blob/c82616097e8a3b257b7b01e75b6b83ce428b518c/entry/src/main/ets/pages/TaskReviewView.ets#L603-L613
c5920cc6fe6efec518747f27fcf992c8803efb45
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
ETSUI/SimpleCalculator/entry/src/main/ets/viewmodel/PressKeysItem.ets
arkts
Copyright (c) 2023 Huawei Device Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
export class PressKeysItem { flag: number; width: string; height: string; value: string; source?: Resource; constructor(flag: number, width: string, height: string, value: string, source?: Resource) { this.flag = flag; this.width = width; this.height = height; this.value = value; this.source = source; } }
AST#export_declaration#Left export AST#class_declaration#Left class PressKeysItem AST#class_body#Left { AST#property_declaration#Left flag : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left width : 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 height : 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 value : 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 source ? : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left flag : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left width : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left height : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left source ? : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . flag AST#member_expression#Right = AST#expression#Left flag 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 . width AST#member_expression#Right = AST#expression#Left width 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 . height AST#member_expression#Right = AST#expression#Left height 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 . 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#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . source AST#member_expression#Right = AST#expression#Left source 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 PressKeysItem { flag: number; width: string; height: string; value: string; source?: Resource; constructor(flag: number, width: string, height: string, value: string, source?: Resource) { this.flag = flag; this.width = width; this.height = height; this.value = value; this.source = source; } }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/ETSUI/SimpleCalculator/entry/src/main/ets/viewmodel/PressKeysItem.ets#L16-L30
4a04d41064217e45bccea12755b1f522dcb4d369
gitee
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto_dto/src/main/ets/crypto/encryption/AESSync.ets
arkts
encodeECB
加密-ECB模式 @param str 待加密的字符串 @param aesKey AES密钥 @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式 @param resultCoding 加密后数据的编码方式(hex/base64)-不传默认为base64 @returns
static encodeECB(str: string, aesKey: string, keyCoding: buffer.BufferEncoding, resultCoding: buffer.BufferEncoding = 'base64'): OutDTO<string> { return CryptoSyncUtil.encodeECB(str, aesKey, 'AES256', 'AES256|ECB|PKCS7', 256, keyCoding, resultCoding); }
AST#method_declaration#Left static encodeECB 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 aesKey : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left keyCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left resultCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'base64' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left OutDTO AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CryptoSyncUtil AST#expression#Right . encodeECB AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left aesKey AST#expression#Right , AST#expression#Left 'AES256' AST#expression#Right , AST#expression#Left 'AES256|ECB|PKCS7' AST#expression#Right , AST#expression#Left 256 AST#expression#Right , AST#expression#Left keyCoding AST#expression#Right , AST#expression#Left resultCoding AST#expression#Right ) AST#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 encodeECB(str: string, aesKey: string, keyCoding: buffer.BufferEncoding, resultCoding: buffer.BufferEncoding = 'base64'): OutDTO<string> { return CryptoSyncUtil.encodeECB(str, aesKey, 'AES256', 'AES256|ECB|PKCS7', 256, keyCoding, resultCoding); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto_dto/src/main/ets/crypto/encryption/AESSync.ets#L166-L169
ca534f87e0844c522835dea74f6c392cf2f210af
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/LocationUtil.ets
arkts
requestLocationPermissions
申请定位权限 @returns
static async requestLocationPermissions(): Promise<boolean> { let grant = await PermissionUtil.requestPermissions(['ohos.permission.LOCATION', 'ohos.permission.APPROXIMATELY_LOCATION']); if (!grant) { grant = await PermissionUtil.requestPermissionOnSetting(['ohos.permission.LOCATION', 'ohos.permission.APPROXIMATELY_LOCATION']); } return grant; }
AST#method_declaration#Left static async requestLocationPermissions AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left grant = 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 PermissionUtil 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 AST#array_literal#Left [ AST#expression#Left 'ohos.permission.LOCATION' AST#expression#Right , AST#expression#Left 'ohos.permission.APPROXIMATELY_LOCATION' 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#unary_expression#Left ! AST#expression#Left grant AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left grant = 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 PermissionUtil 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 AST#array_literal#Left [ AST#expression#Left 'ohos.permission.LOCATION' AST#expression#Right , AST#expression#Left 'ohos.permission.APPROXIMATELY_LOCATION' AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left grant AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static async requestLocationPermissions(): Promise<boolean> { let grant = await PermissionUtil.requestPermissions(['ohos.permission.LOCATION', 'ohos.permission.APPROXIMATELY_LOCATION']); if (!grant) { grant = await PermissionUtil.requestPermissionOnSetting(['ohos.permission.LOCATION', 'ohos.permission.APPROXIMATELY_LOCATION']); } return grant; }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/LocationUtil.ets#L45-L51
17f15f01d2fef5f6db1067c2c3e90d85e14dd282
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/BasicFeature/Security/KeyManager/entry/src/main/ets/client/LocalClient.ets
arkts
sendAesKeyToServer
发送AES密钥到服务端
async sendAesKeyToServer() { sendProcessMessage(`AES密钥进行加密...`, MessagePosition.Right); // 对AES密钥使用公钥进行加密 let encryptedAesKey: string = await rsaEncryption(this.aesKey, this.publicKey); sendProcessMessage(`加密成功,加密结果:${encryptedAesKey},开始发送到服务端...`, MessagePosition.Right); // 将加密后的AES密钥发送到服务端 await this.server.receiveKeyFromClient(encryptedAesKey); }
AST#method_declaration#Left async sendAesKeyToServer AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_custom_component_statement#Left sendProcessMessage ( AST#expression#Left AST#template_literal#Left ` AES密钥进行加密... ` AST#template_literal#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left MessagePosition AST#expression#Right . Right AST#member_expression#Right AST#expression#Right ) ; AST#ui_custom_component_statement#Right // 对AES密钥使用公钥进行加密 AST#expression_statement#Left AST#expression#Left let AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left encryptedAesKey AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left rsaEncryption AST#expression#Right AST#await_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . aesKey AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . publicKey AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#ui_custom_component_statement#Left sendProcessMessage ( AST#expression#Left AST#template_literal#Left ` 加密成功,加密结果: AST#template_substitution#Left $ { AST#expression#Left encryptedAesKey AST#expression#Right } AST#template_substitution#Right ,开始发送到服务端... ` AST#template_literal#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left MessagePosition AST#expression#Right . Right AST#member_expression#Right AST#expression#Right ) ; AST#ui_custom_component_statement#Right // 将加密后的AES密钥发送到服务端 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 . server AST#member_expression#Right AST#expression#Right . receiveKeyFromClient AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left encryptedAesKey AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
async sendAesKeyToServer() { sendProcessMessage(`AES密钥进行加密...`, MessagePosition.Right); let encryptedAesKey: string = await rsaEncryption(this.aesKey, this.publicKey); sendProcessMessage(`加密成功,加密结果:${encryptedAesKey},开始发送到服务端...`, MessagePosition.Right); await this.server.receiveKeyFromClient(encryptedAesKey); }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/BasicFeature/Security/KeyManager/entry/src/main/ets/client/LocalClient.ets#L103-L110
e07e73785f7d7e11ac27ead360cfaf0325146778
gitee
wcmzllx/axis-render
34a330085691968cf1c132095e5ce078aa7ee933
AxisRenderLibrary/src/main/ets/common/AxisRender.ets
arkts
bindDecoratorInvalidate
内部帮助函数:供 AxisRender 调用,绑定刷新回调 @internal 标记为内部使用
function bindDecoratorInvalidate(decorator: BaseAxisDecorator, callback: () => void) { decoratorInvalidateMap.set(decorator, callback); }
AST#function_declaration#Left function bindDecoratorInvalidate AST#parameter_list#Left ( AST#parameter#Left decorator : AST#type_annotation#Left AST#primary_type#Left BaseAxisDecorator 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_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#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left decoratorInvalidateMap AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left decorator 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#function_declaration#Right
function bindDecoratorInvalidate(decorator: BaseAxisDecorator, callback: () => void) { decoratorInvalidateMap.set(decorator, callback); }
https://github.com/wcmzllx/axis-render/blob/34a330085691968cf1c132095e5ce078aa7ee933/AxisRenderLibrary/src/main/ets/common/AxisRender.ets#L132-L134
f7306f79602b80e18afe5d966232953ce230e109
gitee
openharmony/arkui_ace_engine
30c7d1ee12fbedf0fabece54291d75897e2ad44f
examples/Select/entry/src/main/ets/pages/components/slider/sliderStyle.ets
arkts
SliderStyleBuilder
Copyright (c) 2025 Huawei Device Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
@Builder export function SliderStyleBuilder(name: string, param: Object) { SliderStyleExample() }
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function SliderStyleBuilder AST#parameter_list#Left ( AST#parameter#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left param : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left SliderStyleExample ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#decorated_export_declaration#Right
@Builder export function SliderStyleBuilder(name: string, param: Object) { SliderStyleExample() }
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/examples/Select/entry/src/main/ets/pages/components/slider/sliderStyle.ets#L16-L19
227fe9b21fe444634fd9f71e86738b141a757034
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/web/WebSearchService.ets
arkts
generateMockSearchResults
生成模拟搜索结果
private generateMockSearchResults(params: GiftSearchParams): SearchResult[] { const keyword = params.keyword.toLowerCase(); const results: SearchResult[] = []; // 生日相关礼物 if (keyword.includes('生日') || keyword.includes('birthday')) { results.push( { title: '定制生日蛋糕 - 创意个性化设计', description: '新鲜制作,可定制图案和文字,多种口味选择,生日必备', url: 'https://example.com/cake1', price: '¥88-368', imageUrl: 'https://example.com/images/cake1.jpg', shopName: '甜蜜时光蛋糕店', rating: 4.8 }, { title: '精美生日礼品盒套装', description: '包含精美包装、贺卡、小礼品,适合各年龄段', url: 'https://example.com/giftbox1', price: '¥68-188', imageUrl: 'https://example.com/images/giftbox1.jpg', shopName: '礼品之家', rating: 4.6 } ); } // 基于关键词生成更多结果 const templates: SearchResultTemplate[] = [ { title: `${params.keyword} - 热销推荐`, description: `精选${params.keyword},品质保证,用户好评`, price: '¥39-299', shopName: '品质商城', rating: 4.5 }, { title: `创意${params.keyword} - 个性定制`, description: `支持个性化定制的${params.keyword},独一无二的选择`, price: '¥99-499', shopName: '创意工坊', rating: 4.7 }, { title: `限时特惠 - ${params.keyword}套装`, description: `${params.keyword}优惠套装,现在购买享受特价`, price: '¥58-388', shopName: '特惠商城', rating: 4.4 } ]; templates.forEach((template, index) => { const newResult: SearchResult = { title: template.title, description: template.description, price: template.price, shopName: template.shopName, rating: template.rating, url: `https://example.com/product${index + 100}`, imageUrl: `https://example.com/images/product${index + 100}.jpg` }; results.push(newResult); }); // 应用价格筛选 if (params.priceRange) { return results.filter(result => { if (!result.price) return true; const priceMatch = result.price.match(/¥(\d+)/); if (priceMatch) { const price = parseInt(priceMatch[1]); return price >= params.priceRange!.min && price <= params.priceRange!.max; } return true; }); } return results.slice(0, 10); // 限制返回结果数量 }
AST#method_declaration#Left private generateMockSearchResults AST#parameter_list#Left ( AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left GiftSearchParams 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 SearchResult [ ] 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 keyword = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . keyword AST#member_expression#Right AST#expression#Right . toLowerCase AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left results : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left SearchResult [ ] 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#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left keyword AST#expression#Right . includes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '生日' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left keyword AST#expression#Right AST#binary_expression#Right AST#expression#Right . includes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'birthday' 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 results AST#expression#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 title AST#property_name#Right : AST#expression#Left '定制生日蛋糕 - 创意个性化设计' 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#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left 'https://example.com/cake1' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left price AST#property_name#Right : AST#expression#Left '¥88-368' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left imageUrl AST#property_name#Right : AST#expression#Left 'https://example.com/images/cake1.jpg' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left shopName AST#property_name#Right : AST#expression#Left '甜蜜时光蛋糕店' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left rating AST#property_name#Right : AST#expression#Left 4.8 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left '精美生日礼品盒套装' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left description AST#property_name#Right : AST#expression#Left '包含精美包装、贺卡、小礼品,适合各年龄段' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left 'https://example.com/giftbox1' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left price AST#property_name#Right : AST#expression#Left '¥68-188' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left imageUrl AST#property_name#Right : AST#expression#Left 'https://example.com/images/giftbox1.jpg' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left shopName AST#property_name#Right : AST#expression#Left '礼品之家' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left rating AST#property_name#Right : AST#expression#Left 4.6 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 基于关键词生成更多结果 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left templates : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left SearchResultTemplate [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . keyword AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right - 热销推荐 ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left description AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` 精选 AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . keyword AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ,品质保证,用户好评 ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left price AST#property_name#Right : AST#expression#Left '¥39-299' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left shopName AST#property_name#Right : AST#expression#Left '品质商城' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left rating AST#property_name#Right : AST#expression#Left 4.5 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` 创意 AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . keyword AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right - 个性定制 ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left description AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` 支持个性化定制的 AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . keyword AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ,独一无二的选择 ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left price AST#property_name#Right : AST#expression#Left '¥99-499' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left shopName AST#property_name#Right : AST#expression#Left '创意工坊' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left rating AST#property_name#Right : AST#expression#Left 4.7 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` 限时特惠 - AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . keyword AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right 套装 ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left description AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . keyword AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right 优惠套装,现在购买享受特价 ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left price AST#property_name#Right : AST#expression#Left '¥58-388' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left shopName AST#property_name#Right : AST#expression#Left '特惠商城' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left rating AST#property_name#Right : AST#expression#Left 4.4 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left templates 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 template 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 newResult : AST#type_annotation#Left AST#primary_type#Left SearchResult AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left template AST#expression#Right . title AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left description AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left template AST#expression#Right . description 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 template AST#expression#Right . price AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left shopName AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left template AST#expression#Right . shopName AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left rating AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left template AST#expression#Right . rating AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` https://example.com/product AST#template_substitution#Left $ { AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right + AST#expression#Left 100 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#property_assignment#Left AST#property_name#Left imageUrl AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` https://example.com/images/product AST#template_substitution#Left $ { AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right + AST#expression#Left 100 AST#expression#Right AST#binary_expression#Right AST#expression#Right } AST#template_substitution#Right .jpg ` 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 results AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left newResult AST#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#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . priceRange AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left results AST#expression#Right . filter 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#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left result AST#expression#Right AST#unary_expression#Right AST#expression#Right . price AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left priceMatch = 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 result AST#expression#Right . price AST#member_expression#Right AST#expression#Right . match AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#argument_list#Right AST#call_expression#Right AST#expression#Right / AST#ERROR#Left ¥ AST#ERROR#Right AST#expression#Left AST#parenthesized_expression#Left ( AST#ERROR#Left \d AST#ERROR#Right AST#expression#Left AST#unary_expression#Left + AST#expression#Left AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right AST#ERROR#Left / ) AST#ERROR#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left priceMatch AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left price = AST#expression#Left AST#call_expression#Left AST#expression#Left parseInt AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left priceMatch AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left price AST#expression#Right >= AST#expression#Left params AST#expression#Right AST#binary_expression#Right AST#expression#Right . priceRange AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . min AST#member_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left price AST#expression#Right <= AST#expression#Left params AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . priceRange AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . max 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#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#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#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 results 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 10 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right // 限制返回结果数量 } AST#block_statement#Right AST#method_declaration#Right
private generateMockSearchResults(params: GiftSearchParams): SearchResult[] { const keyword = params.keyword.toLowerCase(); const results: SearchResult[] = []; if (keyword.includes('生日') || keyword.includes('birthday')) { results.push( { title: '定制生日蛋糕 - 创意个性化设计', description: '新鲜制作,可定制图案和文字,多种口味选择,生日必备', url: 'https://example.com/cake1', price: '¥88-368', imageUrl: 'https://example.com/images/cake1.jpg', shopName: '甜蜜时光蛋糕店', rating: 4.8 }, { title: '精美生日礼品盒套装', description: '包含精美包装、贺卡、小礼品,适合各年龄段', url: 'https://example.com/giftbox1', price: '¥68-188', imageUrl: 'https://example.com/images/giftbox1.jpg', shopName: '礼品之家', rating: 4.6 } ); } const templates: SearchResultTemplate[] = [ { title: `${params.keyword} - 热销推荐`, description: `精选${params.keyword},品质保证,用户好评`, price: '¥39-299', shopName: '品质商城', rating: 4.5 }, { title: `创意${params.keyword} - 个性定制`, description: `支持个性化定制的${params.keyword},独一无二的选择`, price: '¥99-499', shopName: '创意工坊', rating: 4.7 }, { title: `限时特惠 - ${params.keyword}套装`, description: `${params.keyword}优惠套装,现在购买享受特价`, price: '¥58-388', shopName: '特惠商城', rating: 4.4 } ]; templates.forEach((template, index) => { const newResult: SearchResult = { title: template.title, description: template.description, price: template.price, shopName: template.shopName, rating: template.rating, url: `https://example.com/product${index + 100}`, imageUrl: `https://example.com/images/product${index + 100}.jpg` }; results.push(newResult); }); if (params.priceRange) { return results.filter(result => { if (!result.price) return true; const priceMatch = result.price.match(/¥(\d+)/); if (priceMatch) { const price = parseInt(priceMatch[1]); return price >= params.priceRange!.min && price <= params.priceRange!.max; } return true; }); } return results.slice(0, 10); }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/web/WebSearchService.ets#L160-L240
1a7afafc9a27be61f0dd0818f6b4cc01f388ee87
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/game/VirtualEconomyService.ets
arkts
spendCurrency
消费货币
async spendCurrency( currencyType: CurrencyType, amount: number, reason: string, metadata: Record<string, any> = {} ): Promise<Transaction> { try { if (!this.userWallet || amount <= 0) { throw new Error('Invalid wallet or amount'); } const currentBalance = this.getCurrencyBalance(currencyType); if (currentBalance < amount) { throw new Error('Insufficient balance'); } const newBalance = currentBalance - amount; this.userWallet.balances.set(currencyType, newBalance); // 更新总支出 const totalSpent = this.userWallet.totalSpent.get(currencyType) || 0; this.userWallet.totalSpent.set(currencyType, totalSpent + amount); const transaction: Transaction = { id: `tx_${Date.now()}_spend`, userId: this.userWallet.userId, type: TransactionType.SPEND, currencyType, amount: -amount, balanceBefore: currentBalance, balanceAfter: newBalance, reason, metadata, timestamp: new Date().toISOString() }; this.userWallet.transactions.push(transaction); await this.saveUserWallet(); hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Spent ${amount} ${currencyType} from wallet. Reason: ${reason}`); return transaction; } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to spend currency: ${error}`); throw error; } }
AST#method_declaration#Left async spendCurrency AST#parameter_list#Left ( AST#parameter#Left currencyType : AST#type_annotation#Left AST#primary_type#Left CurrencyType AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left amount : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left reason : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left metadata : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left any AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Transaction 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . userWallet AST#member_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left amount 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#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 'Invalid wallet or amount' 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 currentBalance = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getCurrencyBalance AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left currencyType 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 currentBalance AST#expression#Right < AST#expression#Left amount AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#throw_statement#Left throw AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Insufficient balance' 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 newBalance = AST#expression#Left AST#binary_expression#Left AST#expression#Left currentBalance AST#expression#Right - AST#expression#Left amount 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 AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . userWallet AST#member_expression#Right AST#expression#Right . balances AST#member_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left currencyType AST#expression#Right , AST#expression#Left newBalance 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 totalSpent = 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#member_expression#Left AST#expression#Left this AST#expression#Right . userWallet AST#member_expression#Right AST#expression#Right . totalSpent AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left currencyType AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right 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#member_expression#Left AST#expression#Left this AST#expression#Right . userWallet AST#member_expression#Right AST#expression#Right . totalSpent AST#member_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left currencyType AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left totalSpent AST#expression#Right + AST#expression#Left amount AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left transaction : AST#type_annotation#Left AST#primary_type#Left Transaction AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left id AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` tx_ AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Date AST#expression#Right . now AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right _spend ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left userId 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 . userWallet AST#member_expression#Right AST#expression#Right . userId AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left TransactionType AST#expression#Right . SPEND AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left currencyType AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left amount AST#property_name#Right : AST#expression#Left AST#unary_expression#Left - AST#expression#Left amount AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left balanceBefore AST#property_name#Right : AST#expression#Left currentBalance AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left balanceAfter AST#property_name#Right : AST#expression#Left newBalance AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left reason AST#property_assignment#Right , AST#property_assignment#Left metadata AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left timestamp AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . toISOString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . userWallet AST#member_expression#Right AST#expression#Right . transactions AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left transaction 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 . saveUserWallet AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Spent AST#template_substitution#Left $ { AST#expression#Left amount AST#expression#Right } AST#template_substitution#Right AST#template_substitution#Left $ { AST#expression#Left currencyType AST#expression#Right } AST#template_substitution#Right from wallet. Reason: AST#template_substitution#Left $ { AST#expression#Left reason 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 transaction AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to spend currency: AST#template_substitution#Left $ { AST#expression#Left error AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#throw_statement#Left throw AST#expression#Left error AST#expression#Right ; AST#throw_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async spendCurrency( currencyType: CurrencyType, amount: number, reason: string, metadata: Record<string, any> = {} ): Promise<Transaction> { try { if (!this.userWallet || amount <= 0) { throw new Error('Invalid wallet or amount'); } const currentBalance = this.getCurrencyBalance(currencyType); if (currentBalance < amount) { throw new Error('Insufficient balance'); } const newBalance = currentBalance - amount; this.userWallet.balances.set(currencyType, newBalance); const totalSpent = this.userWallet.totalSpent.get(currencyType) || 0; this.userWallet.totalSpent.set(currencyType, totalSpent + amount); const transaction: Transaction = { id: `tx_${Date.now()}_spend`, userId: this.userWallet.userId, type: TransactionType.SPEND, currencyType, amount: -amount, balanceBefore: currentBalance, balanceAfter: newBalance, reason, metadata, timestamp: new Date().toISOString() }; this.userWallet.transactions.push(transaction); await this.saveUserWallet(); hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Spent ${amount} ${currencyType} from wallet. Reason: ${reason}`); return transaction; } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to spend currency: ${error}`); throw error; } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/game/VirtualEconomyService.ets#L317-L366
7ed9b7e7da9b492ad211a03d3f1ddb4fa7c30872
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/components/Sounds/Cloud/CSoundDbAccessor/CSoundDbAccessor.ets
arkts
MARK: - 声音数据库访问类
export class CSoundDbAccessor { // 单例实例 private static instance: CSoundDbAccessor; // 数据库访问器 private db: DBAccessor | null = null; // 私有构造函数 private constructor() { // 创建目录(假设dMyDataFolderPath已定义) createFolderIfNeeds(dAppCloudSoundFolderPath); // 初始化数据库访问器 const sqlitePath = new CDbPath(CDBName.sounds).sqlite this.db = new DBAccessor(sqlitePath, null, false); this.createDbsIfNeeds(); } // 获取单例实例 public static get shared(): CSoundDbAccessor { if (!CSoundDbAccessor.instance) { CSoundDbAccessor.instance = new CSoundDbAccessor(); } return CSoundDbAccessor.instance; } // MARK: - 数据库初始化 private createDbsIfNeeds(): void { if (!this.db) return; // 创建声音表 const sql = `CREATE TABLE IF NOT EXISTS "${Tables.CSound.name}" ( "${Tables.CSound.Col.idxx}" INTEGER PRIMARY KEY AUTOINCREMENT, "${Tables.CSound.Col.lang}" TEXT, "${Tables.CSound.Col.text}" TEXT, "${Tables.CSound.Col.data}" BLOB )`; // 执行创建表语句 this.db.updateDb(sql); } // MARK: - 插入操作 async insertSound(sound: CDBSound): Promise<void> { if (!this.db || !sound.lang || !sound.text || !sound.data) return; const sql = `INSERT INTO ${Tables.CSound.name} ( ${Tables.CSound.Col.lang}, ${Tables.CSound.Col.text}, ${Tables.CSound.Col.data} ) VALUES(?, ?, ?)`; // 假设StringEncoder.encodeAndAddSalt已经实现 const encodedLang = StringEncoder.encodeAndAddSalt(sound.lang); const encodedText = StringEncoder.encodeAndAddSalt(sound.text); await this.db.updateDb(sql, [encodedLang, encodedText, sound.data]); } // MARK: - 查询操作 async getById(idxx: number): Promise<CDBSound | null> { if (!this.db) return null; const sql = `SELECT * FROM ${Tables.CSound.name} WHERE ${Tables.CSound.Col.idxx} = ?`; return await this.db.getData(sql, [idxx], rs => this.createCSoundFromRs(rs)); } async getByLangAndText(lang: string, text: string): Promise<CDBSound | null> { if (!this.db) return null; const sql = `SELECT * FROM ${Tables.CSound.name} WHERE SUBSTR(${Tables.CSound.Col.lang}, ${DB.salt} + 1, LENGTH(${Tables.CSound.Col.lang}) - ${DB.salt}) = ? AND SUBSTR(${Tables.CSound.Col.text}, ${DB.salt} + 1, LENGTH(${Tables.CSound.Col.text}) - ${DB.salt}) = ?`; const langBase64 = StringEncoder.encodedToBase64(lang); const textBase64 = StringEncoder.encodedToBase64(text); return await this.db.getData(sql, [langBase64, textBase64], rs => this.createCSoundFromRs(rs)); } // MARK: - 删除操作 async deleteById(idxx: number): Promise<void> { if (!this.db) return; const sql = `DELETE FROM ${Tables.CSound.name} WHERE ${Tables.CSound.Col.idxx} = ?`; await this.db.updateDb(sql, [idxx]); } async deleteByLangAndText(lang: string, text: string): Promise<void> { if (!this.db) return; const sql = `DELETE FROM ${Tables.CSound.name} WHERE SUBSTR(${Tables.CSound.Col.lang}, ${DB.salt} + 1, LENGTH(${Tables.CSound.Col.lang}) - ${DB.salt}) = ? AND SUBSTR(${Tables.CSound.Col.text}, ${DB.salt} + 1, LENGTH(${Tables.CSound.Col.text}) - ${DB.salt}) = ?`; const langBase64 = StringEncoder.encodedToBase64(lang); const textBase64 = StringEncoder.encodedToBase64(text); await this.db.updateDb(sql, [langBase64, textBase64]); } async deleteAll(): Promise<void> { if (!this.db) return; const sql = `DELETE FROM ${Tables.CSound.name}`; await this.db.updateDb(sql); } // MARK: - 结果集转换 private createCSoundFromRs(rs: relationalStore.ResultSet): CDBSound { const sound = new CDBSound(); sound.idxx = rs.getLong(rs.getColumnIndex(Tables.CSound.Col.idxx)); sound.lang = ResultSetTool.decodeString(rs, Tables.CSound.Col.lang); sound.text = ResultSetTool.decodeString(rs, Tables.CSound.Col.text); sound.data = rs.getBlob(rs.getColumnIndex(Tables.CSound.Col.data)); return sound; } }
AST#export_declaration#Left export AST#class_declaration#Left class CSoundDbAccessor AST#class_body#Left { // 单例实例 AST#property_declaration#Left private static instance : AST#type_annotation#Left AST#primary_type#Left CSoundDbAccessor AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 数据库访问器 AST#property_declaration#Left private db : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left DBAccessor AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right // 私有构造函数 AST#constructor_declaration#Left private constructor AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { // 创建目录(假设dMyDataFolderPath已定义) AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left createFolderIfNeeds AST#expression#Right AST#argument_list#Left ( AST#expression#Left dAppCloudSoundFolderPath 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 sqlitePath = AST#expression#Left AST#assignment_expression#Left AST#member_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 CDbPath AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CDBName AST#expression#Right . sounds AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . sqlite AST#member_expression#Right AST#expression#Right AST#ERROR#Left this AST#ERROR#Right . db AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left DBAccessor AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sqlitePath AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right , AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_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 this AST#expression#Right . createDbsIfNeeds AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right // 获取单例实例 AST#method_declaration#Left public static get AST#ERROR#Left shared AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left CSoundDbAccessor AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left CSoundDbAccessor AST#expression#Right AST#unary_expression#Right AST#expression#Right . instance AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left CSoundDbAccessor AST#expression#Right . instance AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left CSoundDbAccessor AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CSoundDbAccessor AST#expression#Right . instance AST#member_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right // MARK: - 数据库初始化 AST#method_declaration#Left private createDbsIfNeeds AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . db AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right // 创建声音表 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left sql = AST#expression#Left AST#template_literal#Left ` CREATE TABLE IF NOT EXISTS " AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . name 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 AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . idxx AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " INTEGER PRIMARY KEY AUTOINCREMENT, " 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 Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . lang AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " TEXT, " 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 Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . text AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " TEXT, " 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 Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " BLOB ) ` 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . db AST#member_expression#Right AST#expression#Right . updateDb AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sql AST#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 // MARK: - 插入操作 AST#method_declaration#Left async insertSound AST#parameter_list#Left ( AST#parameter#Left sound : AST#type_annotation#Left AST#primary_type#Left CDBSound AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . db AST#member_expression#Right AST#expression#Right || AST#expression#Left AST#unary_expression#Left ! AST#expression#Left sound AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . lang AST#member_expression#Right AST#expression#Right || AST#expression#Left AST#unary_expression#Left ! AST#expression#Left sound AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . text AST#member_expression#Right AST#expression#Right || AST#expression#Left AST#unary_expression#Left ! AST#expression#Left sound 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#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left sql = AST#expression#Left AST#template_literal#Left ` INSERT INTO AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . name 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 AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . lang 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 AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . text 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 AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ) VALUES(?, ?, ?) ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 假设StringEncoder.encodeAndAddSalt已经实现 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left encodedLang = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StringEncoder AST#expression#Right . encodeAndAddSalt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left sound AST#expression#Right . lang 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 encodedText = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StringEncoder AST#expression#Right . encodeAndAddSalt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left sound AST#expression#Right . text 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#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 . db AST#member_expression#Right AST#expression#Right . updateDb AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sql AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left encodedLang AST#expression#Right , AST#expression#Left encodedText AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left sound AST#expression#Right . data 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#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // MARK: - 查询操作 AST#method_declaration#Left async getById AST#parameter_list#Left ( AST#parameter#Left idxx : 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#union_type#Left AST#primary_type#Left CDBSound AST#primary_type#Right | AST#primary_type#Left null 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#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 . db AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left sql = AST#expression#Left AST#template_literal#Left ` SELECT * FROM AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right WHERE 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 Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . idxx AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right = ? ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#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 AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . db AST#member_expression#Right AST#expression#Right . getData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sql AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left idxx AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left rs => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . createCSoundFromRs AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left rs 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 AST#method_declaration#Left async getByLangAndText AST#parameter_list#Left ( AST#parameter#Left lang : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , 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#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 CDBSound AST#primary_type#Right | AST#primary_type#Left null 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#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 . db AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left sql = AST#expression#Left AST#template_literal#Left ` SELECT * FROM AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right WHERE SUBSTR( 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 Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . lang 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 DB AST#expression#Right . salt AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right + 1, LENGTH( 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 Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . lang 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 DB AST#expression#Right . salt AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ) = ? AND SUBSTR( 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 Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . text 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 DB AST#expression#Right . salt AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right + 1, LENGTH( 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 Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . text 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 DB AST#expression#Right . salt AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ) = ? ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left langBase64 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StringEncoder AST#expression#Right . encodedToBase64 AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left lang 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 textBase64 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StringEncoder AST#expression#Right . encodedToBase64 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#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 AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . db AST#member_expression#Right AST#expression#Right . getData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sql AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left langBase64 AST#expression#Right , AST#expression#Left textBase64 AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left rs => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . createCSoundFromRs AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left rs 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 // MARK: - 删除操作 AST#method_declaration#Left async deleteById AST#parameter_list#Left ( AST#parameter#Left idxx : 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#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 . db AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left sql = AST#expression#Left AST#template_literal#Left ` DELETE FROM AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right WHERE 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 Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . idxx AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right = ? ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#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 . db AST#member_expression#Right AST#expression#Right . updateDb AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sql AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left idxx AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left async deleteByLangAndText AST#parameter_list#Left ( AST#parameter#Left lang : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , 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#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 . db AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left sql = AST#expression#Left AST#template_literal#Left ` DELETE FROM AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right WHERE SUBSTR( 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 Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . lang 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 DB AST#expression#Right . salt AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right + 1, LENGTH( 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 Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . lang 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 DB AST#expression#Right . salt AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ) = ? AND SUBSTR( 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 Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . text 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 DB AST#expression#Right . salt AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right + 1, LENGTH( 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 Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . text 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 DB AST#expression#Right . salt AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ) = ? ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left langBase64 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StringEncoder AST#expression#Right . encodedToBase64 AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left lang 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 textBase64 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StringEncoder AST#expression#Right . encodedToBase64 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . db AST#member_expression#Right AST#expression#Right . updateDb AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sql AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left langBase64 AST#expression#Right , AST#expression#Left textBase64 AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left async deleteAll AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . db AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left sql = AST#expression#Left AST#template_literal#Left ` DELETE FROM AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#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 . db AST#member_expression#Right AST#expression#Right . updateDb AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sql AST#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 // MARK: - 结果集转换 AST#method_declaration#Left private createCSoundFromRs AST#parameter_list#Left ( AST#parameter#Left rs : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left relationalStore . ResultSet AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left CDBSound AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left sound = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left CDBSound AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left sound AST#expression#Right . idxx AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left rs AST#expression#Right . getLong 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 rs 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 AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . idxx AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left sound AST#expression#Right . lang AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ResultSetTool AST#expression#Right . decodeString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left rs AST#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 Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . lang AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left sound AST#expression#Right . text AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ResultSetTool AST#expression#Right . decodeString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left rs AST#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 Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . text AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 sound AST#expression#Right . data AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left rs AST#expression#Right . getBlob 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 rs 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 AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#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 sound AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class CSoundDbAccessor { private static instance: CSoundDbAccessor; private db: DBAccessor | null = null; private constructor() { createFolderIfNeeds(dAppCloudSoundFolderPath); const sqlitePath = new CDbPath(CDBName.sounds).sqlite this.db = new DBAccessor(sqlitePath, null, false); this.createDbsIfNeeds(); } public static get shared(): CSoundDbAccessor { if (!CSoundDbAccessor.instance) { CSoundDbAccessor.instance = new CSoundDbAccessor(); } return CSoundDbAccessor.instance; } private createDbsIfNeeds(): void { if (!this.db) return; const sql = `CREATE TABLE IF NOT EXISTS "${Tables.CSound.name}" ( "${Tables.CSound.Col.idxx}" INTEGER PRIMARY KEY AUTOINCREMENT, "${Tables.CSound.Col.lang}" TEXT, "${Tables.CSound.Col.text}" TEXT, "${Tables.CSound.Col.data}" BLOB )`; this.db.updateDb(sql); } async insertSound(sound: CDBSound): Promise<void> { if (!this.db || !sound.lang || !sound.text || !sound.data) return; const sql = `INSERT INTO ${Tables.CSound.name} ( ${Tables.CSound.Col.lang}, ${Tables.CSound.Col.text}, ${Tables.CSound.Col.data} ) VALUES(?, ?, ?)`; const encodedLang = StringEncoder.encodeAndAddSalt(sound.lang); const encodedText = StringEncoder.encodeAndAddSalt(sound.text); await this.db.updateDb(sql, [encodedLang, encodedText, sound.data]); } async getById(idxx: number): Promise<CDBSound | null> { if (!this.db) return null; const sql = `SELECT * FROM ${Tables.CSound.name} WHERE ${Tables.CSound.Col.idxx} = ?`; return await this.db.getData(sql, [idxx], rs => this.createCSoundFromRs(rs)); } async getByLangAndText(lang: string, text: string): Promise<CDBSound | null> { if (!this.db) return null; const sql = `SELECT * FROM ${Tables.CSound.name} WHERE SUBSTR(${Tables.CSound.Col.lang}, ${DB.salt} + 1, LENGTH(${Tables.CSound.Col.lang}) - ${DB.salt}) = ? AND SUBSTR(${Tables.CSound.Col.text}, ${DB.salt} + 1, LENGTH(${Tables.CSound.Col.text}) - ${DB.salt}) = ?`; const langBase64 = StringEncoder.encodedToBase64(lang); const textBase64 = StringEncoder.encodedToBase64(text); return await this.db.getData(sql, [langBase64, textBase64], rs => this.createCSoundFromRs(rs)); } async deleteById(idxx: number): Promise<void> { if (!this.db) return; const sql = `DELETE FROM ${Tables.CSound.name} WHERE ${Tables.CSound.Col.idxx} = ?`; await this.db.updateDb(sql, [idxx]); } async deleteByLangAndText(lang: string, text: string): Promise<void> { if (!this.db) return; const sql = `DELETE FROM ${Tables.CSound.name} WHERE SUBSTR(${Tables.CSound.Col.lang}, ${DB.salt} + 1, LENGTH(${Tables.CSound.Col.lang}) - ${DB.salt}) = ? AND SUBSTR(${Tables.CSound.Col.text}, ${DB.salt} + 1, LENGTH(${Tables.CSound.Col.text}) - ${DB.salt}) = ?`; const langBase64 = StringEncoder.encodedToBase64(lang); const textBase64 = StringEncoder.encodedToBase64(text); await this.db.updateDb(sql, [langBase64, textBase64]); } async deleteAll(): Promise<void> { if (!this.db) return; const sql = `DELETE FROM ${Tables.CSound.name}`; await this.db.updateDb(sql); } private createCSoundFromRs(rs: relationalStore.ResultSet): CDBSound { const sound = new CDBSound(); sound.idxx = rs.getLong(rs.getColumnIndex(Tables.CSound.Col.idxx)); sound.lang = ResultSetTool.decodeString(rs, Tables.CSound.Col.lang); sound.text = ResultSetTool.decodeString(rs, Tables.CSound.Col.text); sound.data = rs.getBlob(rs.getColumnIndex(Tables.CSound.Col.data)); return sound; } }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/components/Sounds/Cloud/CSoundDbAccessor/CSoundDbAccessor.ets#L26-L147
eae4a160d32512861dc880516f3e15fd25b28321
github
vhall/VHLive_SDK_Harmony
29c820e5301e17ae01bc6bdcc393a4437b518e7c
watchKit/src/main/ets/utils/PermissionUtil.ets
arkts
requestPermissionOnSetting
二次向用户申请授权(单个权限 或 读写权限组,建议使用该方法)。 @param permissions 需要授权的权限集合 @returns true表示授权成功继续业务操作,false表示用户拒绝授权
static async requestPermissionOnSetting(permissions: Permissions | Array<Permissions>): Promise<boolean> { const atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); const context: Context = getContext() as common.UIAbilityContext; //requestPermissionOnSetting会判断权限的授权状态来决定是否唤起弹窗 let grantStatus = await atManager.requestPermissionOnSetting(context, Array.isArray(permissions) ? [...permissions] : [permissions]); let result: boolean = PermissionUtil.getGrantSuccess(grantStatus); //鉴权结果 return result; }
AST#method_declaration#Left static async requestPermissionOnSetting AST#parameter_list#Left ( AST#parameter#Left permissions : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Permissions AST#primary_type#Right | AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Permissions AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#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 atManager : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left abilityAccessCtrl . AtManager AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left abilityAccessCtrl AST#expression#Right . createAtManager AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left context : AST#type_annotation#Left AST#primary_type#Left Context AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //requestPermissionOnSetting会判断权限的授权状态来决定是否唤起弹窗 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left grantStatus = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left atManager AST#expression#Right AST#await_expression#Right AST#expression#Right . requestPermissionOnSetting AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left AST#conditional_expression#Left 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 permissions AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ? AST#expression#Left AST#array_literal#Left [ ... AST#expression#Left permissions AST#expression#Right ] AST#array_literal#Right AST#expression#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left permissions AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left result : 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 PermissionUtil AST#expression#Right . getGrantSuccess AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left grantStatus AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //鉴权结果 AST#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static async requestPermissionOnSetting(permissions: Permissions | Array<Permissions>): Promise<boolean> { const atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); const context: Context = getContext() as common.UIAbilityContext; let grantStatus = await atManager.requestPermissionOnSetting(context, Array.isArray(permissions) ? [...permissions] : [permissions]); let result: boolean = PermissionUtil.getGrantSuccess(grantStatus); return result; }
https://github.com/vhall/VHLive_SDK_Harmony/blob/29c820e5301e17ae01bc6bdcc393a4437b518e7c/watchKit/src/main/ets/utils/PermissionUtil.ets#L101-L109
61c07b2e26e8d508775e7aa035f94a37abb259fa
gitee
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Data/FirstStartDemo/entry/src/main/ets/pages/AdvertisingPage.ets
arkts
jumpToAppHomePage
Jump to app home page.
jumpToAppHomePage(): void { router.pushUrl({ url: CommonConstants.APP_HOME_PAGE_URL }).catch((error: Error) => { Logger.error(CommonConstants.ADVERTISING_PAGE_TAG, 'AdvertisingPage pushUrl error ' + JSON.stringify(error)); }); }
AST#method_declaration#Left jumpToAppHomePage AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left router AST#expression#Right . pushUrl AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . APP_HOME_PAGE_URL AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . ADVERTISING_PAGE_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'AdvertisingPage pushUrl error ' AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
jumpToAppHomePage(): void { router.pushUrl({ url: CommonConstants.APP_HOME_PAGE_URL }).catch((error: Error) => { Logger.error(CommonConstants.ADVERTISING_PAGE_TAG, 'AdvertisingPage pushUrl error ' + JSON.stringify(error)); }); }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Data/FirstStartDemo/entry/src/main/ets/pages/AdvertisingPage.ets#L47-L53
79b51c02e3031be3461744c4b324ffffc4ae8449
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/llm/LLMService.ets
arkts
initialize
初始化配置
initialize(config: LLMConfig): void { this.config = config; this.status = { configured: true, provider: config.provider, errorCount: 0 }; hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `LLM service initialized with provider: ${config.provider}`); }
AST#method_declaration#Left initialize AST#parameter_list#Left ( AST#parameter#Left config : AST#type_annotation#Left AST#primary_type#Left LLMConfig 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 . config AST#member_expression#Right = AST#expression#Left config 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 . status AST#member_expression#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left configured 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 provider AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . provider 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 0 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` LLM service initialized with provider: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . provider 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#builder_function_body#Right AST#method_declaration#Right
initialize(config: LLMConfig): void { this.config = config; this.status = { configured: true, provider: config.provider, errorCount: 0 }; hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `LLM service initialized with provider: ${config.provider}`); }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/llm/LLMService.ets#L250-L258
fdf7382a796838d53f5115fcfce5ffc2e62f44e8
github
harmonyos-dev/arkui-codelabs.git
3eb8e934fb7e2caa6bf402d5736de45d7ef86f06
007-shared_styles/entry/src/main/ets/pages/Index.ets
arkts
makeItFuckingBIG
@Styles 不能有参数 See: https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V2/arkts-style-0000001473856690-V2
@Styles function makeItFuckingBIG() { .scale({ x: 2, y: 2, z: 2, }) }
AST#decorated_function_declaration#Left AST#decorator#Left @ Styles AST#decorator#Right function makeItFuckingBIG AST#parameter_list#Left ( ) AST#parameter_list#Right AST#extend_function_body#Left { AST#modifier_chain_expression#Left . scale ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left 2 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left 2 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left z 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#extend_function_body#Right AST#decorated_function_declaration#Right
@Styles function makeItFuckingBIG() { .scale({ x: 2, y: 2, z: 2, }) }
https://github.com/harmonyos-dev/arkui-codelabs.git/blob/3eb8e934fb7e2caa6bf402d5736de45d7ef86f06/007-shared_styles/entry/src/main/ets/pages/Index.ets#L47-L53
13d12c3208a1a00287d861dc11b93781d1c47f6c
github
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/data/LineDataSet.ets
arkts
setCircleHoleColor
Sets the color of the inner circle of the line-circles. @param color
public setCircleHoleColor(color: number): void { this.mCircleHoleColor = color; }
AST#method_declaration#Left public setCircleHoleColor AST#parameter_list#Left ( AST#parameter#Left color : 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 . mCircleHoleColor AST#member_expression#Right = AST#expression#Left color AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
public setCircleHoleColor(color: number): void { this.mCircleHoleColor = color; }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/data/LineDataSet.ets#L332-L334
b358ac7c80b702a0d6edb84b3fc7361f066dae90
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/toolbox/src/main/ets/model/LongClickListener.ets
arkts
长按监听器
export interface LongClickListener { /** * 长按开始回调 * @param {GestureEvent} event - 手势事件 * @param {boolean} isDisable - 是否禁用悬浮球标志 */ onAction: (event: GestureEvent, isDisable: boolean) => void; /** * 长按结束回调 * @param {GestureEvent} event - 手势事件 * @param {boolean} isDisable - 是否禁用悬浮球标志 */ onActionEnd: (event: GestureEvent, isDisable: boolean) => void; /** * 长按取消回调 * @param {boolean} isDisable - 是否禁用悬浮球标志 */ onActionCancel: (isDisable: boolean) => void; }
AST#export_declaration#Left export AST#interface_declaration#Left interface LongClickListener AST#object_type#Left { /** * 长按开始回调 * @param {GestureEvent} event - 手势事件 * @param {boolean} isDisable - 是否禁用悬浮球标志 */ AST#type_member#Left onAction : AST#type_annotation#Left AST#function_type#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#Left isDisable : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * 长按结束回调 * @param {GestureEvent} event - 手势事件 * @param {boolean} isDisable - 是否禁用悬浮球标志 */ AST#type_member#Left onActionEnd : AST#type_annotation#Left AST#function_type#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#Left isDisable : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * 长按取消回调 * @param {boolean} isDisable - 是否禁用悬浮球标志 */ AST#type_member#Left onActionCancel : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left isDisable : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface LongClickListener { onAction: (event: GestureEvent, isDisable: boolean) => void; onActionEnd: (event: GestureEvent, isDisable: boolean) => void; onActionCancel: (isDisable: boolean) => void; }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/toolbox/src/main/ets/model/LongClickListener.ets#L20-L38
afb2bfb0e367420efb0d572e77b0e2ce30f5ea95
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/cuberotateanimation/src/main/ets/model/DataModel.ets
arkts
定义Tab标签项的数据类型。 每个标签项包含一个未选中状态的图标 (icon)、一个选中状态的图标 (selectedIcon) 和一个标题 (title)。
export interface MyTabItem { icon: Resource selectedIcon: Resource title: ResourceStr }
AST#export_declaration#Left export AST#interface_declaration#Left interface MyTabItem AST#object_type#Left { AST#type_member#Left icon : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right AST#type_member#Left selectedIcon : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right AST#type_member#Left title : AST#type_annotation#Left AST#primary_type#Left ResourceStr 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 MyTabItem { icon: Resource selectedIcon: Resource title: ResourceStr }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/cuberotateanimation/src/main/ets/model/DataModel.ets#L69-L73
5b5deaa7a641c778174340cb7fdfb5be5205bf20
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/editaddress/src/main/ets/view/EditAddressView.ets
arkts
loadRegion
从文件中读取省市区json数据
async loadRegion(): Promise<void> { try { // 通过getRawFileContent()获取resources/rawfile目录下对应的文件内容,得到一个字节数组 getContext(this).resourceManager.getRawFileContent(this.fileName, (error: BusinessError, value: Uint8Array) => { let rawFile = value; let textDecoder = util.TextDecoder.create('utf-8', { ignoreBOM: true }); let retStr = textDecoder.decodeToString(rawFile, { stream: false }); // 再用@ohos.util (util工具函数)的TextDecoder给它解析出来 this.cascade = JSON.parse(retStr); }) } catch (error) { let code = (error as BusinessError).code; let message = (error as BusinessError).message; console.error(`callback getRawFileContent failed, error code: ${code}, message: ${message}.`); } }
AST#method_declaration#Left async loadRegion AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 通过getRawFileContent()获取resources/rawfile目录下对应的文件内容,得到一个字节数组 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#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( AST#expression#Left this AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . resourceManager AST#member_expression#Right AST#expression#Right . getRawFileContent 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 . fileName AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left value : 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#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left rawFile = AST#expression#Left value 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 textDecoder = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left util AST#expression#Right . TextDecoder AST#member_expression#Right AST#expression#Right . create AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'utf-8' AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left ignoreBOM AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left retStr = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left textDecoder AST#expression#Right . decodeToString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left rawFile AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left stream AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 再用@ohos.util (util工具函数)的TextDecoder给它解析出来 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 . cascade 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 . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left retStr AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left code = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . code AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left message = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#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 ` callback getRawFileContent failed, error code: AST#template_substitution#Left $ { AST#expression#Left code AST#expression#Right } AST#template_substitution#Right , message: AST#template_substitution#Left $ { AST#expression#Left message AST#expression#Right } AST#template_substitution#Right . ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async loadRegion(): Promise<void> { try { getContext(this).resourceManager.getRawFileContent(this.fileName, (error: BusinessError, value: Uint8Array) => { let rawFile = value; let textDecoder = util.TextDecoder.create('utf-8', { ignoreBOM: true }); let retStr = textDecoder.decodeToString(rawFile, { stream: false }); this.cascade = JSON.parse(retStr); }) } catch (error) { let code = (error as BusinessError).code; let message = (error as BusinessError).message; console.error(`callback getRawFileContent failed, error code: ${code}, message: ${message}.`); } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/editaddress/src/main/ets/view/EditAddressView.ets#L153-L168
c14205bcf04169637ffb733ebe24808288221944
gitee
common-apps/dsbrigde-harmony-os
bb03e4e95984db32939a1ad609f688537b5a92e8
library/BuildProfile.ets
arkts
Use these variables when you tailor your ArkTS code. They must be of the const type.
export const HAR_VERSION = '1.8.0';
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left HAR_VERSION = AST#expression#Left '1.8.0' AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
export const HAR_VERSION = '1.8.0';
https://github.com/common-apps/dsbrigde-harmony-os/blob/bb03e4e95984db32939a1ad609f688537b5a92e8/library/BuildProfile.ets#L4-L4
ea3d831a3623116a75554f442dfc591c7ac6378a
gitee
851432669/Smart-Home-ArkTs-Hi3861.git
0451f85f072ed3281cc23d9cdc2843d79f60f975
entry/src/main/ets/common/utils/GlobalDataManager.ets
arkts
getDeviceById
获取单个设备状态
getDeviceById(deviceId: string): DeviceStatus | undefined { return this.deviceStatus.find(device => device.id === deviceId); }
AST#method_declaration#Left getDeviceById AST#parameter_list#Left ( AST#parameter#Left deviceId : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left DeviceStatus 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . deviceStatus 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 device => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left device AST#expression#Right . id AST#member_expression#Right AST#expression#Right === AST#expression#Left deviceId AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
getDeviceById(deviceId: string): DeviceStatus | undefined { return this.deviceStatus.find(device => device.id === deviceId); }
https://github.com/851432669/Smart-Home-ArkTs-Hi3861.git/blob/0451f85f072ed3281cc23d9cdc2843d79f60f975/entry/src/main/ets/common/utils/GlobalDataManager.ets#L152-L154
68b3f2ebd4a54a12e5cdd3aec030a7b2a7175464
github
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@ohos.arkui.advanced.ChipGroup.d.ets
arkts
Defines chipItem options. @interface ChipGroupItemOptions @syscap SystemCapability.ArkUI.ArkUI.Full @crossplatform @atomicservice @since 12
export interface ChipGroupItemOptions { /** * Prefix icon. * * @type { ?IconOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ prefixIcon?: IconOptions; /** * Prefix symbol. * * @type { ?ChipSymbolGlyphOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ prefixSymbol?: ChipSymbolGlyphOptions; /** * Chip label. * * @type { LabelOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ label: LabelOptions; /** * Suffix icon. * * @type { ?IconOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 * @deprecated since 14 * @useinstead ChipGroupItemOptions#suffixImageIcon */ suffixIcon?: IconOptions; /** * Suffix icon. * * @type { ?SuffixImageIconOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 14 */ suffixImageIcon?: SuffixImageIconOptions; /** * suffix symbol. * * @type { ?ChipSymbolGlyphOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ suffixSymbol?: ChipSymbolGlyphOptions; /** * Set options for suffix symbol. * * @type { ?ChipSuffixSymbolGlyphOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 14 */ suffixSymbolOptions?: ChipSuffixSymbolGlyphOptions; /** * Allow close. * * @type { ?boolean } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ allowClose?: boolean; /** * Set options for default close icon when 'allowaClose' is true. * * @type { ?CloseOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 14 */ closeOptions?: CloseOptions; /** * Set accessibility description for ChipGroup item. * * @type { ?ResourceStr } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 14 */ accessibilityDescription?: ResourceStr; /** * Set accessibility level for ChipGroup item. * * @type { ?string } * @default "auto" * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 14 */ accessibilityLevel?: string; }
AST#export_declaration#Left export AST#interface_declaration#Left interface ChipGroupItemOptions AST#object_type#Left { /** * Prefix icon. * * @type { ?IconOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ AST#type_member#Left prefixIcon ? : AST#type_annotation#Left AST#primary_type#Left IconOptions AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * Prefix symbol. * * @type { ?ChipSymbolGlyphOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#type_member#Left prefixSymbol ? : AST#type_annotation#Left AST#primary_type#Left ChipSymbolGlyphOptions AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * Chip label. * * @type { LabelOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ AST#type_member#Left label : AST#type_annotation#Left AST#primary_type#Left LabelOptions AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * Suffix icon. * * @type { ?IconOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 * @deprecated since 14 * @useinstead ChipGroupItemOptions#suffixImageIcon */ AST#type_member#Left suffixIcon ? : AST#type_annotation#Left AST#primary_type#Left IconOptions AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * Suffix icon. * * @type { ?SuffixImageIconOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 14 */ AST#type_member#Left suffixImageIcon ? : AST#type_annotation#Left AST#primary_type#Left SuffixImageIconOptions AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * suffix symbol. * * @type { ?ChipSymbolGlyphOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#type_member#Left suffixSymbol ? : AST#type_annotation#Left AST#primary_type#Left ChipSymbolGlyphOptions AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * Set options for suffix symbol. * * @type { ?ChipSuffixSymbolGlyphOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 14 */ AST#type_member#Left suffixSymbolOptions ? : AST#type_annotation#Left AST#primary_type#Left ChipSuffixSymbolGlyphOptions AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * Allow close. * * @type { ?boolean } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ AST#type_member#Left allowClose ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * Set options for default close icon when 'allowaClose' is true. * * @type { ?CloseOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 14 */ AST#type_member#Left closeOptions ? : AST#type_annotation#Left AST#primary_type#Left CloseOptions AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * Set accessibility description for ChipGroup item. * * @type { ?ResourceStr } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 14 */ AST#type_member#Left accessibilityDescription ? : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * Set accessibility level for ChipGroup item. * * @type { ?string } * @default "auto" * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 14 */ AST#type_member#Left accessibilityLevel ? : 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 ChipGroupItemOptions { prefixIcon?: IconOptions; prefixSymbol?: ChipSymbolGlyphOptions; label: LabelOptions; suffixIcon?: IconOptions; suffixImageIcon?: SuffixImageIconOptions; suffixSymbol?: ChipSymbolGlyphOptions; suffixSymbolOptions?: ChipSuffixSymbolGlyphOptions; allowClose?: boolean; closeOptions?: CloseOptions; accessibilityDescription?: ResourceStr; accessibilityLevel?: string; }
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.arkui.advanced.ChipGroup.d.ets#L148-L271
20ef6cd2439e22593e772367805432cfe11a2ce1
gitee
Tianpei-Shi/MusicDash.git
4db7ea82fb9d9fa5db7499ccdd6d8d51a4bb48d5
src/pages/LoginPage.ets
arkts
handleLogin
处理登录
async handleLogin(): Promise<void> { // 基本验证 if (!this.username || !this.password) { prompt.showToast({ message: '请输入用户名和密码' }); return; } try { this.isLoading = true; // 调用登录服务 await this.userService.login(this.username, this.password); prompt.showToast({ message: '登录成功' }); // 返回上一页 router.back(); } catch (error) { console.error('登录失败:', error); prompt.showToast({ message: '登录失败:' + (error instanceof Error ? error.message : String(error)) }); } finally { this.isLoading = false; } }
AST#method_declaration#Left async handleLogin AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 基本验证 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . username AST#member_expression#Right AST#expression#Right || AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . password 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 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#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLoading AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 调用登录服务 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 . userService AST#member_expression#Right AST#expression#Right . login AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . username AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . password 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 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 router AST#expression#Right . back AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '登录失败:' AST#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#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#binary_expression#Left AST#expression#Left '登录失败:' AST#expression#Right + AST#expression#Left AST#parenthesized_expression#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#parenthesized_expression#Right AST#expression#Right AST#binary_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#catch_clause#Right AST#finally_clause#Left finally AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLoading AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#finally_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async handleLogin(): Promise<void> { if (!this.username || !this.password) { prompt.showToast({ message: '请输入用户名和密码' }); return; } try { this.isLoading = true; await this.userService.login(this.username, this.password); prompt.showToast({ message: '登录成功' }); router.back(); } catch (error) { console.error('登录失败:', error); prompt.showToast({ message: '登录失败:' + (error instanceof Error ? error.message : String(error)) }); } finally { this.isLoading = false; } }
https://github.com/Tianpei-Shi/MusicDash.git/blob/4db7ea82fb9d9fa5db7499ccdd6d8d51a4bb48d5/src/pages/LoginPage.ets#L26-L52
adf05db4ad5209328faf17c751f9c49aec676c58
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/ai/GreetingGenerationService.ets
arkts
generateGreeting
生成个性化祝福语(非流式)
async generateGreeting(params: GreetingGenerateParams): Promise<GreetingGenerationResult> { const startTime = Date.now(); try { hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[GreetingGenerationService] Starting greeting generation for ${params.contact.name}`); // 转换参数格式给SimpleAIService const aiParams: GenerationParams = { contact: params.contact, style: params.style, occasion: params.occasion, customPrompt: params.customPrompt, includeAge: params.includeAge, includeRelation: params.includeRelation, includeEmoji: params.includeEmoji, greetingDescription: params.greetingDescription, targetWordCount: params.targetWordCount }; hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[GreetingGenerationService] Calling SimpleAIService with params - greetingDescription: ${params.greetingDescription || 'none'}, targetWordCount: ${params.targetWordCount || 'default'}`); hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[GreetingGenerationService] Full params object: greetingDescription='${params.greetingDescription}', targetWordCount=${params.targetWordCount}, contact='${params.contact.name}', style='${params.style}', occasion='${params.occasion}'`); // 调用真实AI服务 const generatedContent = await this.aiService.generateGreeting(aiParams); const processingTime = Date.now() - startTime; const result: GreetingGenerationResult = { success: true, content: generatedContent, alternatives: [], // SimpleAIService生成单个结果 confidence: 0.95, processingTime, isStreaming: false }; hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[GreetingGenerationService] Greeting generation completed in ${processingTime}ms, length: ${generatedContent.length} chars`); return result; } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[GreetingGenerationService] Failed to generate greeting: ${error}`); return { success: false, content: '', alternatives: [], confidence: 0, processingTime: Date.now() - startTime, error: `生成失败:${error}` }; } }
AST#method_declaration#Left async generateGreeting AST#parameter_list#Left ( AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left GreetingGenerateParams 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 GreetingGenerationResult 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 startTime = 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#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` [GreetingGenerationService] Starting greeting generation for AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . contact AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 转换参数格式给SimpleAIService AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left aiParams : AST#type_annotation#Left AST#primary_type#Left GenerationParams AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left contact AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . contact AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left style AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . style AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left occasion AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . occasion AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left customPrompt AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . customPrompt AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left includeAge AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . includeAge AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left includeRelation AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . includeRelation AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left includeEmoji AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . includeEmoji AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left greetingDescription AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . greetingDescription AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left targetWordCount AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . targetWordCount AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` [GreetingGenerationService] Calling SimpleAIService with params - greetingDescription: AST#template_substitution#Left $ { AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . greetingDescription AST#member_expression#Right AST#expression#Right || AST#expression#Left 'none' AST#expression#Right AST#binary_expression#Right AST#expression#Right } AST#template_substitution#Right , targetWordCount: AST#template_substitution#Left $ { AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . targetWordCount AST#member_expression#Right AST#expression#Right || AST#expression#Left 'default' AST#expression#Right AST#binary_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` [GreetingGenerationService] Full params object: greetingDescription=' AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . greetingDescription AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ', targetWordCount= AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . targetWordCount AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , contact=' AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . contact AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ', style=' AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . style AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ', occasion=' AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . occasion 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 // 调用真实AI服务 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left generatedContent = 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 . aiService AST#member_expression#Right AST#expression#Right . generateGreeting AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left aiParams 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 processingTime = 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 startTime 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 result : AST#type_annotation#Left AST#primary_type#Left GreetingGenerationResult 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 content AST#property_name#Right : AST#expression#Left generatedContent AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left alternatives AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right , // SimpleAIService生成单个结果 AST#property_assignment#Left AST#property_name#Left confidence AST#property_name#Right : AST#expression#Left 0.95 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left processingTime AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left isStreaming 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` [GreetingGenerationService] Greeting generation completed in AST#template_substitution#Left $ { AST#expression#Left processingTime AST#expression#Right } AST#template_substitution#Right ms, length: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left generatedContent AST#expression#Right . length AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right chars ` 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 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 hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` [GreetingGenerationService] Failed to generate greeting: AST#template_substitution#Left $ { AST#expression#Left error AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#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 content AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left alternatives AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left confidence AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left processingTime 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 startTime AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left error AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` 生成失败: AST#template_substitution#Left $ { AST#expression#Left error 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#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 generateGreeting(params: GreetingGenerateParams): Promise<GreetingGenerationResult> { const startTime = Date.now(); try { hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[GreetingGenerationService] Starting greeting generation for ${params.contact.name}`); const aiParams: GenerationParams = { contact: params.contact, style: params.style, occasion: params.occasion, customPrompt: params.customPrompt, includeAge: params.includeAge, includeRelation: params.includeRelation, includeEmoji: params.includeEmoji, greetingDescription: params.greetingDescription, targetWordCount: params.targetWordCount }; hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[GreetingGenerationService] Calling SimpleAIService with params - greetingDescription: ${params.greetingDescription || 'none'}, targetWordCount: ${params.targetWordCount || 'default'}`); hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[GreetingGenerationService] Full params object: greetingDescription='${params.greetingDescription}', targetWordCount=${params.targetWordCount}, contact='${params.contact.name}', style='${params.style}', occasion='${params.occasion}'`); const generatedContent = await this.aiService.generateGreeting(aiParams); const processingTime = Date.now() - startTime; const result: GreetingGenerationResult = { success: true, content: generatedContent, alternatives: [], confidence: 0.95, processingTime, isStreaming: false }; hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[GreetingGenerationService] Greeting generation completed in ${processingTime}ms, length: ${generatedContent.length} chars`); return result; } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[GreetingGenerationService] Failed to generate greeting: ${error}`); return { success: false, content: '', alternatives: [], confidence: 0, processingTime: Date.now() - startTime, error: `生成失败:${error}` }; } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/ai/GreetingGenerationService.ets#L75-L129
6fc2b784a40c8260ee0e993a5ef2cdc6245f66ce
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_core/src/main/ets/core/util/CharUtil.ets
arkts
@Author csx @DateTime 2023/12/29 21:04 @TODO CharUtil 字符工具类 @Use 详细使用方法以及文档详见ohpm官网,地址https://ohpm.openharmony.cn/#/cn/detail/@yunkss%2Fef_core
export class CharUtil { /** * 是否空白符 空白符包括空格、制表符、全角空格和不间断空格 * @param c * @returns */ static isBlankChar(c: number): boolean { return CharUtil.isWhitespace(c) || CharUtil.isSpaceChar(c) || c == 0xFEFF || c == 0x202A || c == 0x0000; } /** * 检查字符是否位于ASCII范围内(0~127) * @param ch 被检查的字符 * @returns `true`表示为ASCII字符,否则为`false` */ static isAscii(ch: string): boolean { // 确保输入的是单个字符 if (ch.length !== 1) throw new Error("Input must be a single character"); return ch.charCodeAt(0) < 128; } /** * 判断是否为emoji表情符 * * @param c 字符 * @returns 是否为emoji */ static isEmoji(c: number): boolean { // 判断码点是否在 Emoji 的主要 Unicode 范围内 return ( // 表情符号 (c >= 0x1F600 && c <= 0x1F64F) || // 交通和地图符号 (c >= 0x1F680 && c <= 0x1F6FF) || // 补充符号和图形 (c >= 0x1F700 && c <= 0x1F77F) || // 几何形状扩展 (c >= 0x1F780 && c <= 0x1F7FF) || // 补充符号 (c >= 0x1F800 && c <= 0x1F8FF) || // 补充符号和图形 (c >= 0x1F900 && c <= 0x1F9FF) || // 补充符号和图形 (c >= 0x1FA00 && c <= 0x1FA6F) || // 补充符号 (c >= 0x1FA70 && c <= 0x1FAFF) || // 其他 Emoji 区域 (c >= 0x2300 && c <= 0x23FF) || // 技术符号 (c >= 0x2700 && c <= 0x27BF) || // 装饰性符号 (c >= 0x2B50 && c <= 0x2B50) // 星星 ); } private static isWhitespace(codePoint: number): boolean { const whitespaceRegex = /^\s$/; const character = String.fromCodePoint(codePoint); return whitespaceRegex.test(character); } private static isSpaceChar(codePoint: number): boolean { const spaceCategories = [ "Zs", // Space separator "Zl", // Line separator "Zp" // Paragraph separator ]; const character = String.fromCodePoint(codePoint); const category = character.charCodeAt(0).toString(16); return spaceCategories.includes(category); } }
AST#export_declaration#Left export AST#class_declaration#Left class CharUtil AST#class_body#Left { /** * 是否空白符 空白符包括空格、制表符、全角空格和不间断空格 * @param c * @returns */ AST#method_declaration#Left static isBlankChar AST#parameter_list#Left ( AST#parameter#Left c : 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#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CharUtil AST#expression#Right . isWhitespace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left c AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left CharUtil AST#expression#Right AST#binary_expression#Right AST#expression#Right . isSpaceChar AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left c AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right == AST#expression#Left 0xFEFF 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 c AST#expression#Right == AST#expression#Left 0x202A 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 c AST#expression#Right == AST#expression#Left 0x0000 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 检查字符是否位于ASCII范围内(0~127) * @param ch 被检查的字符 * @returns `true`表示为ASCII字符,否则为`false` */ AST#method_declaration#Left static isAscii AST#parameter_list#Left ( AST#parameter#Left ch : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 确保输入的是单个字符 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ch AST#expression#Right . length AST#member_expression#Right AST#expression#Right !== AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#statement#Left AST#throw_statement#Left throw AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "Input must be a single character" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#throw_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ch AST#expression#Right . charCodeAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right < AST#expression#Left 128 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 判断是否为emoji表情符 * * @param c 字符 * @returns 是否为emoji */ AST#method_declaration#Left static isEmoji AST#parameter_list#Left ( AST#parameter#Left c : 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 { // 判断码点是否在 Emoji 的主要 Unicode 范围内 AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#parenthesized_expression#Left ( // 表情符号 AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#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#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#binary_expression#Left AST#expression#Left c AST#expression#Right >= AST#expression#Left 0x1F600 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right <= AST#expression#Left 0x1F64F AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right || // 交通和地图符号 AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right >= AST#expression#Left 0x1F680 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right <= AST#expression#Left 0x1F6FF 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#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 c AST#expression#Right >= AST#expression#Left 0x1F700 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right <= AST#expression#Left 0x1F77F 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#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 c AST#expression#Right >= AST#expression#Left 0x1F780 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right <= AST#expression#Left 0x1F7FF 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#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 c AST#expression#Right >= AST#expression#Left 0x1F800 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right <= AST#expression#Left 0x1F8FF 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#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 c AST#expression#Right >= AST#expression#Left 0x1F900 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right <= AST#expression#Left 0x1F9FF 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#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 c AST#expression#Right >= AST#expression#Left 0x1FA00 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right <= AST#expression#Left 0x1FA6F 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#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 c AST#expression#Right >= AST#expression#Left 0x1FA70 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right <= AST#expression#Left 0x1FAFF 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#binary_expression#Right AST#expression#Right || // 其他 Emoji 区域 AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right >= AST#expression#Left 0x2300 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right <= AST#expression#Left 0x23FF 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#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 c AST#expression#Right >= AST#expression#Left 0x2700 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right <= AST#expression#Left 0x27BF 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#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 c AST#expression#Right >= AST#expression#Left 0x2B50 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right <= AST#expression#Left 0x2B50 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#binary_expression#Right AST#expression#Right // 星星 ) AST#parenthesized_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left private static isWhitespace AST#parameter_list#Left ( AST#parameter#Left codePoint : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left whitespaceRegex AST#variable_declarator#Right AST#ERROR#Left = AST#ERROR#Left / ^ \s AST#ERROR#Right $ / AST#ERROR#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left character = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left String AST#expression#Right . fromCodePoint AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left codePoint 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 whitespaceRegex AST#expression#Right . test AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left character 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 private static isSpaceChar AST#parameter_list#Left ( AST#parameter#Left codePoint : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left spaceCategories = AST#expression#Left AST#array_literal#Left [ AST#expression#Left "Zs" AST#expression#Right , // Space separator AST#expression#Left "Zl" AST#expression#Right , // Line separator AST#expression#Left "Zp" AST#expression#Right // Paragraph separator ] 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 character = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left String AST#expression#Right . fromCodePoint AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left codePoint 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 category = 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 character AST#expression#Right . charCodeAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 16 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 spaceCategories AST#expression#Right . includes 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class CharUtil { static isBlankChar(c: number): boolean { return CharUtil.isWhitespace(c) || CharUtil.isSpaceChar(c) || c == 0xFEFF || c == 0x202A || c == 0x0000; } static isAscii(ch: string): boolean { if (ch.length !== 1) throw new Error("Input must be a single character"); return ch.charCodeAt(0) < 128; } static isEmoji(c: number): boolean { return ( (c >= 0x1F600 && c <= 0x1F64F) || (c >= 0x1F680 && c <= 0x1F6FF) || (c >= 0x1F700 && c <= 0x1F77F) || (c >= 0x1F780 && c <= 0x1F7FF) || (c >= 0x1F800 && c <= 0x1F8FF) || (c >= 0x1F900 && c <= 0x1F9FF) || (c >= 0x1FA00 && c <= 0x1FA6F) || (c >= 0x1FA70 && c <= 0x1FAFF) || (c >= 0x2300 && c <= 0x23FF) || (c >= 0x2700 && c <= 0x27BF) || (c >= 0x2B50 && c <= 0x2B50) ); } private static isWhitespace(codePoint: number): boolean { const whitespaceRegex = /^\s$/; const character = String.fromCodePoint(codePoint); return whitespaceRegex.test(character); } private static isSpaceChar(codePoint: number): boolean { const spaceCategories = [ "Zs", "Zl", "Zp" ]; const character = String.fromCodePoint(codePoint); const category = character.charCodeAt(0).toString(16); return spaceCategories.includes(category); } }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_core/src/main/ets/core/util/CharUtil.ets#L23-L98
8a47e9a3d71a6482c02c36faae32f19241d9369b
gitee
lime-zz/Ark-ui_RubbishRecycleApp.git
c2a9bff8fbb5bc46d922934afad0327cc1696969
rubbish/rubbish/entry/src/main/ets/pages/fenlei.ets
arkts
TabBuilder
自定义导航页签的样式
@Builder TabBuilder(title: string, targetIndex: number) { Column({space:10}) { Row() { // 标签图片 Image(this.currentIndex === targetIndex ? $r('app.media.img_38') : $r('app.media.img_37')) .width(10) .height(40) //.margin({left:0, right: 10 }) Text(title) .fontSize(this.currentIndex ===targetIndex ? 22 : 20) // 根据currentIndex动态改变字体大小 .fontColor(this.currentIndex === targetIndex ? '#FF5E81' : '#8a8a8a') // .fontSize(20) } .width('100%') .height(50) .justifyContent(FlexAlign.Start) .onClick(() => { this.currentIndex = targetIndex this.controller.changeIndex(this.currentIndex) }) } }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right TabBuilder 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 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#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 10 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { // 标签图片 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentIndex AST#member_expression#Right AST#expression#Right === AST#expression#Left targetIndex AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.img_38' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.img_37' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 10 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right //.margin({left:0, right: 10 }) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left title AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 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 . currentIndex AST#member_expression#Right AST#expression#Right === AST#expression#Left targetIndex AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 22 AST#expression#Right : AST#expression#Left 20 AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) // 根据currentIndex动态改变字体大小 AST#modifier_chain_expression#Left . fontColor ( 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 . currentIndex AST#member_expression#Right AST#expression#Right === AST#expression#Left targetIndex AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left '#FF5E81' AST#expression#Right : AST#expression#Left '#8a8a8a' 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 // .fontSize(20) } 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 50 AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentIndex AST#member_expression#Right = AST#expression#Left 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . controller AST#member_expression#Right AST#expression#Right . changeIndex 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 . currentIndex AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#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 TabBuilder(title: string, targetIndex: number) { Column({space:10}) { Row() { Image(this.currentIndex === targetIndex ? $r('app.media.img_38') : $r('app.media.img_37')) .width(10) .height(40) Text(title) .fontSize(this.currentIndex ===targetIndex ? 22 : 20) .fontColor(this.currentIndex === targetIndex ? '#FF5E81' : '#8a8a8a') } .width('100%') .height(50) .justifyContent(FlexAlign.Start) .onClick(() => { this.currentIndex = targetIndex this.controller.changeIndex(this.currentIndex) }) } }
https://github.com/lime-zz/Ark-ui_RubbishRecycleApp.git/blob/c2a9bff8fbb5bc46d922934afad0327cc1696969/rubbish/rubbish/entry/src/main/ets/pages/fenlei.ets#L1443-L1464
7a02b4c02262bed97ec2cb57721dacba0826918f
github
iotjin/JhHarmonyDemo.git
819e6c3b1db9984c042a181967784550e171b2e8
JhCommon/src/main/ets/JhCommon/components/JhAlert.ets
arkts
showDialog
中间弹框,黑色按钮文字 @param options
public static showDialog(options: JhAlertOptions) { DialogUtil.showDialog({ title: options.title, message: options.message ?? '', buttons: [ { value: options.leftText ?? _cancelText, fontColor: Color.Black, action: () => { options.onCancel?.() } }, { value: options.rightText ?? _confirmText, fontColor: Color.Black, action: () => { options.onConfirm?.() } }, ], }) }
AST#method_declaration#Left public static showDialog AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left JhAlertOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DialogUtil 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#member_expression#Left AST#expression#Left options AST#expression#Right . title AST#member_expression#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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . message AST#member_expression#Right AST#expression#Right ?? AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#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 value AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . leftText AST#member_expression#Right AST#expression#Right ?? AST#expression#Left _cancelText AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left fontColor AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Black AST#member_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 options AST#expression#Right . onCancel 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#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 value AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . rightText AST#member_expression#Right AST#expression#Right ?? AST#expression#Left _confirmText AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left fontColor AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Black AST#member_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 options AST#expression#Right . onConfirm 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#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 AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
public static showDialog(options: JhAlertOptions) { DialogUtil.showDialog({ title: options.title, message: options.message ?? '', buttons: [ { value: options.leftText ?? _cancelText, fontColor: Color.Black, action: () => { options.onCancel?.() } }, { value: options.rightText ?? _confirmText, fontColor: Color.Black, action: () => { options.onConfirm?.() } }, ], }) }
https://github.com/iotjin/JhHarmonyDemo.git/blob/819e6c3b1db9984c042a181967784550e171b2e8/JhCommon/src/main/ets/JhCommon/components/JhAlert.ets#L129-L150
2024a8c85265f5f2bce7a03bf902873899ded55b
github
zhongte/TaoYao
80850f3800dd6037216d3f7c58a2bf34a881c93f
taoyao/src/main/ets/shijing/taoyao/origin/Origin.ets
arkts
getContext
获取context对象 @returns
abstract getContext(): Context
AST#method_declaration#Left abstract getContext AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left Context AST#primary_type#Right AST#type_annotation#Right AST#method_declaration#Right
abstract getContext(): Context
https://github.com/zhongte/TaoYao/blob/80850f3800dd6037216d3f7c58a2bf34a881c93f/taoyao/src/main/ets/shijing/taoyao/origin/Origin.ets#L13-L13
4ea9cc82756e7c24a75a36e5ad40c8818ae6afe0
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/utils/strings/StringPyHelper.ets
arkts
isAlphabet
/ 检测是否为字母
static isAlphabet(str: string): boolean { return Array.from(str).every(c => /[a-zA-Z]/.test(c)); }
AST#method_declaration#Left static isAlphabet AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Array AST#expression#Right . from AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . every AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left c => AST#ERROR#Left / AST#ERROR#Right AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#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 zA AST#expression#Right AST#binary_expression#Right 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#expression#Left AST#expression#Right AST#binary_expression#Right AST#expression#Right . test AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left c 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
static isAlphabet(str: string): boolean { return Array.from(str).every(c => /[a-zA-Z]/.test(c)); }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/utils/strings/StringPyHelper.ets#L23-L25
6efab6b3a62b7f6c9222601e9087bddfb1689d87
github
common-apps/ZRouter
5adc9c4bcca6ba7d9b323451ed464e1e9b47eee6
RouterApi/src/main/ets/animation/NavAnimationMgr.ets
arkts
getTopAvoidAreaHeightPx
获取顶部安全区域高度 @returns
public getTopAvoidAreaHeightPx(): number { return WindowUtils.topAvoidAreaHeight_px }
AST#method_declaration#Left public getTopAvoidAreaHeightPx 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 WindowUtils AST#expression#Right . topAvoidAreaHeight_px AST#member_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public getTopAvoidAreaHeightPx(): number { return WindowUtils.topAvoidAreaHeight_px }
https://github.com/common-apps/ZRouter/blob/5adc9c4bcca6ba7d9b323451ed464e1e9b47eee6/RouterApi/src/main/ets/animation/NavAnimationMgr.ets#L203-L205
1de42487a61bde8004150cdda84226bfce0da199
gitee
fourseas1998/hos.ArkTSComponents.git
5f0dbd0038f17067722cb035c88fe826e4846e69
entry/src/main/ets/viewmodel/MainViewModel.ets
arkts
getSettingListData
获取设置页数据资源
getSettingListData(): Array<ItemData> { let settingListData: ItemData[] = [ new ItemData($r('app.string.setting_list_news'), $r("app.media.news"), $r("app.string.setting_toggle")), new ItemData($r('app.string.setting_list_data'), $r("app.media.data"), null), new ItemData($r('app.string.setting_list_menu'), $r("app.media.menu"), null), new ItemData($r('app.string.setting_list_about'), $r("app.media.about"), null), new ItemData($r('app.string.setting_list_storage'), $r("app.media.storage"), null), new ItemData($r('app.string.setting_list_privacy'), $r("app.media.privacy"), null) ]; return settingListData; }
AST#method_declaration#Left getSettingListData 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 ItemData 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 settingListData : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ItemData [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ItemData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.setting_list_news' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.news" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.setting_toggle" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ItemData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.setting_list_data' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.data" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ItemData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.setting_list_menu' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.menu" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ItemData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.setting_list_about' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.about" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ItemData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.setting_list_storage' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.storage" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ItemData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.setting_list_privacy' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.privacy" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ] AST#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 settingListData AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
getSettingListData(): Array<ItemData> { let settingListData: ItemData[] = [ new ItemData($r('app.string.setting_list_news'), $r("app.media.news"), $r("app.string.setting_toggle")), new ItemData($r('app.string.setting_list_data'), $r("app.media.data"), null), new ItemData($r('app.string.setting_list_menu'), $r("app.media.menu"), null), new ItemData($r('app.string.setting_list_about'), $r("app.media.about"), null), new ItemData($r('app.string.setting_list_storage'), $r("app.media.storage"), null), new ItemData($r('app.string.setting_list_privacy'), $r("app.media.privacy"), null) ]; return settingListData; }
https://github.com/fourseas1998/hos.ArkTSComponents.git/blob/5f0dbd0038f17067722cb035c88fe826e4846e69/entry/src/main/ets/viewmodel/MainViewModel.ets#L55-L65
2b9e875797d6e0ceb9b82e540bb6dcaed3ee2527
github
zqaini002/YaoYaoLingXian.git
5095b12cbeea524a87c42d0824b1702978843d39
YaoYaoLingXian/entry/src/main/ets/pages/home/HomePage.ets
arkts
updateTaskStatus
更新任务状态
async updateTaskStatus(taskId: number, status: number) { try { await ApiService.updateTaskStatus(taskId, status); // 刷新数据 this.refreshData(); } catch (error) { console.error('更新任务状态失败', error); // 本地更新UI(乐观更新) const taskIndex = this.todayTasks.findIndex(task => task.id === taskId); if (taskIndex !== -1) { this.todayTasks[taskIndex].status = status; } } }
AST#method_declaration#Left async updateTaskStatus AST#parameter_list#Left ( AST#parameter#Left taskId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left status : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left ApiService AST#expression#Right AST#await_expression#Right AST#expression#Right . updateTaskStatus AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left taskId AST#expression#Right , AST#expression#Left status 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 . 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#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 // 本地更新UI(乐观更新) AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left taskIndex = 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 . todayTasks AST#member_expression#Right AST#expression#Right . findIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left task => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left task AST#expression#Right . id AST#member_expression#Right AST#expression#Right === AST#expression#Left taskId 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left taskIndex AST#expression#Right !== AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_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 . todayTasks AST#member_expression#Right AST#expression#Right [ AST#expression#Left taskIndex AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . status AST#member_expression#Right = AST#expression#Left status 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#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async updateTaskStatus(taskId: number, status: number) { try { await ApiService.updateTaskStatus(taskId, status); this.refreshData(); } catch (error) { console.error('更新任务状态失败', error); const taskIndex = this.todayTasks.findIndex(task => task.id === taskId); if (taskIndex !== -1) { this.todayTasks[taskIndex].status = status; } } }
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/pages/home/HomePage.ets#L345-L358
f835e3b4d4efde7f77dfb0c4ad7a716259962b0c
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/views/main/sub/report/RadarView.ets
arkts
onDataChange
========== 生命周期和监控 ==========
@Monitor('parts', 'guideLineCount', 'showPercentText') onDataChange() { if (this.isCanvasReady) { this.drawCanvas(); } }
AST#method_declaration#Left AST#decorator#Left @ Monitor ( AST#expression#Left 'parts' AST#expression#Right , AST#expression#Left 'guideLineCount' AST#expression#Right , AST#expression#Left 'showPercentText' AST#expression#Right ) AST#decorator#Right onDataChange 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 . isCanvasReady AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . drawCanvas AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Monitor('parts', 'guideLineCount', 'showPercentText') onDataChange() { if (this.isCanvasReady) { this.drawCanvas(); } }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/views/main/sub/report/RadarView.ets#L29-L34
f04e77e80b7fc37ffd77edb10e98d9c2348a6e0c
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/GlobalContext.ets
arkts
单例对象 GlobalContext.ts
export class GlobalContext { private constructor() {} private static instance: GlobalContext; private _objects = new Map<string, Object>(); public static getContext(): GlobalContext { if (!GlobalContext.instance) { GlobalContext.instance = new GlobalContext(); } return GlobalContext.instance; } public getObject(key: string): Object | undefined { return this._objects.get(key); } public setObject(key: string, objectClass: Object): void { this._objects.set(key, objectClass); } /** * 将数据存入缓存中 */ public put(key: string, value: Object): void { this._objects.set(key, value); } /** * 获取缓存中的数据 */ public get<T>(key: string): T { return this._objects.get(key) as T; } /** * 缓存中的数据是否存在 */ public has(key: string): boolean { return this._objects.has(key); } /** * 移除缓存 */ public remove(key: string) { this._objects.delete(key); } /** * 清除缓存数据 */ public clear() { return this._objects.clear(); } }
AST#export_declaration#Left export AST#class_declaration#Left class GlobalContext AST#class_body#Left { AST#constructor_declaration#Left private constructor AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { } AST#block_statement#Right AST#constructor_declaration#Right AST#property_declaration#Left private static instance : AST#type_annotation#Left AST#primary_type#Left GlobalContext AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left private _objects = 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 Object 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#property_declaration#Right AST#method_declaration#Left public static getContext AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left GlobalContext AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left GlobalContext AST#expression#Right AST#unary_expression#Right AST#expression#Right . instance AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left GlobalContext AST#expression#Right . instance AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left GlobalContext AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left GlobalContext AST#expression#Right . instance AST#member_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left public getObject AST#parameter_list#Left ( AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Object AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#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 . _objects AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left public setObject AST#parameter_list#Left ( AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left objectClass : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 . _objects AST#member_expression#Right 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 objectClass AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /** * 将数据存入缓存中 */ AST#method_declaration#Left public put AST#parameter_list#Left ( AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left Object 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 . _objects AST#member_expression#Right 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#builder_function_body#Right AST#method_declaration#Right /** * 获取缓存中的数据 */ AST#method_declaration#Left public get AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#as_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 . _objects AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 缓存中的数据是否存在 */ AST#method_declaration#Left public has AST#parameter_list#Left ( AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _objects AST#member_expression#Right AST#expression#Right . has AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 移除缓存 */ AST#method_declaration#Left public remove AST#parameter_list#Left ( AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#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 . _objects AST#member_expression#Right AST#expression#Right . delete AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /** * 清除缓存数据 */ AST#method_declaration#Left public clear AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _objects AST#member_expression#Right AST#expression#Right . clear AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class GlobalContext { private constructor() {} private static instance: GlobalContext; private _objects = new Map<string, Object>(); public static getContext(): GlobalContext { if (!GlobalContext.instance) { GlobalContext.instance = new GlobalContext(); } return GlobalContext.instance; } public getObject(key: string): Object | undefined { return this._objects.get(key); } public setObject(key: string, objectClass: Object): void { this._objects.set(key, objectClass); } public put(key: string, value: Object): void { this._objects.set(key, value); } public get<T>(key: string): T { return this._objects.get(key) as T; } public has(key: string): boolean { return this._objects.has(key); } public remove(key: string) { this._objects.delete(key); } public clear() { return this._objects.clear(); } }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/GlobalContext.ets#L17-L80
70cf2fc3bd5af60c17da7b3e3db961c591e19f23
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/SystemFeature/DeviceManagement/DeviceManagementCollection/feature/capabilities/src/main/ets/util/DeviceUtil.ets
arkts
serial
设备序列号
static serial(): string { return deviceInfo.serial }
AST#method_declaration#Left static serial 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 . serial AST#member_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static serial(): string { return deviceInfo.serial }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/DeviceManagement/DeviceManagementCollection/feature/capabilities/src/main/ets/util/DeviceUtil.ets#L85-L87
4876a3c6ed495939b9a8a6c29f01a450686a5df1
gitee
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@ohos.arkui.advanced.MultiNavigation.d.ets
arkts
MultiNavigation
Declaration struct MultiNavigation. @struct { MultiNavigation } @syscap SystemCapability.ArkUI.ArkUI.Full @crossplatform @atomicservice @since 14
@Component export declare struct MultiNavigation { /** * MultiNavigation path stack of the MultiNavigation. * * @type { MultiNavPathStack } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 14 */ @State multiStack: MultiNavPathStack; /** * build function of NavDestination. * * @type { NavDestinationBuildFunction } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 14 */ @BuilderParam navDestination: NavDestinationBuildFunction; /** * callback when the MultiNavigationMode change. * * @type { ?OnNavigationModeChangeCallback } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 14 */ onNavigationModeChange?: OnNavigationModeChangeCallback; /** * This callback is triggered when the HomePage at the top of the stack. * * @type { ?OnHomeShowOnTopCallback } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 14 */ onHomeShowOnTop?: OnHomeShowOnTopCallback; }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export AST#ERROR#Left declare AST#ERROR#Right struct MultiNavigation AST#component_body#Left { /** * MultiNavigation path stack of the MultiNavigation. * * @type { MultiNavPathStack } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 14 */ AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right multiStack : AST#type_annotation#Left AST#primary_type#Left MultiNavPathStack AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * build function of NavDestination. * * @type { NavDestinationBuildFunction } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 14 */ AST#property_declaration#Left AST#decorator#Left @ BuilderParam AST#decorator#Right navDestination : AST#type_annotation#Left AST#primary_type#Left NavDestinationBuildFunction AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * callback when the MultiNavigationMode change. * * @type { ?OnNavigationModeChangeCallback } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 14 */ AST#property_declaration#Left onNavigationModeChange ? : AST#type_annotation#Left AST#primary_type#Left OnNavigationModeChangeCallback AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * This callback is triggered when the HomePage at the top of the stack. * * @type { ?OnHomeShowOnTopCallback } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 14 */ AST#property_declaration#Left onHomeShowOnTop ? : AST#type_annotation#Left AST#primary_type#Left OnHomeShowOnTopCallback AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export declare struct MultiNavigation { @State multiStack: MultiNavPathStack; @BuilderParam navDestination: NavDestinationBuildFunction; onNavigationModeChange?: OnNavigationModeChangeCallback; onHomeShowOnTop?: OnHomeShowOnTopCallback; }
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.arkui.advanced.MultiNavigation.d.ets#L73-L120
3884433f7aba2cced354f61350979b6ed942b19a
gitee
BohanSu/LumosAgent-HarmonyOS.git
9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76
entry/src/main/ets/common/Utils.ets
arkts
generateId
Generate a unique ID @returns Unique ID string
static generateId(): string { return Date.now().toString(36) + Math.random().toString(36).substr(2); }
AST#method_declaration#Left static generateId 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#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#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 36 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left Math AST#expression#Right AST#binary_expression#Right 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 . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 36 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . substr AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static generateId(): string { return Date.now().toString(36) + Math.random().toString(36).substr(2); }
https://github.com/BohanSu/LumosAgent-HarmonyOS.git/blob/9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76/entry/src/main/ets/common/Utils.ets#L72-L74
338e322063e05c5f4f0b70908a56d2a66fab652d
github
hqj201013136012/HarmonyMiliUiPro.git
0625e681e07b771998a0ac4430824627d0eb60ed
entry/src/main/ets/common/dialog/CommonTimeDialog.ets
arkts
CommonTimeDialog
Icon+Text自定义弹窗
@CustomDialog export struct CommonTimeDialog { controller?: CustomDialogController @State currentDate:string='' @State config: DateTimePickerConfig = { format: DateTimeFormat.Hm, start: '00:00', end: '23:59', selected: (this.currentDate=='')?DateUtil.getTodayStr('HH:mm'):this.currentDate } @State suffixMode: SuffixMode = SuffixMode.Separated // @State selectedTime: DateTime = new DateTime(this.config.format, this.config.selected) build() { Column() { Text('时间设置') .fontColor('#ffffff') .fontSize(30) .margin({ top: 38 }) DateTimePicker({ config: this.config, suffixMode: this.suffixMode, suffixes: { // 后缀文字 year: '年', month: '月', day: '日', hour: '时', minute: '', second: '' }, selectedTextStyle: { font: { size: 34 }, color: '#2495ff' }, textStyle: { font: { size: 22 }, color: '#ffffff' }, disappearTextStyle: { font: { size: 18 }, color: '#ffffff' }, suffixTextStyle: { font: { size: 24 }, color: '#484848' }, onSelectedCallback: (selected) => { // this.selectedTime = selected this.currentDate=selected.format() } }) .width('100%') .layoutWeight(1) .align(Alignment.Center) .padding({ left: 40, right: 40 }) Row() { Button('取消') .width(280) .height(75) .backgroundColor('#262626') .fontColor('#ffffff') .fontSize(28) .borderRadius(20) .onClick(()=>{ this.controller?.close() }) Button('确定') .width(280) .height(75) .backgroundColor('#2495ff') .fontColor('#ffffff') .fontSize(28) .borderRadius(20) .margin({left:30}) .onClick(()=>{ this.controller?.close() }) } .width('100%') .height(75) .margin({ bottom: 30 }) .justifyContent(FlexAlign.Center) } .width('100%') .height('100%') .justifyContent(FlexAlign.Center) .backgroundColor('#1A1A1A') .borderRadius(20) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ CustomDialog AST#decorator#Right export struct CommonTimeDialog AST#component_body#Left { AST#property_declaration#Left controller ? : AST#type_annotation#Left AST#primary_type#Left CustomDialogController AST#primary_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right currentDate : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right config : AST#type_annotation#Left AST#primary_type#Left DateTimePickerConfig AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left format AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left DateTimeFormat AST#expression#Right . Hm AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left start AST#property_name#Right : AST#expression#Left '00:00' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left end AST#property_name#Right : AST#expression#Left '23:59' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left selected AST#property_name#Right : AST#expression#Left AST#member_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#member_expression#Left AST#expression#Left this AST#expression#Right . currentDate AST#member_expression#Right AST#expression#Right == AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateUtil AST#expression#Right . getTodayStr AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'HH:mm' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . currentDate AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right suffixMode : AST#type_annotation#Left AST#primary_type#Left SuffixMode AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left SuffixMode AST#expression#Right . Separated AST#member_expression#Right AST#expression#Right // @State selectedTime: DateTime = new DateTime(this.config.format, this.config.selected) 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#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#ffffff' AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 30 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 38 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 DateTimePicker ( AST#component_parameters#Left { AST#component_parameter#Left config : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . config AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left suffixMode : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . suffixMode AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left suffixes : AST#expression#Left AST#object_literal#Left { // 后缀文字 AST#property_assignment#Left AST#property_name#Left year AST#property_name#Right : AST#expression#Left '年' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left month AST#property_name#Right : AST#expression#Left '月' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left day AST#property_name#Right : AST#expression#Left '日' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left hour AST#property_name#Right : AST#expression#Left '时' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left minute AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left second AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left selectedTextStyle : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left font AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left size AST#property_name#Right : AST#expression#Left 34 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 '#2495ff' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left textStyle : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left font AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left size AST#property_name#Right : AST#expression#Left 22 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 '#ffffff' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left disappearTextStyle : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left font AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left size AST#property_name#Right : AST#expression#Left 18 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 '#ffffff' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left suffixTextStyle : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left font AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left size AST#property_name#Right : AST#expression#Left 24 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 '#484848' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onSelectedCallback : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left selected AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // this.selectedTime = selected 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 . currentDate AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left selected AST#expression#Right . format AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . align ( AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 40 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 40 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left '取消' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 280 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 75 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#262626' AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#ffffff' AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 28 AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 20 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#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left '确定' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 280 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 75 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#2495ff' AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#ffffff' AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 28 AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 20 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#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#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 75 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 30 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#1A1A1A' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@CustomDialog export struct CommonTimeDialog { controller?: CustomDialogController @State currentDate:string='' @State config: DateTimePickerConfig = { format: DateTimeFormat.Hm, start: '00:00', end: '23:59', selected: (this.currentDate=='')?DateUtil.getTodayStr('HH:mm'):this.currentDate } @State suffixMode: SuffixMode = SuffixMode.Separated build() { Column() { Text('时间设置') .fontColor('#ffffff') .fontSize(30) .margin({ top: 38 }) DateTimePicker({ config: this.config, suffixMode: this.suffixMode, suffixes: { year: '年', month: '月', day: '日', hour: '时', minute: '', second: '' }, selectedTextStyle: { font: { size: 34 }, color: '#2495ff' }, textStyle: { font: { size: 22 }, color: '#ffffff' }, disappearTextStyle: { font: { size: 18 }, color: '#ffffff' }, suffixTextStyle: { font: { size: 24 }, color: '#484848' }, onSelectedCallback: (selected) => { this.currentDate=selected.format() } }) .width('100%') .layoutWeight(1) .align(Alignment.Center) .padding({ left: 40, right: 40 }) Row() { Button('取消') .width(280) .height(75) .backgroundColor('#262626') .fontColor('#ffffff') .fontSize(28) .borderRadius(20) .onClick(()=>{ this.controller?.close() }) Button('确定') .width(280) .height(75) .backgroundColor('#2495ff') .fontColor('#ffffff') .fontSize(28) .borderRadius(20) .margin({left:30}) .onClick(()=>{ this.controller?.close() }) } .width('100%') .height(75) .margin({ bottom: 30 }) .justifyContent(FlexAlign.Center) } .width('100%') .height('100%') .justifyContent(FlexAlign.Center) .backgroundColor('#1A1A1A') .borderRadius(20) } }
https://github.com/hqj201013136012/HarmonyMiliUiPro.git/blob/0625e681e07b771998a0ac4430824627d0eb60ed/entry/src/main/ets/common/dialog/CommonTimeDialog.ets#L13-L116
dc1aa2bfe5b3a75277f628f2306472997119680e
github