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
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto_dto/src/main/ets/crypto/encryption/AESSync.ets
arkts
encodeCBC192
加密-CBC模式-192位 @param str 待加密的字符串 @param aesKey AES密钥 @param iv iv偏移量字符串 @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式 @param resultCoding 加密后数据的编码方式(hex/base64)-不传默认为base64 @returns
static encodeCBC192(str: string, aesKey: string, iv: string, keyCoding: buffer.BufferEncoding, resultCoding: buffer.BufferEncoding = 'base64'): OutDTO<string> { return CryptoSyncUtil.encodeCBC(str, aesKey, iv, 'AES192', 'AES192|CBC|PKCS7', 192, keyCoding, resultCoding); }
AST#method_declaration#Left static encodeCBC192 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 iv : 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 . encodeCBC 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 iv AST#expression#Right , AST#expression#Left 'AES192' AST#expression#Right , AST#expression#Left 'AES192|CBC|PKCS7' AST#expression#Right , AST#expression#Left 192 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 encodeCBC192(str: string, aesKey: string, iv: string, keyCoding: buffer.BufferEncoding, resultCoding: buffer.BufferEncoding = 'base64'): OutDTO<string> { return CryptoSyncUtil.encodeCBC(str, aesKey, iv, 'AES192', 'AES192|CBC|PKCS7', 192, keyCoding, resultCoding); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto_dto/src/main/ets/crypto/encryption/AESSync.ets#L153-L156
d2ea9f293d8def0e72b1ccccb6834b80db08a0e3
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/entryability/EntryAbility.ets
arkts
initDatas
使用处代码
async initDatas() { import('../models/datas/book/BookDbAccess') .then((it) => { it.BookDbAccess.shared }) // import('../models/datas/word/WordDbAccess') .then((it) => { it.WordDbAccess.shared }) import('../models/datas/myData/WordUserDbAccess') .then((it) => { it.WordUserDbAccess.shared }) import('../models/datas/model/SearchManager') .then((it) => { it.SearchManager.shared }) import('../models/datas/book/BookManager') .then((it) => { it.BookManager.shared }) import('../models/datas/basedict/BaseWordDbAccess') .then((it) => { it.BaseWordDbAccess.shared }) import('../models/datas/cigen/CigenWordDbAccess') .then((it) => { it.CigenWordDbAccess.shared }) }
AST#method_declaration#Left async initDatas 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#import_expression#Left import ( AST#expression#Left '../models/datas/book/BookDbAccess' AST#expression#Right ) AST#import_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left it AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left it AST#expression#Right . BookDbAccess AST#member_expression#Right AST#expression#Right . shared AST#member_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 // import('../models/datas/word/WordDbAccess') .then((it) => { it.WordDbAccess.shared }) AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#import_expression#Left import ( AST#expression#Left '../models/datas/myData/WordUserDbAccess' AST#expression#Right ) AST#import_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left it AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left it AST#expression#Right . WordUserDbAccess AST#member_expression#Right AST#expression#Right . shared AST#member_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#import_expression#Left import ( AST#expression#Left '../models/datas/model/SearchManager' AST#expression#Right ) AST#import_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left it AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left it AST#expression#Right . SearchManager AST#member_expression#Right AST#expression#Right . shared AST#member_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#import_expression#Left import ( AST#expression#Left '../models/datas/book/BookManager' AST#expression#Right ) AST#import_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left it AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left it AST#expression#Right . BookManager AST#member_expression#Right AST#expression#Right . shared AST#member_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#import_expression#Left import ( AST#expression#Left '../models/datas/basedict/BaseWordDbAccess' AST#expression#Right ) AST#import_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left it AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left it AST#expression#Right . BaseWordDbAccess AST#member_expression#Right AST#expression#Right . shared AST#member_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#import_expression#Left import ( AST#expression#Left '../models/datas/cigen/CigenWordDbAccess' AST#expression#Right ) AST#import_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left it AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left it AST#expression#Right . CigenWordDbAccess AST#member_expression#Right AST#expression#Right . shared AST#member_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
async initDatas() { import('../models/datas/book/BookDbAccess') .then((it) => { it.BookDbAccess.shared }) import('../models/datas/myData/WordUserDbAccess') .then((it) => { it.WordUserDbAccess.shared }) import('../models/datas/model/SearchManager') .then((it) => { it.SearchManager.shared }) import('../models/datas/book/BookManager') .then((it) => { it.BookManager.shared }) import('../models/datas/basedict/BaseWordDbAccess') .then((it) => { it.BaseWordDbAccess.shared }) import('../models/datas/cigen/CigenWordDbAccess') .then((it) => { it.CigenWordDbAccess.shared }) }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/entryability/EntryAbility.ets#L131-L144
ab776acfe1ab848705569f2363de7dd0517405e5
github
mayuanwei/harmonyOS_bilibili
8a36b68b1ddf4433e2e17ee10fee4993cce2a6c5
HCIA/demoCollect/startAbility/frame/AbilityKit/DataSynchronization/entry/src/main/ets/viewModel/CommonData.ets
arkts
金额
constructor(type: string, money: number) { this.type = type; this.money = money; }
AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left type : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left money : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . type AST#member_expression#Right = AST#expression#Left type AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . money AST#member_expression#Right = AST#expression#Left money AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right
constructor(type: string, money: number) { this.type = type; this.money = money; }
https://github.com/mayuanwei/harmonyOS_bilibili/blob/8a36b68b1ddf4433e2e17ee10fee4993cce2a6c5/HCIA/demoCollect/startAbility/frame/AbilityKit/DataSynchronization/entry/src/main/ets/viewModel/CommonData.ets#L8-L11
432bfdc14dd508d25e7e3a1ee0ae2f1edb82d003
gitee
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
core/network/src/main/ets/datasource/auth/AuthNetworkDataSourceImpl.ets
arkts
@file 认证相关网络数据源实现类 @author Joker.X
export class AuthNetworkDataSourceImpl implements AuthNetworkDataSource { /** * 刷新 Token * @param {Record<string, string>} params - 刷新参数 * @returns {Promise<NetworkResponse<Auth>>} 刷新后的认证信息 */ async refreshToken(params: Record<string, string>): Promise<NetworkResponse<Auth>> { const response: AxiosResponse<NetworkResponse<Auth>> = await NetworkClient.http.post("user/login/refreshToken", params); return response.data; } /** * 密码登录实现 * @param {Record<string, string>} params - 登录参数 * @returns {Promise<NetworkResponse<Auth>>} 登录结果 */ async loginByPassword(params: PasswordLoginRequest): Promise<NetworkResponse<Auth>> { const response: AxiosResponse<NetworkResponse<Auth>> = await NetworkClient.http.post("user/login/password", params); return response.data; } }
AST#export_declaration#Left export AST#class_declaration#Left class AuthNetworkDataSourceImpl AST#implements_clause#Left implements AuthNetworkDataSource AST#implements_clause#Right AST#class_body#Left { /** * 刷新 Token * @param {Record<string, string>} params - 刷新参数 * @returns {Promise<NetworkResponse<Auth>>} 刷新后的认证信息 */ AST#method_declaration#Left async refreshToken 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 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#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 Auth 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#variable_declaration#Left const AST#variable_declarator#Left response : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left AxiosResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left NetworkResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Auth AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left NetworkClient AST#expression#Right AST#await_expression#Right AST#expression#Right . http AST#member_expression#Right AST#expression#Right . post AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "user/login/refreshToken" 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#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . data AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 密码登录实现 * @param {Record<string, string>} params - 登录参数 * @returns {Promise<NetworkResponse<Auth>>} 登录结果 */ AST#method_declaration#Left async loginByPassword AST#parameter_list#Left ( AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left PasswordLoginRequest 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 Auth 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#variable_declaration#Left const AST#variable_declarator#Left response : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left AxiosResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left NetworkResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Auth AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left NetworkClient AST#expression#Right AST#await_expression#Right AST#expression#Right . http AST#member_expression#Right AST#expression#Right . post AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "user/login/password" 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#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . data AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class AuthNetworkDataSourceImpl implements AuthNetworkDataSource { async refreshToken(params: Record<string, string>): Promise<NetworkResponse<Auth>> { const response: AxiosResponse<NetworkResponse<Auth>> = await NetworkClient.http.post("user/login/refreshToken", params); return response.data; } async loginByPassword(params: PasswordLoginRequest): Promise<NetworkResponse<Auth>> { const response: AxiosResponse<NetworkResponse<Auth>> = await NetworkClient.http.post("user/login/password", params); return response.data; } }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/network/src/main/ets/datasource/auth/AuthNetworkDataSourceImpl.ets#L10-L32
ec6d66aa5174e93672df8ac54dc3f2525f2de8cf
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Media/ImageEdit/entry/src/main/ets/viewModel/Ratio.ets
arkts
isValid
Determine whether the current ratio is valid. @returns
isValid(): boolean { return (this.w > 0 && this.h > 0); }
AST#method_declaration#Left isValid 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#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . w AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . h AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
isValid(): boolean { return (this.w > 0 && this.h > 0); }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Media/ImageEdit/entry/src/main/ets/viewModel/Ratio.ets#L75-L77
3c86e05dec9afbf850742b9a15d9743021c88425
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/util/src/main/ets/validation/ValidationUtil.ets
arkts
isValidEmail
验证邮箱地址是否有效 @param {string} email - 邮箱地址 @returns {boolean} 是否有效
static isValidEmail(email: string): boolean { return ValidationUtil.EMAIL_REGEX.test(email); }
AST#method_declaration#Left static isValidEmail AST#parameter_list#Left ( AST#parameter#Left email : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#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 ValidationUtil AST#expression#Right . EMAIL_REGEX AST#member_expression#Right AST#expression#Right . test AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left email AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static isValidEmail(email: string): boolean { return ValidationUtil.EMAIL_REGEX.test(email); }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/util/src/main/ets/validation/ValidationUtil.ets#L69-L71
d0216f7db6c68b706aeda978b71a001ecf81a45e
github
Classaspen/ArkTS_PasswordManagement.git
66aea6e4f8ee3a78e5029c63186dba70707ca2d9
entry/src/main/ets/components/database/Database.ets
arkts
getDeviceList
Query the list of devices within the network.
getDeviceList(): string[] { let deviceManager: distributedDeviceManager.DeviceManager; let deviceIds: string[] = []; try { // create deviceManager. deviceManager = distributedDeviceManager.createDeviceManager('com.example.crossDeviceDataSynchronization'); // DeviceIds is obtained by calling the getAvailableDeviceListSync method by the DeviceManager. if (deviceManager != null) { let devices = deviceManager.getAvailableDeviceListSync(); hilog.info(0x0000, 'hilog', CommonConstants.RDB_TAG, 'devices size ' + devices.length); for (let i = 0; i < devices.length; i++) { deviceIds[i] = devices[i].networkId as string; hilog.info(0x0000, 'hilog', CommonConstants.RDB_TAG, 'devices size ' + deviceIds[i]); } } } catch (err) { hilog.error(0x0000, 'hilog', CommonConstants.RDB_TAG, `Failed to insert data. Code:${err.code}, message:${err.message}`); } return deviceIds; }
AST#method_declaration#Left getDeviceList AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left deviceManager : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left distributedDeviceManager . DeviceManager AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left deviceIds : 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#try_statement#Left try AST#block_statement#Left { // create deviceManager. AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left deviceManager = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left distributedDeviceManager AST#expression#Right . createDeviceManager AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'com.example.crossDeviceDataSynchronization' 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 // DeviceIds is obtained by calling the getAvailableDeviceListSync method by the DeviceManager. AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left deviceManager AST#expression#Right != AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left devices = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left deviceManager AST#expression#Right . getAvailableDeviceListSync 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 hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'hilog' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'devices size ' AST#expression#Right + AST#expression#Left devices AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left devices AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left deviceIds AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left = devices AST#ERROR#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . networkId 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#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'hilog' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left 'devices size ' AST#expression#Right + AST#expression#Left AST#subscript_expression#Left AST#expression#Left deviceIds AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'hilog' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to insert data. Code: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , message: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left deviceIds AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
getDeviceList(): string[] { let deviceManager: distributedDeviceManager.DeviceManager; let deviceIds: string[] = []; try { deviceManager = distributedDeviceManager.createDeviceManager('com.example.crossDeviceDataSynchronization'); if (deviceManager != null) { let devices = deviceManager.getAvailableDeviceListSync(); hilog.info(0x0000, 'hilog', CommonConstants.RDB_TAG, 'devices size ' + devices.length); for (let i = 0; i < devices.length; i++) { deviceIds[i] = devices[i].networkId as string; hilog.info(0x0000, 'hilog', CommonConstants.RDB_TAG, 'devices size ' + deviceIds[i]); } } } catch (err) { hilog.error(0x0000, 'hilog', CommonConstants.RDB_TAG, `Failed to insert data. Code:${err.code}, message:${err.message}`); } return deviceIds; }
https://github.com/Classaspen/ArkTS_PasswordManagement.git/blob/66aea6e4f8ee3a78e5029c63186dba70707ca2d9/entry/src/main/ets/components/database/Database.ets#L188-L208
124eab20f8742d78cf92df0235b2181b1e31de99
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/database/DatabaseService.ets
arkts
getCommemorationsInMonth
获取本月的纪念日 @param month 月份 @param year 年份(可选)
async getCommemorationsInMonth(month: number, year?: number): Promise<CommemorationEntity[]> { this.checkInitialization(); return await this.commemorationDAO.getCommemorationsInMonth(month, year); }
AST#method_declaration#Left async getCommemorationsInMonth AST#parameter_list#Left ( AST#parameter#Left month : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left year ? : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left CommemorationEntity [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . checkInitialization 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#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 . commemorationDAO AST#member_expression#Right AST#expression#Right . getCommemorationsInMonth AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left month AST#expression#Right , AST#expression#Left year 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 getCommemorationsInMonth(month: number, year?: number): Promise<CommemorationEntity[]> { this.checkInitialization(); return await this.commemorationDAO.getCommemorationsInMonth(month, year); }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/database/DatabaseService.ets#L194-L197
ac532f5234f1903633ddbe4b98569b05f47bba27
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_core/src/main/ets/core/util/IdCardUtil.ets
arkts
getDistrictCodeByIdCard
根据身份编号获取区县级编码,只支持15或18位身份证号码 @param idCard 身份编码 @return 省份编码
static getDistrictCodeByIdCard(idCard: string): OutDTO<string> { if (IdCardUtil.PROVINCE_CODES.size == 0) { IdCardUtil.init(); } let len = idCard.length; if (len == IdCardUtil.CHINA_ID_MIN_LENGTH || len == IdCardUtil.CHINA_ID_MAX_LENGTH) { let district = IdCardUtil.DISTRICT_CODES.get(idCard.substring(0, 6)); if (!district) { return OutDTO.Error("根据身份证号获取区域信息错误"); } return OutDTO.OKByDataRow(district.toString(), idCard.substring(0, 6)); } else { return OutDTO.Error("身份证长度不正确"); } }
AST#method_declaration#Left static getDistrictCodeByIdCard AST#parameter_list#Left ( AST#parameter#Left idCard : 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#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left IdCardUtil AST#expression#Right . PROVINCE_CODES AST#member_expression#Right AST#expression#Right . size AST#member_expression#Right AST#expression#Right == AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left IdCardUtil AST#expression#Right . init AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left let AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left len = AST#expression#Left AST#member_expression#Left AST#expression#Left idCard AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left len AST#expression#Right == AST#expression#Left IdCardUtil AST#expression#Right AST#binary_expression#Right AST#expression#Right . CHINA_ID_MIN_LENGTH AST#member_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left len AST#expression#Right == AST#expression#Left IdCardUtil AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . CHINA_ID_MAX_LENGTH AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left let AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left district = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left IdCardUtil AST#expression#Right . DISTRICT_CODES AST#member_expression#Right AST#expression#Right . get 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 idCard AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left 6 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#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left district AST#expression#Right AST#unary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left return 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 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#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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left OutDTO AST#expression#Right . OKByDataRow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left district AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left idCard AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left 6 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 } else { AST#expression_statement#Left AST#expression#Left return 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 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#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
static getDistrictCodeByIdCard(idCard: string): OutDTO<string> { if (IdCardUtil.PROVINCE_CODES.size == 0) { IdCardUtil.init(); } let len = idCard.length; if (len == IdCardUtil.CHINA_ID_MIN_LENGTH || len == IdCardUtil.CHINA_ID_MAX_LENGTH) { let district = IdCardUtil.DISTRICT_CODES.get(idCard.substring(0, 6)); if (!district) { return OutDTO.Error("根据身份证号获取区域信息错误"); } return OutDTO.OKByDataRow(district.toString(), idCard.substring(0, 6)); } else { return OutDTO.Error("身份证长度不正确"); } }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_core/src/main/ets/core/util/IdCardUtil.ets#L280-L294
c1339291f5806163ca977beb61939ed80b0707d8
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/BasicFeature/Media/VideoTrimmer/entry/src/main/ets/videotrimmer/RangeSeekBarView.ets
arkts
视频播放状态
export class MediaPlayerStatus { public redLineProgress: number = 0; // [0,1] public isPlaying: boolean = false; // true播放 false暂停 }
AST#export_declaration#Left export AST#class_declaration#Left class MediaPlayerStatus AST#class_body#Left { AST#property_declaration#Left public redLineProgress : 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 // [0,1] AST#property_declaration#Left public isPlaying : 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 // true播放 false暂停 } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class MediaPlayerStatus { public redLineProgress: number = 0; public isPlaying: boolean = false; }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/BasicFeature/Media/VideoTrimmer/entry/src/main/ets/videotrimmer/RangeSeekBarView.ets#L31-L34
d9a69106adab1b68a34187998b82886aaed74c4b
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/SimpleBirthdayApp.ets
arkts
buildSettingsItem
构建设置项
@Builder buildSettingsItem(item: SettingsItem, isLast: boolean) { Row({ space: 12 }) { Column({ space: 2 }) { Text(item.title) .fontSize(14) .fontWeight(FontWeight.Medium) .fontColor('#333333') .alignSelf(ItemAlign.Start) Text(item.subtitle) .fontSize(12) .fontColor('#666666') .alignSelf(ItemAlign.Start) } .alignItems(HorizontalAlign.Start) .layoutWeight(1) if (item.hasSwitch) { Toggle({ type: ToggleType.Switch, isOn: item.enabled }) .width(40) .height(24) .selectedColor('#4ECDC4') .onChange((isOn: boolean) => { promptAction.showToast({ message: `${item.title} ${isOn ? '已开启' : '已关闭'}`, duration: 1000 }); }) } else { Text('>') .fontSize(16) .fontColor('#cccccc') } } .width('100%') .padding(16) .backgroundColor('#ffffff') .onClick(() => { if (!item.hasSwitch) { promptAction.showToast({ message: `点击了 ${item.title}`, duration: 1000 }); } }) if (!isLast) { Divider() .color('#f0f0f0') .strokeWidth(1) .margin({ left: 16, right: 16 }) } }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildSettingsItem AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left SettingsItem AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left isLast : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 12 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 2 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . title AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#333333' AST#expression#Right ) AST#modifier_chain_expression#Left . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . subtitle 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 . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#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#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . hasSwitch AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Toggle ( AST#component_parameters#Left { AST#component_parameter#Left type : AST#expression#Left AST#member_expression#Left AST#expression#Left ToggleType AST#expression#Right . Switch AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left isOn : AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . enabled 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 40 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Left . selectedColor ( AST#expression#Left '#4ECDC4' AST#expression#Right ) AST#modifier_chain_expression#Left . onChange ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left isOn : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . title AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right AST#template_substitution#Left $ { AST#expression#Left AST#conditional_expression#Left AST#expression#Left isOn AST#expression#Right ? AST#expression#Left '已开启' AST#expression#Right : AST#expression#Left '已关闭' AST#expression#Right AST#conditional_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left 1000 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } else { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '>' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#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#ui_if_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#ffffff' AST#expression#Right ) AST#modifier_chain_expression#Left . 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#unary_expression#Left ! AST#expression#Left item AST#expression#Right AST#unary_expression#Right AST#expression#Right . hasSwitch 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 promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` 点击了 AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . title 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 duration AST#property_name#Right : AST#expression#Left 1000 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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#unary_expression#Left ! AST#expression#Left isLast AST#expression#Right AST#unary_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Divider ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . color ( AST#expression#Left '#f0f0f0' AST#expression#Right ) AST#modifier_chain_expression#Left . strokeWidth ( AST#expression#Left 1 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#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder buildSettingsItem(item: SettingsItem, isLast: boolean) { Row({ space: 12 }) { Column({ space: 2 }) { Text(item.title) .fontSize(14) .fontWeight(FontWeight.Medium) .fontColor('#333333') .alignSelf(ItemAlign.Start) Text(item.subtitle) .fontSize(12) .fontColor('#666666') .alignSelf(ItemAlign.Start) } .alignItems(HorizontalAlign.Start) .layoutWeight(1) if (item.hasSwitch) { Toggle({ type: ToggleType.Switch, isOn: item.enabled }) .width(40) .height(24) .selectedColor('#4ECDC4') .onChange((isOn: boolean) => { promptAction.showToast({ message: `${item.title} ${isOn ? '已开启' : '已关闭'}`, duration: 1000 }); }) } else { Text('>') .fontSize(16) .fontColor('#cccccc') } } .width('100%') .padding(16) .backgroundColor('#ffffff') .onClick(() => { if (!item.hasSwitch) { promptAction.showToast({ message: `点击了 ${item.title}`, duration: 1000 }); } }) if (!isLast) { Divider() .color('#f0f0f0') .strokeWidth(1) .margin({ left: 16, right: 16 }) } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/SimpleBirthdayApp.ets#L1373-L1426
28e67de577760b4c0666c6cca0d7389ed57638b3
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/share/SharePage.ets
arkts
buildTemplateDialog
构建模板选择对话框
@Builder buildTemplateDialog() { Column({ space: UIConstants.DEFAULT_PADDING }) { Text('选择分享模板') .fontSize(UIConstants.FONT_SIZE_HEADING) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.text_primary')) Scroll() { Column({ space: UIConstants.SMALL_PADDING }) { ForEach(this.shareTemplates, (template: ShareTemplate) => { Row({ space: UIConstants.DEFAULT_PADDING }) { Column({ space: 4 }) { Text(template.name) .fontSize(UIConstants.FONT_SIZE_BODY) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.text_primary')) Text(template.description) .fontSize(UIConstants.FONT_SIZE_CAPTION) .fontColor($r('app.color.text_secondary')) .maxLines(2) .textOverflow({ overflow: TextOverflow.Ellipsis }) Row({ space: 4 }) { ForEach(template.tags.slice(0, 3), (tag: string) => { Text(tag) .fontSize(UIConstants.FONT_SIZE_CAPTION) .fontColor($r('app.color.primary')) .padding({ left: 6, right: 6, top: 2, bottom: 2 }) .backgroundColor($r('app.color.primary_background')) .borderRadius(4) }) } .margin({ top: 4 }) } .layoutWeight(1) .alignItems(HorizontalAlign.Start) Button('使用') .type(ButtonType.Normal) .backgroundColor(this.selectedTemplate === template.id ? $r('app.color.primary') : $r('app.color.secondary')) .fontColor(Color.White) .fontSize(UIConstants.FONT_SIZE_CAPTION) .padding({ left: 12, right: 12, top: 6, bottom: 6 }) .onClick(() => this.useTemplate(template.id)) } .width('100%') .padding(UIConstants.DEFAULT_PADDING) .backgroundColor($r('app.color.card_background')) .borderRadius(UIConstants.BORDER_RADIUS) }) } } .layoutWeight(1) } .width('100%') .height('100%') .padding(UIConstants.LARGE_PADDING) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildTemplateDialog AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left AST#member_expression#Left AST#expression#Left UIConstants AST#expression#Right . DEFAULT_PADDING AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '选择分享模板' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left UIConstants AST#expression#Right . FONT_SIZE_HEADING AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_primary' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Scroll ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left AST#member_expression#Left AST#expression#Left UIConstants AST#expression#Right . SMALL_PADDING AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#for_each_statement#Left ForEach ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . shareTemplates AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left template : AST#type_annotation#Left AST#primary_type#Left ShareTemplate 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 Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left AST#member_expression#Left AST#expression#Left UIConstants AST#expression#Right . DEFAULT_PADDING AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 4 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left template AST#expression#Right . name AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left UIConstants AST#expression#Right . FONT_SIZE_BODY AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_primary' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left template AST#expression#Right . description AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left UIConstants AST#expression#Right . FONT_SIZE_CAPTION AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_secondary' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . maxLines ( AST#expression#Left 2 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#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 4 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 template AST#expression#Right . tags 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 3 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 tag : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left tag AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left UIConstants AST#expression#Right . FONT_SIZE_CAPTION AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.primary' 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 6 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 6 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 2 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom 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#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.primary_background' 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#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#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 4 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#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 . type ( AST#expression#Left AST#member_expression#Left AST#expression#Left ButtonType AST#expression#Right . Normal AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedTemplate AST#member_expression#Right AST#expression#Right === AST#expression#Left template AST#expression#Right AST#binary_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.primary' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.secondary' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left UIConstants AST#expression#Right . FONT_SIZE_CAPTION AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 6 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 6 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#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . useTemplate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left template 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#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 . padding ( AST#expression#Left AST#member_expression#Left AST#expression#Left UIConstants AST#expression#Right . DEFAULT_PADDING AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.card_background' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#member_expression#Left AST#expression#Left UIConstants AST#expression#Right . BORDER_RADIUS 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_arrow_function_body#Right AST#ui_builder_arrow_function#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . 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#member_expression#Left AST#expression#Left UIConstants AST#expression#Right . LARGE_PADDING AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder buildTemplateDialog() { Column({ space: UIConstants.DEFAULT_PADDING }) { Text('选择分享模板') .fontSize(UIConstants.FONT_SIZE_HEADING) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.text_primary')) Scroll() { Column({ space: UIConstants.SMALL_PADDING }) { ForEach(this.shareTemplates, (template: ShareTemplate) => { Row({ space: UIConstants.DEFAULT_PADDING }) { Column({ space: 4 }) { Text(template.name) .fontSize(UIConstants.FONT_SIZE_BODY) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.text_primary')) Text(template.description) .fontSize(UIConstants.FONT_SIZE_CAPTION) .fontColor($r('app.color.text_secondary')) .maxLines(2) .textOverflow({ overflow: TextOverflow.Ellipsis }) Row({ space: 4 }) { ForEach(template.tags.slice(0, 3), (tag: string) => { Text(tag) .fontSize(UIConstants.FONT_SIZE_CAPTION) .fontColor($r('app.color.primary')) .padding({ left: 6, right: 6, top: 2, bottom: 2 }) .backgroundColor($r('app.color.primary_background')) .borderRadius(4) }) } .margin({ top: 4 }) } .layoutWeight(1) .alignItems(HorizontalAlign.Start) Button('使用') .type(ButtonType.Normal) .backgroundColor(this.selectedTemplate === template.id ? $r('app.color.primary') : $r('app.color.secondary')) .fontColor(Color.White) .fontSize(UIConstants.FONT_SIZE_CAPTION) .padding({ left: 12, right: 12, top: 6, bottom: 6 }) .onClick(() => this.useTemplate(template.id)) } .width('100%') .padding(UIConstants.DEFAULT_PADDING) .backgroundColor($r('app.color.card_background')) .borderRadius(UIConstants.BORDER_RADIUS) }) } } .layoutWeight(1) } .width('100%') .height('100%') .padding(UIConstants.LARGE_PADDING) }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/share/SharePage.ets#L426-L485
9ff26ac9c30db4b504a551381212e109cb43f4ae
github
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/data/DataSet.ets
arkts
setValues
/** * This method is deprecated. * Use setEntries(...) instead. * * @param values @Deprecated
public setValues(values: JArrayList<T>): void { this.setEntries(values); }
AST#method_declaration#Left public setValues AST#parameter_list#Left ( AST#parameter#Left values : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left JArrayList AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . setEntries AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left values 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 setValues(values: JArrayList<T>): void { this.setEntries(values); }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/data/DataSet.ets#L159-L161
e7a3074d674d426ac94e0f91c67768264521d302
gitee
sithvothykiv/dialog_hub.git
b676c102ef2d05f8994d170abe48dcc40cd39005
custom_dialog/src/main/ets/core/DialogBuilder.ets
arkts
ActionSheetDialogBuilder
/** * 底部滑出菜单弹窗view * @param options @Builder export function BottomSheetDialogBuilder(options: IBottomSheetOptions) { BottomSheetDialogView({ options: options }); } 菜单弹窗view @param options
@Builder export function ActionSheetDialogBuilder(options: IBottomSheetOptions) { ActionSheetDialogView({ options: options }); }
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function ActionSheetDialogBuilder AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left IBottomSheetOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_custom_component_statement#Left ActionSheetDialogView ( AST#component_parameters#Left { AST#component_parameter#Left options : AST#expression#Left options AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right } AST#builder_function_body#Right AST#decorated_export_declaration#Right
@Builder export function ActionSheetDialogBuilder(options: IBottomSheetOptions) { ActionSheetDialogView({ options: options }); }
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/core/DialogBuilder.ets#L251-L254
d8cd001f206c43dbaccf0bdfcbf7ea6e9d4d52a6
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Media/ImageEdit/entry/src/main/ets/utils/MathUtils.ets
arkts
limitRectInRotatedBasedOnPoint
Based on point rotating, limit rect. @param baseIndex @param rect @param rotatedLines
static limitRectInRotatedBasedOnPoint(baseIndex: number, rect: RectF, rotatedLines: Array<LineSegment>): void { let points = MathUtils.rectToPoints(rect); let base = points[baseIndex]; points.splice(baseIndex, 1); let scale = 1; for (let point of points) { let line = new LineSegment(base, point); for (let rotatedLine of rotatedLines) { if (MathUtils.hasIntersection(line, rotatedLine)) { let p = MathUtils.getIntersection(line, rotatedLine); if (p == undefined) { continue; } let tempScale = Math.hypot(p.x - base.x, p.y - base.y) / Math.hypot(point.x - base.x, point.y - base.y); scale = Math.min(scale, (tempScale > CommonConstants.EQUALITY_THRESHOLD) ? tempScale : 1); } } } MathUtils.scaleRectBasedOnPoint(rect, base, scale); } /** * Get max fixed rect size. * @param rate * @param maxWidth * @param maxHeight * @returns rect width and height. */ static getMaxFixedRectSize(rate: number, maxWidth: number, maxHeight: number): Array<number> { let width = 0; let height = 0; if (rate > (maxWidth / maxHeight)) { width = maxWidth; height = width / rate; } else { height = maxHeight; width = height * rate; } return [width, height]; } /** * Get min fixed rect size. * @param rate * @param minLength * @returns rect width and height. */ static getMinFixedRectSize(rate: number, minLength: number): Array<number> { let width = minLength; let height = minLength; if (rate > 1) { width = height * rate; } else { height = width / rate; } return [width, height]; } /** * Determine whether it is the same rectangle. * @param rect1 * @param rect2 * @returns true means same, false means not same. */ static areRectsSame(rect1: RectF, rect2: RectF): boolean { if (rect1.left == rect2.left && rect1.top == rect2.top && rect1.right == rect2.right && rect1.bottom == rect2.bottom) { return true; }
AST#method_declaration#Left static limitRectInRotatedBasedOnPoint AST#parameter_list#Left ( AST#parameter#Left baseIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left rect : AST#type_annotation#Left AST#primary_type#Left RectF AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left rotatedLines : 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 LineSegment 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#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left points = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left MathUtils AST#expression#Right . rectToPoints AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left rect 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 base = AST#expression#Left AST#subscript_expression#Left AST#expression#Left points AST#expression#Right [ AST#expression#Left baseIndex 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 points AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left baseIndex AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left scale = AST#expression#Left 1 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( let point of AST#expression#Left points AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left line = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left LineSegment AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left base AST#expression#Right , AST#expression#Left point 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 ( let rotatedLine of AST#expression#Left rotatedLines AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left MathUtils AST#expression#Right . hasIntersection AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left line AST#expression#Right , AST#expression#Left rotatedLine AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left p = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left MathUtils AST#expression#Right . getIntersection AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left line AST#expression#Right , AST#expression#Left rotatedLine 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 p 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#continue_statement#Left continue ; AST#continue_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left tempScale = 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 Math AST#expression#Right . hypot 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 p AST#expression#Right . x AST#member_expression#Right AST#expression#Right - AST#expression#Left base AST#expression#Right AST#binary_expression#Right AST#expression#Right . x AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left p AST#expression#Right . y AST#member_expression#Right AST#expression#Right - AST#expression#Left base AST#expression#Right AST#binary_expression#Right AST#expression#Right . y AST#member_expression#Right 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 . hypot 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 point AST#expression#Right . x AST#member_expression#Right AST#expression#Right - AST#expression#Left base AST#expression#Right AST#binary_expression#Right AST#expression#Right . x AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left point AST#expression#Right . y AST#member_expression#Right AST#expression#Right - AST#expression#Left base AST#expression#Right AST#binary_expression#Right AST#expression#Right . y AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left scale = AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . min AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#ERROR#Left ( AST#expression#Left scale AST#expression#Right , AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left tempScale AST#expression#Right > AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . EQUALITY_THRESHOLD AST#member_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 tempScale AST#expression#Right AST#ERROR#Left : 1 ) ; } } } MathUtils AST#ERROR#Right . scaleRectBasedOnPoint AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left rect AST#expression#Right , AST#expression#Left base AST#expression#Right , AST#expression#Left scale AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right /** * Get max fixed rect size. * @param rate * @param maxWidth * @param maxHeight * @returns rect width and height. */ AST#statement#Left AST#expression_statement#Left AST#expression#Left static 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 getMaxFixedRectSize AST#expression#Right AST#argument_list#Left ( AST#expression#Left rate AST#expression#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right , AST#expression#Left maxWidth AST#expression#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right , AST#expression#Left AST#assignment_expression#Left maxHeight AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ) : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right { let width AST#ERROR#Right = AST#expression#Left 0 AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left height = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left rate AST#expression#Right > AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left maxWidth AST#expression#Right / AST#expression#Left maxHeight AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left width = AST#expression#Left maxWidth 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 height = AST#expression#Left AST#binary_expression#Left AST#expression#Left width AST#expression#Right / AST#expression#Left rate AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left height = AST#expression#Left maxHeight 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 width = AST#expression#Left AST#binary_expression#Left AST#expression#Left height AST#expression#Right * AST#expression#Left rate AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ AST#expression#Left width AST#expression#Right , AST#expression#Left height AST#expression#Right ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right /** * Get min fixed rect size. * @param rate * @param minLength * @returns rect width and height. */ AST#statement#Left AST#expression_statement#Left AST#expression#Left static AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left getMinFixedRectSize AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left ( AST#expression#Left rate AST#expression#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right , minLength AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ) AST#ERROR#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 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#ERROR#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left width = AST#expression#Left minLength 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 height = AST#expression#Left minLength 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 rate AST#expression#Right > AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left width = AST#expression#Left AST#binary_expression#Left AST#expression#Left height AST#expression#Right * AST#expression#Left rate AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left height = AST#expression#Left AST#binary_expression#Left AST#expression#Left width AST#expression#Right / AST#expression#Left rate AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ AST#expression#Left width AST#expression#Right , AST#expression#Left height AST#expression#Right ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right /** * Determine whether it is the same rectangle. * @param rect1 * @param rect2 * @returns true means same, false means not same. */ AST#statement#Left AST#expression_statement#Left AST#expression#Left static 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 areRectsSame AST#expression#Right AST#argument_list#Left ( AST#expression#Left rect1 AST#expression#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left RectF AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left rect2 AST#expression#Right AST#ERROR#Left : AST#ERROR#Left AST#type_annotation#Left AST#primary_type#Left RectF AST#primary_type#Right AST#type_annotation#Right ) : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right { if AST#ERROR#Right ( AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left rect1 . left AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right == AST#expression#Left rect2 AST#expression#Right AST#binary_expression#Right AST#expression#Right . left AST#member_expression#Right AST#expression#Right && AST#expression#Left rect1 AST#expression#Right AST#binary_expression#Right AST#expression#Right . top AST#member_expression#Right AST#expression#Right == AST#expression#Left rect2 AST#expression#Right AST#binary_expression#Right AST#expression#Right . top AST#member_expression#Right AST#expression#Right && AST#expression#Left rect1 AST#expression#Right AST#binary_expression#Right AST#expression#Right . right AST#member_expression#Right AST#expression#Right == AST#expression#Left rect2 AST#expression#Right AST#binary_expression#Right AST#expression#Right . right AST#member_expression#Right AST#expression#Right && AST#expression#Left rect1 AST#expression#Right AST#binary_expression#Right AST#expression#Right . bottom AST#member_expression#Right AST#expression#Right == AST#expression#Left rect2 AST#expression#Right AST#binary_expression#Right AST#expression#Right . bottom 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#object_literal#Left { AST#property_assignment#Left return AST#property_assignment#Right AST#object_literal#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static limitRectInRotatedBasedOnPoint(baseIndex: number, rect: RectF, rotatedLines: Array<LineSegment>): void { let points = MathUtils.rectToPoints(rect); let base = points[baseIndex]; points.splice(baseIndex, 1); let scale = 1; for (let point of points) { let line = new LineSegment(base, point); for (let rotatedLine of rotatedLines) { if (MathUtils.hasIntersection(line, rotatedLine)) { let p = MathUtils.getIntersection(line, rotatedLine); if (p == undefined) { continue; } let tempScale = Math.hypot(p.x - base.x, p.y - base.y) / Math.hypot(point.x - base.x, point.y - base.y); scale = Math.min(scale, (tempScale > CommonConstants.EQUALITY_THRESHOLD) ? tempScale : 1); } } } MathUtils.scaleRectBasedOnPoint(rect, base, scale); } static getMaxFixedRectSize(rate: number, maxWidth: number, maxHeight: number): Array<number> { let width = 0; let height = 0; if (rate > (maxWidth / maxHeight)) { width = maxWidth; height = width / rate; } else { height = maxHeight; width = height * rate; } return [width, height]; } static getMinFixedRectSize(rate: number, minLength: number): Array<number> { let width = minLength; let height = minLength; if (rate > 1) { width = height * rate; } else { height = width / rate; } return [width, height]; } static areRectsSame(rect1: RectF, rect2: RectF): boolean { if (rect1.left == rect2.left && rect1.top == rect2.top && rect1.right == rect2.right && rect1.bottom == rect2.bottom) { return true; }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Media/ImageEdit/entry/src/main/ets/utils/MathUtils.ets#L320-L389
fd4d29b6501975448629228587dd5c6898b03127
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/entry2ability/Entry2Ability.ets
arkts
onWindowStageCreate
[EndExclude allow_subsequent_rendering_to_use_ui]
onWindowStageCreate(windowStage: window.WindowStage): void { windowStage.loadContent('pages/Index', (err, data) => { if (err.code) { return; } // 保存 UIContext, 在后续的同层渲染绘制中会用到。 AppStorage.setOrCreate<UIContext>('UIContext', windowStage.getMainWindowSync().getUIContext()); }); }
AST#method_declaration#Left onWindowStageCreate AST#parameter_list#Left ( AST#parameter#Left windowStage : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . WindowStage AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#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 windowStage AST#expression#Right . loadContent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'pages/Index' AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right , AST#parameter#Left data AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code 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 // 保存 UIContext, 在后续的同层渲染绘制中会用到。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left 'UIContext' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowStage AST#expression#Right . getMainWindowSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getUIContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) 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
onWindowStageCreate(windowStage: window.WindowStage): void { windowStage.loadContent('pages/Index', (err, data) => { if (err.code) { return; } AppStorage.setOrCreate<UIContext>('UIContext', windowStage.getMainWindowSync().getUIContext()); }); }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/entry2ability/Entry2Ability.ets#L31-L39
d2e8f52bdec98bcfd0937ca5e59e12813a5f70cd
gitee
awa_Liny/LinysBrowser_NEXT
a5cd96a9aa8114cae4972937f94a8967e55d4a10
home/src/main/ets/hosts/bunch_of_downloads.ets
arkts
init_delegate
Initializes the download delegate for blob downloads. Delegate: AppStorage.get('dl_delegate')
init_delegate(storage: LocalStorage) { // Init blob_delegate let dl_delegate = storage.get('dl_delegate') as webview.WebDownloadDelegate; dl_delegate.onBeforeDownload((webDownloadItem: webview.WebDownloadItem) => { console.log('[bunch_of_downloads][init_delegate] onBeforeDownload: [' + webDownloadItem.getSuggestedFileName() + '][' + webDownloadItem.getUrl() + ']'); // See meowWebView and woofWantDownload for further handling storage.set('uni_webDownloadItem_gateway', webDownloadItem); this.update_timestamp(); }) dl_delegate.onDownloadUpdated((webDownloadItem: webview.WebDownloadItem) => { this.onDownloadUpdated(webDownloadItem); }) dl_delegate.onDownloadFailed((webDownloadItem: webview.WebDownloadItem) => { let index = this.index_of_task(webDownloadItem); console.error("[bunch_of_downloads] download failed index: " + index); console.error("[bunch_of_downloads] download failed guid: " + webDownloadItem.getGuid()); console.error("[bunch_of_downloads] download failed error: " + webDownloadItem.getLastErrorCode()); this.list_of_failed[index] = true; this.list_of_paused[index] = true; this.last_action = Date.now(); }) dl_delegate.onDownloadFinish((webDownloadItem: webview.WebDownloadItem) => { this.onDownloadFinish(webDownloadItem, storage); }) }
AST#method_declaration#Left init_delegate AST#parameter_list#Left ( AST#parameter#Left storage : AST#type_annotation#Left AST#primary_type#Left LocalStorage AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { // Init blob_delegate AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left dl_delegate = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left storage AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'dl_delegate' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left webview . WebDownloadDelegate AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dl_delegate AST#expression#Right . onBeforeDownload 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 webDownloadItem : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left webview . WebDownloadItem AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#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#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 '[bunch_of_downloads][init_delegate] onBeforeDownload: [' AST#expression#Right + AST#expression#Left webDownloadItem AST#expression#Right AST#binary_expression#Right AST#expression#Right . getSuggestedFileName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left '][' AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left webDownloadItem AST#expression#Right AST#binary_expression#Right AST#expression#Right . getUrl AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left ']' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // See meowWebView and woofWantDownload for further handling AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left storage AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'uni_webDownloadItem_gateway' AST#expression#Right , AST#expression#Left webDownloadItem 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 . update_timestamp 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#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dl_delegate AST#expression#Right . onDownloadUpdated 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 webDownloadItem : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left webview . WebDownloadItem AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onDownloadUpdated AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left webDownloadItem 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dl_delegate AST#expression#Right . onDownloadFailed 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 webDownloadItem : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left webview . WebDownloadItem 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 index = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . index_of_task AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left webDownloadItem AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left "[bunch_of_downloads] download failed index: " AST#expression#Right + AST#expression#Left index 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 . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left "[bunch_of_downloads] download failed guid: " AST#expression#Right + AST#expression#Left webDownloadItem AST#expression#Right AST#binary_expression#Right AST#expression#Right . getGuid 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 console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left "[bunch_of_downloads] download failed error: " AST#expression#Right + AST#expression#Left webDownloadItem AST#expression#Right AST#binary_expression#Right AST#expression#Right . getLastErrorCode 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#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . list_of_failed AST#member_expression#Right AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . list_of_paused AST#member_expression#Right AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#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 . last_action AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Date AST#expression#Right . now AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dl_delegate AST#expression#Right . onDownloadFinish 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 webDownloadItem : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left webview . WebDownloadItem AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onDownloadFinish AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left webDownloadItem AST#expression#Right , AST#expression#Left storage AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
init_delegate(storage: LocalStorage) { let dl_delegate = storage.get('dl_delegate') as webview.WebDownloadDelegate; dl_delegate.onBeforeDownload((webDownloadItem: webview.WebDownloadItem) => { console.log('[bunch_of_downloads][init_delegate] onBeforeDownload: [' + webDownloadItem.getSuggestedFileName() + '][' + webDownloadItem.getUrl() + ']'); storage.set('uni_webDownloadItem_gateway', webDownloadItem); this.update_timestamp(); }) dl_delegate.onDownloadUpdated((webDownloadItem: webview.WebDownloadItem) => { this.onDownloadUpdated(webDownloadItem); }) dl_delegate.onDownloadFailed((webDownloadItem: webview.WebDownloadItem) => { let index = this.index_of_task(webDownloadItem); console.error("[bunch_of_downloads] download failed index: " + index); console.error("[bunch_of_downloads] download failed guid: " + webDownloadItem.getGuid()); console.error("[bunch_of_downloads] download failed error: " + webDownloadItem.getLastErrorCode()); this.list_of_failed[index] = true; this.list_of_paused[index] = true; this.last_action = Date.now(); }) dl_delegate.onDownloadFinish((webDownloadItem: webview.WebDownloadItem) => { this.onDownloadFinish(webDownloadItem, storage); }) }
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/hosts/bunch_of_downloads.ets#L37-L67
2b02a6b764780785146676e4b1e6031eff2fa6e2
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/cardswiperanimation/src/main/ets/view/CardSwiper.ets
arkts
CardSwiperAnimationComponent
功能说明:本示例通过Swiper、Image组件实现卡片预览效果和滚动切换, 通过linearGradient实现主题背景色渐变和滑动边缘渐变 推荐场景:不同比例卡片滚动切换、主题色随卡片中图片渐变 核心组件: 1. CardSwiperComponent: 卡片组件滚动切换组件, 叠底渐变背景, 遮盖渐变边缘 2. CardComponent: 卡片子组件, 展示全模态窗图片或缩略图 实现步骤: 1. 构建 initCardsList 数组, 向组件中传入初始化内容; 数组中每项包括 src: 图片路径, with: 单卡片宽度, height: 单卡片高度 根据想要展示的比例设置对应宽度和高度,如宽: 高为1: 2展示时, width配置为1倍的CARD_UNIT_LENGTH, height配置为2倍的CARD_UNIT_LENGTH @example this.initCardsList = [ 卡片比例 1 x 1 { src: $r('app.media.panda'), width: Constants.CARD_UNIT_LENGTH, height: Constants.CARD_UNIT_LENGTH }, 卡片比例 1 x 2 { src: $r('app.media.kangaroo'), width: Constants.CARD_UNIT_LENGTH, height: 2 * Constants.CARD_UNIT_LENGTH }, 卡片比例 2 x 1 { src: $r('app.media.bear'), width: 2 * Constants.CARD_UNIT_LENGTH, height: Constants.CARD_UNIT_LENGTH }, 卡片比例 2 x 2 { src: $r('app.media.parrot'), width: 2 * Constants.CARD_UNIT_LENGTH, height: 2 * Constants.CARD_UNIT_LENGTH }, ]; 2. 打开或关闭边缘渐变和主题渐变, isEdgeFading配置为滑动边缘渐变, isBackgroundColorChange配置为主题背景渐变 如需调整边缘渐变的颜色、宽度, 则修改Constants中边缘渐变配置的部分, 如:BEGIN_COLOR 如需调整主题背景渐变的方向、宽度, 则修改Constants中背景渐变配置的部分, 如:LINEAR_GRADIENT_ANGLE @example isEdgeFading : boolean = true; isBackgroundColorChange : boolean = true; isShowPreviewImage : boolean = true; 3. 构建 CardSwiperComponent 卡片组件滚动切换组件 @example CardSwiperComponent({ initCardsList : this.initCardsList isEdgeFading : this.isEdgeFading, isBackgroundColorChange: this.isBackgroundColorChange, isShowPreviewImage : this.isShowPreviewImage })
@Component export struct CardSwiperAnimationComponent { // 卡片列表 initCardsList : CardInfo[] = []; // 边缘渐变 isEdgeFading : boolean = true; // 主题背景渐变 isBackgroundColorChange : boolean = true; // 开启预览大图 isShowPreviewImage : boolean = true; aboutToAppear() :void { this.initCardsList = [ // 卡片比例 1 x 1 { src: $r('app.media.panda'), width: Constants.CARD_UNIT_LENGTH, height: Constants.CARD_UNIT_LENGTH }, // 卡片比例 1 x 2 { src: $r('app.media.kangaroo'), width: Constants.CARD_UNIT_LENGTH, height: 2 * Constants.CARD_UNIT_LENGTH }, // 卡片比例 2 x 1 { src: $r('app.media.bear'), width: 2 * Constants.CARD_UNIT_LENGTH, height: Constants.CARD_UNIT_LENGTH }, // 卡片比例 2 x 2 { src: $r('app.media.parrot'), width: 2 * Constants.CARD_UNIT_LENGTH, height: 2 * Constants.CARD_UNIT_LENGTH }, ]; } build() { Column() { /** * 卡片组件滚动切换 * initCardsList: 初始化数据列表 * isEdgeFading: 边缘渐变开启 * isBackgroundColorChange: 主题背景渐变开启 * isShowPreviewImage : 预览大图开启 */ CardSwiperComponent({ initCardsList : this.initCardsList, isEdgeFading : this.isEdgeFading, isBackgroundColorChange: this.isBackgroundColorChange, isShowPreviewImage : this.isShowPreviewImage }) .height($r('app.string.card_swiper_component_size')) } .height($r('app.string.card_swiper_animation_component_size')) .width($r('app.string.card_swiper_animation_component_size')) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct CardSwiperAnimationComponent AST#component_body#Left { // 卡片列表 AST#property_declaration#Left initCardsList : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left CardInfo [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right // 边缘渐变 AST#property_declaration#Left isEdgeFading : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right // 主题背景渐变 AST#property_declaration#Left isBackgroundColorChange : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right // 开启预览大图 AST#property_declaration#Left isShowPreviewImage : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . initCardsList AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ // 卡片比例 1 x 1 AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left src AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.panda' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . CARD_UNIT_LENGTH AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . CARD_UNIT_LENGTH AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , // 卡片比例 1 x 2 AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left src AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.kangaroo' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . CARD_UNIT_LENGTH AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 2 AST#expression#Right * AST#expression#Left Constants AST#expression#Right AST#binary_expression#Right AST#expression#Right . CARD_UNIT_LENGTH AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , // 卡片比例 2 x 1 AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left src AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.bear' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 2 AST#expression#Right * AST#expression#Left Constants AST#expression#Right AST#binary_expression#Right AST#expression#Right . CARD_UNIT_LENGTH AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . CARD_UNIT_LENGTH AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , // 卡片比例 2 x 2 AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left src AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.parrot' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 2 AST#expression#Right * AST#expression#Left Constants AST#expression#Right AST#binary_expression#Right AST#expression#Right . CARD_UNIT_LENGTH AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 2 AST#expression#Right * AST#expression#Left Constants AST#expression#Right AST#binary_expression#Right AST#expression#Right . CARD_UNIT_LENGTH AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , ] AST#array_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 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 { /** * 卡片组件滚动切换 * initCardsList: 初始化数据列表 * isEdgeFading: 边缘渐变开启 * isBackgroundColorChange: 主题背景渐变开启 * isShowPreviewImage : 预览大图开启 */ AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left CardSwiperComponent ( AST#component_parameters#Left { AST#component_parameter#Left initCardsList : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . initCardsList AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left isEdgeFading : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isEdgeFading AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left isBackgroundColorChange : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isBackgroundColorChange AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left isShowPreviewImage : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isShowPreviewImage AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.card_swiper_component_size' 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 . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.card_swiper_animation_component_size' 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.card_swiper_animation_component_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export struct CardSwiperAnimationComponent { initCardsList : CardInfo[] = []; isEdgeFading : boolean = true; isBackgroundColorChange : boolean = true; isShowPreviewImage : boolean = true; aboutToAppear() :void { this.initCardsList = [ { src: $r('app.media.panda'), width: Constants.CARD_UNIT_LENGTH, height: Constants.CARD_UNIT_LENGTH }, { src: $r('app.media.kangaroo'), width: Constants.CARD_UNIT_LENGTH, height: 2 * Constants.CARD_UNIT_LENGTH }, { src: $r('app.media.bear'), width: 2 * Constants.CARD_UNIT_LENGTH, height: Constants.CARD_UNIT_LENGTH }, { src: $r('app.media.parrot'), width: 2 * Constants.CARD_UNIT_LENGTH, height: 2 * Constants.CARD_UNIT_LENGTH }, ]; } build() { Column() { CardSwiperComponent({ initCardsList : this.initCardsList, isEdgeFading : this.isEdgeFading, isBackgroundColorChange: this.isBackgroundColorChange, isShowPreviewImage : this.isShowPreviewImage }) .height($r('app.string.card_swiper_component_size')) } .height($r('app.string.card_swiper_animation_component_size')) .width($r('app.string.card_swiper_animation_component_size')) } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/cardswiperanimation/src/main/ets/view/CardSwiper.ets#L59-L104
e65f58fdec79239b5551efadacaa8cde6dffe03d
gitee
wuyuanwuhui999/harmony-arkts-chat-app-ui.git
128861bc002adae9c34c6ce8fbf12686c26e51ec
entry/src/main/ets/utils/PreferenceModel.ets
arkts
setPassword
写入密码
async setPassword(userAccount: string, password: string) { await this.putPreference(userAccount, password); }
AST#method_declaration#Left async setPassword AST#parameter_list#Left ( AST#parameter#Left userAccount : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left password : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . putPreference AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left userAccount AST#expression#Right , AST#expression#Left password 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 setPassword(userAccount: string, password: string) { await this.putPreference(userAccount, password); }
https://github.com/wuyuanwuhui999/harmony-arkts-chat-app-ui.git/blob/128861bc002adae9c34c6ce8fbf12686c26e51ec/entry/src/main/ets/utils/PreferenceModel.ets#L100-L102
4274f538503b420d97a84652981374d464f252a3
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/pages/common.ets
arkts
aboutToResize
当布局大小发生变化时进行回调
aboutToResize(size: Size) { console.log('aboutToResize width : ' + size.width + ' height : ' + size.height ); }
AST#method_declaration#Left aboutToResize AST#parameter_list#Left ( AST#parameter#Left size : AST#type_annotation#Left AST#primary_type#Left Size 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 . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'aboutToResize width : ' AST#expression#Right + AST#expression#Left size AST#expression#Right AST#binary_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right + AST#expression#Left ' height : ' AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left size AST#expression#Right AST#binary_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
aboutToResize(size: Size) { console.log('aboutToResize width : ' + size.width + ' height : ' + size.height ); }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/pages/common.ets#L56-L58
495f0c3592c44378c3ce8d0bc7f54e10e15f0229
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/bottomdrawerslidecase/src/main/ets/view/BottomDrawerSlideCase.ets
arkts
窗口管理model
build() { Stack({ alignContent: Alignment.TopStart }) { RelativeContainer() { // Image地图 ImageMapView() .id('map') // list上部的标题栏 this.itemHead('安全出行季') /** * 抽屉视图 * @param { ()=>void } searchAddress - 搜索视图 * @param {()=>void} listBuilder - 列表视图 * @param { boolean } isShow - 控制标题栏是否显示 * @param {BottomDrawerHeight} BottomDrawerHeight - 列表阶段高度属性 */ BottomDrawer({ searchAddress: this.searchAddress, listBuilder: ()=>{ this.listBuilder(); }, isShow: this.isShow, bottomDrawerHeight: this.bottomDrawerHeight }) } /** * 顶部标题 * @param {boolean} isShow - 顶部遮蔽导航栏区域是否显示 */ TopTitle({ isShow: this.isShow }) .id('title_bar') }.width(CommonConstants.FULL_SIZE) .height(CommonConstants.FULL_SIZE) }
AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Stack ( AST#component_parameters#Left { AST#component_parameter#Left alignContent : AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . TopStart 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 RelativeContainer ( ) AST#container_content_body#Left { // Image地图 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ImageMapView ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . id ( AST#expression#Left 'map' AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // list上部的标题栏 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 . itemHead AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '安全出行季' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right /** * 抽屉视图 * @param { ()=>void } searchAddress - 搜索视图 * @param {()=>void} listBuilder - 列表视图 * @param { boolean } isShow - 控制标题栏是否显示 * @param {BottomDrawerHeight} BottomDrawerHeight - 列表阶段高度属性 */ AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left BottomDrawer ( AST#component_parameters#Left { AST#component_parameter#Left searchAddress : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . searchAddress AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left listBuilder : 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 . listBuilder AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left isShow : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isShow AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left bottomDrawerHeight : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bottomDrawerHeight 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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right /** * 顶部标题 * @param {boolean} isShow - 顶部遮蔽导航栏区域是否显示 */ AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left TopTitle ( AST#component_parameters#Left { AST#component_parameter#Left isShow : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isShow AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . id ( AST#expression#Left 'title_bar' AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FULL_SIZE AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FULL_SIZE 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#build_body#Right AST#build_method#Right
build() { Stack({ alignContent: Alignment.TopStart }) { RelativeContainer() { ImageMapView() .id('map') this.itemHead('安全出行季') BottomDrawer({ searchAddress: this.searchAddress, listBuilder: ()=>{ this.listBuilder(); }, isShow: this.isShow, bottomDrawerHeight: this.bottomDrawerHeight }) } TopTitle({ isShow: this.isShow }) .id('title_bar') }.width(CommonConstants.FULL_SIZE) .height(CommonConstants.FULL_SIZE) }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/bottomdrawerslidecase/src/main/ets/view/BottomDrawerSlideCase.ets#L82-L117
f4c7703ab29d0f8ae9dbfa2787f9deb93169844b
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/calendarswitch/src/main/ets/customcalendar/model/CalendarModel.ets
arkts
日期信息。用于选择日期回调
export interface CalendarData { year: number, // 年 month: number, // 月 date: number // 日 }
AST#export_declaration#Left export AST#interface_declaration#Left interface CalendarData 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 date : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right // 日 } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface CalendarData { year: number, month: number, date: number }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/calendarswitch/src/main/ets/customcalendar/model/CalendarModel.ets#L42-L46
2c045949f0063b214ac72ad3dcb7b72daeca3802
gitee
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
feature/demo/src/main/ets/viewmodel/NetworkListDemoViewModel.ets
arkts
@file Network List Demo 示例页 ViewModel @author Joker.X
@ObservedV2 export default class NetworkListDemoViewModel extends BaseNetWorkListViewModel<Goods> { /** * 商品仓库 */ private repository: GoodsRepository = new GoodsRepository(); /** * 请求商品分页数据 * @returns {Promise<NetworkResponse<NetworkPageData<Goods>>>} 网络请求 Promise */ protected requestListData(): Promise<NetworkResponse<NetworkPageData<Goods>>> { const request: GoodsSearchRequest = new GoodsSearchRequest(); request.page = this.currentPage; request.size = this.pageSize; return this.repository.getGoodsPage(request); } }
AST#decorated_export_declaration#Left AST#decorator#Left @ ObservedV2 AST#decorator#Right export default AST#class_declaration#Left class NetworkListDemoViewModel extends AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left BaseNetWorkListViewModel AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Goods AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#class_body#Left { /** * 商品仓库 */ AST#property_declaration#Left private repository : AST#type_annotation#Left AST#primary_type#Left GoodsRepository AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left GoodsRepository AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * 请求商品分页数据 * @returns {Promise<NetworkResponse<NetworkPageData<Goods>>>} 网络请求 Promise */ AST#method_declaration#Left protected requestListData AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left NetworkResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left NetworkPageData AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Goods 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#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 request : AST#type_annotation#Left AST#primary_type#Left GoodsSearchRequest 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 GoodsSearchRequest 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 request AST#expression#Right . page AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentPage AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left request AST#expression#Right . size AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . pageSize AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . repository AST#member_expression#Right AST#expression#Right . getGoodsPage 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#decorated_export_declaration#Right
@ObservedV2 export default class NetworkListDemoViewModel extends BaseNetWorkListViewModel<Goods> { private repository: GoodsRepository = new GoodsRepository(); protected requestListData(): Promise<NetworkResponse<NetworkPageData<Goods>>> { const request: GoodsSearchRequest = new GoodsSearchRequest(); request.page = this.currentPage; request.size = this.pageSize; return this.repository.getGoodsPage(request); } }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/feature/demo/src/main/ets/viewmodel/NetworkListDemoViewModel.ets#L9-L26
527ea69dace5baf4ee9f1f295fc0457d12a72314
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/game/InteractiveGameService.ets
arkts
游戏表现接口
export interface GamePerformance { accuracy: number; // 准确率 speed: number; // 速度得分 efficiency: number; // 效率得分 streak: number; // 连击数 perfectRounds: number; // 完美回合数 rating: PerformanceRating; }
AST#export_declaration#Left export AST#interface_declaration#Left interface GamePerformance AST#object_type#Left { AST#type_member#Left accuracy : 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 speed : 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 efficiency : 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 streak : 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 perfectRounds : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; // 完美回合数 AST#type_member#Left rating : AST#type_annotation#Left AST#primary_type#Left PerformanceRating 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 GamePerformance { accuracy: number; speed: number; efficiency: number; streak: number; perfectRounds: number; rating: PerformanceRating; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/game/InteractiveGameService.ets#L99-L106
8d24eac4f8975d1b700c6ef5ab5507b184000dfd
github
IceYuanyyy/OxHornCampus.git
bb5686f77fa36db89687502e35898cda218d601f
entry/src/main/ets/model/WindowModel.ets
arkts
setWindowStage
设置 WindowStage(在 EntryAbility 中调用) Set windowStage. @param windowStage The object of WindowStage.
setWindowStage(windowStage: window.WindowStage) { this.windowStage = windowStage; }
AST#method_declaration#Left setWindowStage AST#parameter_list#Left ( AST#parameter#Left windowStage : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . WindowStage AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . windowStage AST#member_expression#Right = AST#expression#Left windowStage AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
setWindowStage(windowStage: window.WindowStage) { this.windowStage = windowStage; }
https://github.com/IceYuanyyy/OxHornCampus.git/blob/bb5686f77fa36db89687502e35898cda218d601f/entry/src/main/ets/model/WindowModel.ets#L52-L54
8f14fa589462fd8caa2a6f47e89eb9265f8b9a06
github
openharmony/update_update_app
0157b7917e2f48e914b5585991e8b2f4bc25108a
feature/ota/src/main/ets/manager/OtaUpdateManager.ets
arkts
onReceivedUpdatePageMessage
收到page推送消息 @param otaStatus 状态数据
async onReceivedUpdatePageMessage(otaStatus: OtaStatus): Promise<void> { this.log('receives from onReceivedUpdatePageMessage:' + JSON.stringify(otaStatus)); this.notifyUpdateStatus(otaStatus, globalThis.abilityContext); }
AST#method_declaration#Left async onReceivedUpdatePageMessage AST#parameter_list#Left ( AST#parameter#Left otaStatus : AST#type_annotation#Left AST#primary_type#Left OtaStatus AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'receives from onReceivedUpdatePageMessage:' 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 otaStatus 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 this AST#expression#Right . notifyUpdateStatus AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left otaStatus AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left globalThis AST#expression#Right . abilityContext 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
async onReceivedUpdatePageMessage(otaStatus: OtaStatus): Promise<void> { this.log('receives from onReceivedUpdatePageMessage:' + JSON.stringify(otaStatus)); this.notifyUpdateStatus(otaStatus, globalThis.abilityContext); }
https://github.com/openharmony/update_update_app/blob/0157b7917e2f48e914b5585991e8b2f4bc25108a/feature/ota/src/main/ets/manager/OtaUpdateManager.ets#L358-L361
fcecfb7682e5057c8f44b98f66b3fc87e83ab733
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/goods/src/main/ets/viewmodel/GoodsDetailViewModel.ets
arkts
selectSpec
选择规格 @param {GoodsSpec} spec - 选中的规格
selectSpec(spec: GoodsSpec): void { // 如果点击的是已选中的规格,则取消选择 if (this.selectedSpec?.id === spec.id) { this.selectedSpec = null; } else { this.selectedSpec = spec; } }
AST#method_declaration#Left selectSpec AST#parameter_list#Left ( AST#parameter#Left spec : AST#type_annotation#Left AST#primary_type#Left GoodsSpec AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { // 如果点击的是已选中的规格,则取消选择 AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedSpec AST#member_expression#Right AST#expression#Right ?. id AST#member_expression#Right AST#expression#Right === AST#expression#Left spec AST#expression#Right AST#binary_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedSpec 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 } else { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedSpec AST#member_expression#Right = AST#expression#Left spec AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
selectSpec(spec: GoodsSpec): void { if (this.selectedSpec?.id === spec.id) { this.selectedSpec = null; } else { this.selectedSpec = spec; } }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/goods/src/main/ets/viewmodel/GoodsDetailViewModel.ets#L103-L110
512d60f5ecfe753953055fe9594e466c9631e368
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/components/Sounds/Cloud/Download/CBook/CBookPath.ets
arkts
/ CloudBookList 的名称
export const CBookListName : string = "BookList";
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left CBookListName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "BookList" AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
export const CBookListName : string = "BookList";
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/components/Sounds/Cloud/Download/CBook/CBookPath.ets#L27-L27
47e28a3b143df5244b0931a2addef3409f1fed63
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/StrUtil.ets
arkts
bytesToStr
Bytes转字符串 @param bytes @returns
public static bytesToStr(bytes: Uint8Array): string { let str = "" for (let i = 0; i < bytes.length; i++) { str += String.fromCharCode(bytes[i]); } return str; }
AST#method_declaration#Left public static bytesToStr AST#parameter_list#Left ( AST#parameter#Left bytes : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left str = AST#expression#Left "" AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left bytes AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left str += AST#expression#Left AST#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 AST#subscript_expression#Left AST#expression#Left bytes AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left str AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public static bytesToStr(bytes: Uint8Array): string { let str = "" for (let i = 0; i < bytes.length; i++) { str += String.fromCharCode(bytes[i]); } return str; }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/StrUtil.ets#L284-L291
841b4c9d3a990b6d0044b6a474b7e37780a47b3d
gitee
Hyricane/Interview_Success.git
9783273fe05fc8951b99bf32d3887c605268db8f
entry/src/main/ets/commons/components/QuestionListComp.ets
arkts
QuestionListComp
后端返回的数据类型 不一定要完整的写 用什么写什么 每一个分类的类型 interface CateItemType { id: number name: string icon: string }
@Component export struct QuestionListComp { @Prop activeIndex: number = 0 // 哪个tab被选中 将来应该更新哪个list @Prop index: number = 0 // 每个list对应的下标 @Prop @Watch('fn') sort: SortType = SortType.Default // 传入的分类id @Prop typeId: number @Prop keyword: string = '' @State list: QuestionItem[] = [] // 文章列表数据 暂时为空 @State isRefreshing: boolean = false // 是否是下拉状态 // 节流 请求前打开(true) 请求后关闭(false) @State isLoading: boolean = false // 标识当前加载状态 // 刚开始数据是加载了一部分 等到有一天数据真全获取完了 改true @State isFinished: boolean = false // 标识数据是否全部加载完 @State page: number = 1 // 页码 fn() { // 该我更新我才更新 if (this.activeIndex == this.index) { this.isRefreshing = true // 拉下来 } } async getList() { const res = await http.request<PageData>({ url: 'question/list', params: { questionBankType: 10, // 表示获取面试题 type: this.typeId, // 获取哪个分类 page: this.page, // 获取第几页 pageSize: 10, // 每页获取几条数据 sort: 0 ,// 10 11 20 21 30 表示排序方式 枚举优化一下 keyword: this.keyword, // 还有一些其他参数 } }) // this.list = res.rows // 面试题列表数据 return res }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct QuestionListComp AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right activeIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right // 哪个tab被选中 将来应该更新哪个list AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right // 每个list对应的下标 AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right AST#decorator#Left @ Watch ( AST#expression#Left 'fn' AST#expression#Right ) AST#decorator#Right sort : AST#type_annotation#Left AST#primary_type#Left SortType AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left SortType AST#expression#Right . Default AST#member_expression#Right AST#expression#Right // 传入的分类id AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right typeId : 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 @ Prop AST#decorator#Right keyword : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right list : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left QuestionItem [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right // 文章列表数据 暂时为空 AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right isRefreshing : 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 // 是否是下拉状态 // 节流 请求前打开(true) 请求后关闭(false) AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right isLoading : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right // 标识当前加载状态 // 刚开始数据是加载了一部分 等到有一天数据真全获取完了 改true AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right isFinished : 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#ERROR#Left AST#decorator#Left @ State AST#decorator#Right page : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#ERROR#Left AST#expression#Left AST#call_expression#Left AST#expression#Left 1 AST#expression#Right // 页码 AST#ERROR#Left fn AST#ERROR#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 AST#as_expression#Left AST#expression#Left AST#object_literal#Left { // 该我更新我才更新 AST#property_assignment#Left AST#property_name#Left if AST#property_name#Right AST#parameter_list#Left ( AST#parameter#Left this AST#parameter#Right AST#ERROR#Left . activeIndex == this . in dex AST#ERROR#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 . isRefreshing 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#property_assignment#Right } AST#object_literal#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left ync AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#ERROR#Left get List AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right { AST#property_name#Left const AST#property_name#Right res = AST#ERROR#Right AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left http AST#expression#Right AST#await_expression#Right AST#expression#Right . request AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left PageData AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#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 'question/list' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left params AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left questionBankType AST#property_name#Right : AST#expression#Left 10 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 this AST#expression#Right . typeId AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 获取哪个分类 AST#property_assignment#Left AST#property_name#Left page AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . page AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 获取第几页 AST#property_assignment#Left AST#property_name#Left pageSize AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right , // 每页获取几条数据 AST#property_assignment#Left AST#property_name#Left sort AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , // 10 11 20 21 30 表示排序方式 枚举优化一下 AST#property_assignment#Left AST#property_name#Left keyword AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . keyword AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 还有一些其他参数 } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right // this.list = res.rows // 面试题列表数据 return res AST#ERROR#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export struct QuestionListComp { @Prop activeIndex: number = 0 @Prop index: number = 0 @Prop @Watch('fn') sort: SortType = SortType.Default @Prop typeId: number @Prop keyword: string = '' @State list: QuestionItem[] = [] @State isRefreshing: boolean = false @State isLoading: boolean = false @State isFinished: boolean = false @State page: number = 1 fn() { if (this.activeIndex == this.index) { this.isRefreshing = true } } async getList() { const res = await http.request<PageData>({ url: 'question/list', params: { questionBankType: 10, type: this.typeId, page: this.page, pageSize: 10, sort: 0 , keyword: this.keyword, } }) return res }
https://github.com/Hyricane/Interview_Success.git/blob/9783273fe05fc8951b99bf32d3887c605268db8f/entry/src/main/ets/commons/components/QuestionListComp.ets#L41-L81
26fe07862a88cef426df90ebd9d50453f6054f2e
github
open9527/OpenHarmony
fdea69ed722d426bf04e817ec05bff4002e81a4e
entry/src/main/ets/pages/example/debug/DebugPanelParams.ets
arkts
@author open_9527 @date 2025/10/31 @desc DebugNodeParams
export enum DebugPanelNodeMode { Default = 'Default', Router = 'Router', Log = 'Log', System = 'System', Network = 'Network', Storage = 'Storage' }
AST#export_declaration#Left export AST#enum_declaration#Left enum DebugPanelNodeMode AST#enum_body#Left { AST#enum_member#Left Default = AST#expression#Left 'Default' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left Router = AST#expression#Left 'Router' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left Log = AST#expression#Left 'Log' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left System = AST#expression#Left 'System' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left Network = AST#expression#Left 'Network' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left Storage = AST#expression#Left 'Storage' AST#expression#Right AST#enum_member#Right } AST#enum_body#Right AST#enum_declaration#Right AST#export_declaration#Right
export enum DebugPanelNodeMode { Default = 'Default', Router = 'Router', Log = 'Log', System = 'System', Network = 'Network', Storage = 'Storage' }
https://github.com/open9527/OpenHarmony/blob/fdea69ed722d426bf04e817ec05bff4002e81a4e/entry/src/main/ets/pages/example/debug/DebugPanelParams.ets#L8-L15
7dbcd71a8e619d5f540fd7a69a28d639b027b406
gitee
openharmony/update_update_app
0157b7917e2f48e914b5585991e8b2f4bc25108a
feature/ota/src/main/ets/OtaPage.ets
arkts
getCurrentVersionPageInfo
取当前版本数据 @param versionComponents 升级包 @param componentDescriptions 更新日志 @return VersionPageInfo 具体的当前版本数据
public getCurrentVersionPageInfo(versionComponents: Array<update.VersionComponent>, componentDescriptions: Array<update.ComponentDescription>): VersionPageInfo { let component: update.VersionComponent = versionComponents.filter((component: update.VersionComponent) => { return component.componentType == update.ComponentType.OTA; })?.[0]; let componentId: string = component?.componentId; let description: string = ''; if (componentDescriptions) { description = UpdateUtils.obtainDescription(componentDescriptions, componentId); } return { version: VersionUtils.getCurrentDisplayVersion(), changelog: { version: VersionUtils.getCurrentDisplayVersion(), content: description } }; }
AST#method_declaration#Left public getCurrentVersionPageInfo AST#parameter_list#Left ( AST#parameter#Left versionComponents : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left update . VersionComponent AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left componentDescriptions : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left update . ComponentDescription 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#type_annotation#Left AST#primary_type#Left VersionPageInfo AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left component : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left update . VersionComponent AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left versionComponents AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left component : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left update . VersionComponent 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#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left component AST#expression#Right . componentType AST#member_expression#Right AST#expression#Right == AST#expression#Left update AST#expression#Right AST#binary_expression#Right AST#expression#Right . ComponentType AST#member_expression#Right AST#expression#Right . OTA AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ?. [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left componentId : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left component AST#expression#Right ?. componentId 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 description : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left componentDescriptions AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left description = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left UpdateUtils AST#expression#Right . obtainDescription AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left componentDescriptions AST#expression#Right , AST#expression#Left componentId 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 AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left version AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left VersionUtils AST#expression#Right . getCurrentDisplayVersion AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left changelog AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left version AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left VersionUtils AST#expression#Right . getCurrentDisplayVersion AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left content AST#property_name#Right : AST#expression#Left description 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public getCurrentVersionPageInfo(versionComponents: Array<update.VersionComponent>, componentDescriptions: Array<update.ComponentDescription>): VersionPageInfo { let component: update.VersionComponent = versionComponents.filter((component: update.VersionComponent) => { return component.componentType == update.ComponentType.OTA; })?.[0]; let componentId: string = component?.componentId; let description: string = ''; if (componentDescriptions) { description = UpdateUtils.obtainDescription(componentDescriptions, componentId); } return { version: VersionUtils.getCurrentDisplayVersion(), changelog: { version: VersionUtils.getCurrentDisplayVersion(), content: description } }; }
https://github.com/openharmony/update_update_app/blob/0157b7917e2f48e914b5585991e8b2f4bc25108a/feature/ota/src/main/ets/OtaPage.ets#L76-L93
4646d1d199845b4ff570039e68a823643f36a7c0
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/clickanimation/src/main/ets/components/ClickAnimationComponent.ets
arkts
videoBackgroundSlot
背景视频插槽。
@Builder videoBackgroundSlot() { Video({ src: $r('app.media.click_animation_test_video') }) .height($r('app.string.click_animation_full_size')) .width($r('app.string.click_animation_full_size')) .autoPlay(true) .loop(true) .controls(false) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right videoBackgroundSlot 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 Video ( AST#component_parameters#Left { AST#component_parameter#Left src : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.click_animation_test_video' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.click_animation_full_size' 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.click_animation_full_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . autoPlay ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . loop ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . controls ( 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#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 videoBackgroundSlot() { Video({ src: $r('app.media.click_animation_test_video') }) .height($r('app.string.click_animation_full_size')) .width($r('app.string.click_animation_full_size')) .autoPlay(true) .loop(true) .controls(false) }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/clickanimation/src/main/ets/components/ClickAnimationComponent.ets#L169-L177
c3a4be47e15cf3121755f361ff604feeb1f3424e
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/GreetingsPage.ets
arkts
buildFloatingActionButton
构建浮动操作按钮
@Builder buildFloatingActionButton() { Stack() { // AI生成按钮 Button() { Text('🤖') .fontSize(24) } .type(ButtonType.Circle) .width('56vp') .height('56vp') .backgroundColor('#ff6b6b') .position({ x: '100%', y: '100%' }) .translate({ x: -80, y: -140 }) .onClick(() => { // TODO: AI生成祝福语 }) // 创建祝福语按钮 Button() { Text('+') .fontSize(28) .fontColor('#ffffff') } .type(ButtonType.Circle) .width('64vp') .height('64vp') .backgroundColor('#007AFF') .position({ x: '100%', y: '100%' }) .translate({ x: -80, y: -80 }) .onClick(() => { appRouter.push(RoutePaths.GREETING_SEND); }) } .width('100%') .height('0vp') }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildFloatingActionButton 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 Stack ( ) AST#container_content_body#Left { // AI生成按钮 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left 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#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . type ( AST#expression#Left AST#member_expression#Left AST#expression#Left ButtonType AST#expression#Right . Circle AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '56vp' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '56vp' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#ff6b6b' AST#expression#Right ) AST#modifier_chain_expression#Left . position ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left '100%' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left '100%' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . translate ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#unary_expression#Left - AST#expression#Left 80 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#unary_expression#Left - AST#expression#Left 140 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#expression#Left AST#object_literal#Left { // TODO: AI生成祝福语 } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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#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 28 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#ffffff' 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 . type ( AST#expression#Left AST#member_expression#Left AST#expression#Left ButtonType AST#expression#Right . Circle AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '64vp' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '64vp' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#007AFF' AST#expression#Right ) AST#modifier_chain_expression#Left . position ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left '100%' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left '100%' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . translate ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#unary_expression#Left - AST#expression#Left 80 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#unary_expression#Left - AST#expression#Left 80 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left appRouter AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left RoutePaths AST#expression#Right . GREETING_SEND 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#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 '0vp' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder buildFloatingActionButton() { Stack() { Button() { Text('🤖') .fontSize(24) } .type(ButtonType.Circle) .width('56vp') .height('56vp') .backgroundColor('#ff6b6b') .position({ x: '100%', y: '100%' }) .translate({ x: -80, y: -140 }) .onClick(() => { }) Button() { Text('+') .fontSize(28) .fontColor('#ffffff') } .type(ButtonType.Circle) .width('64vp') .height('64vp') .backgroundColor('#007AFF') .position({ x: '100%', y: '100%' }) .translate({ x: -80, y: -80 }) .onClick(() => { appRouter.push(RoutePaths.GREETING_SEND); }) } .width('100%') .height('0vp') }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/GreetingsPage.ets#L585-L621
5cce54abbd04162a359e65ddce3b737aced95a16
github
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
core/designsystem/src/main/ets/component/Row.ets
arkts
RowSpaceBetweenTop
横向两端分布 + 垂直顶部
@ComponentV2 export struct RowSpaceBetweenTop { /** * Row 构造参数 */ @Param options: RowOptions | RowOptionsV2 = {}; /** * 宽度 */ @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 * RowSpaceBetweenTop() { Text("A"); Text("B"); } */ build(): void { RowBase({ options: this.options, justifyContent: FlexAlign.SpaceBetween, alignItems: VerticalAlign.Top, 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 RowSpaceBetweenTop AST#component_body#Left { /** * Row 构造参数 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right options : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left RowOptions AST#primary_type#Right | AST#primary_type#Left RowOptionsV2 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 * RowSpaceBetweenTop() { Text("A"); Text("B"); } */ AST#build_method#Left build ( ) : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#build_body#Left { AST#ui_custom_component_statement#Left RowBase ( AST#component_parameters#Left { AST#component_parameter#Left options : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left justifyContent : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . 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 VerticalAlign AST#expression#Right . Top 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 RowSpaceBetweenTop { @Param options: RowOptions | RowOptionsV2 = {}; @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 { RowBase({ options: this.options, justifyContent: FlexAlign.SpaceBetween, alignItems: VerticalAlign.Top, widthValue: this.widthValue, heightValue: this.heightValue, sizeValue: this.sizeValue, paddingValue: this.paddingValue, marginValue: this.marginValue, fillMaxSize: this.fillMaxSize, bgColor: this.bgColor, onTap: this.onTap, content: this.content }); } }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/designsystem/src/main/ets/component/Row.ets#L1105-L1180
c27ccc61a5f7343464df063826e12f5a4732edff
github
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@ohos.base.d.ets
arkts
Defines the basic error callback. @typedef { ErrorCallback<T extends Error = BusinessError> } @syscap SystemCapability.Base @crossplatform @atomicservice @since 20
export type ErrorCallback<T extends Error = BusinessError> = (err: T)=> void;
AST#export_declaration#Left export AST#type_declaration#Left type ErrorCallback AST#type_parameters#Left < AST#type_parameter#Left T extends AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right = AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#type_parameter#Right > AST#type_parameters#Right = AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left err : 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#function_type#Right AST#type_annotation#Right ; AST#type_declaration#Right AST#export_declaration#Right
export type ErrorCallback<T extends Error = BusinessError> = (err: T)=> void;
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.base.d.ets#L42-L42
0f0c751b79394c5aaec7617d7b2c6121615663d5
gitee
iotjin/JhHarmonyDemo.git
819e6c3b1db9984c042a181967784550e171b2e8
JhCommon/Index.ets
arkts
JhLoginTextInput
/ JhForm
export { JhLoginTextInput } from './src/main/ets/JhForm/JhLoginTextInput'
AST#export_declaration#Left export { JhLoginTextInput } from './src/main/ets/JhForm/JhLoginTextInput' AST#export_declaration#Right
export { JhLoginTextInput } from './src/main/ets/JhForm/JhLoginTextInput'
https://github.com/iotjin/JhHarmonyDemo.git/blob/819e6c3b1db9984c042a181967784550e171b2e8/JhCommon/Index.ets#L2-L2
47865824f5590b8dee7219d519db6ca42c1239ad
github
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/jobs/ViewPortJob.ets
arkts
Runnable that is used for viewport modifications since they cannot be executed at any time. This can be used to delay the execution of viewport modifications until the onSizeChanged(...) method of the chart-view is called. This is especially important if viewport modifying methods are called on the chart directly after initialization.
export default abstract class ViewPortJob extends Poolable { protected pts: number[] = new Array<number>(2); protected mViewPortHandler: ViewPortHandler | null = null; protected xValue: number = 0; protected yValue: number = 0; protected mTrans: Transformer | null = null; protected view: Chart<ChartData<IDataSet<EntryOhos>>> | null = null; constructor(viewPortHandler: ViewPortHandler | null, xValue: number, yValue: number, trans: Transformer | null, v: Chart<ChartData<IDataSet<EntryOhos>>> | null) { super(); this.mViewPortHandler = viewPortHandler; this.xValue = xValue; this.yValue = yValue; this.mTrans = trans; this.view = v; } public getXValue(): number { return this.xValue; } public getYValue(): number { return this.yValue; } }
AST#export_declaration#Left export default AST#class_declaration#Left abstract class ViewPortJob extends AST#type_annotation#Left AST#primary_type#Left Poolable AST#primary_type#Right AST#type_annotation#Right AST#class_body#Left { AST#property_declaration#Left protected pts : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#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 number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left 2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left protected mViewPortHandler : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ViewPortHandler 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 protected xValue : 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 protected yValue : 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 protected mTrans : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Transformer 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 protected view : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#generic_type#Left Chart AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left ChartData AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left IDataSet AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left EntryOhos 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#type_arguments#Right AST#generic_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left viewPortHandler : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ViewPortHandler AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left xValue : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left yValue : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left trans : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Transformer AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left v : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#generic_type#Left Chart AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left ChartData AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left IDataSet AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left EntryOhos 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#type_arguments#Right AST#generic_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#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 super AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mViewPortHandler AST#member_expression#Right = AST#expression#Left viewPortHandler 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 . xValue AST#member_expression#Right = AST#expression#Left xValue 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 . yValue AST#member_expression#Right = AST#expression#Left yValue 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 . mTrans AST#member_expression#Right = AST#expression#Left trans 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 . view AST#member_expression#Right = AST#expression#Left v AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right AST#method_declaration#Left public getXValue AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . xValue AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left public getYValue AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . yValue AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export default abstract class ViewPortJob extends Poolable { protected pts: number[] = new Array<number>(2); protected mViewPortHandler: ViewPortHandler | null = null; protected xValue: number = 0; protected yValue: number = 0; protected mTrans: Transformer | null = null; protected view: Chart<ChartData<IDataSet<EntryOhos>>> | null = null; constructor(viewPortHandler: ViewPortHandler | null, xValue: number, yValue: number, trans: Transformer | null, v: Chart<ChartData<IDataSet<EntryOhos>>> | null) { super(); this.mViewPortHandler = viewPortHandler; this.xValue = xValue; this.yValue = yValue; this.mTrans = trans; this.view = v; } public getXValue(): number { return this.xValue; } public getYValue(): number { return this.yValue; } }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/jobs/ViewPortJob.ets#L33-L59
8f68782ef7f44bbff5d95b688cb718790bac1686
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
mime_types/src/main/ets/Mime.ets
arkts
getIconFileByMIMEType
根据MIME类型获取对应文件类型的图标 @param mimeType MIME类型名称 'text/css'
static getIconFileByMIMEType(mimeType: string): string { const descriptor = Mime.getTypeDescriptorByMIMEType(mimeType); return descriptor.iconFile; }
AST#method_declaration#Left static getIconFileByMIMEType AST#parameter_list#Left ( AST#parameter#Left mimeType : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left descriptor = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Mime AST#expression#Right . getTypeDescriptorByMIMEType AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left mimeType 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 descriptor AST#expression#Right . iconFile AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static getIconFileByMIMEType(mimeType: string): string { const descriptor = Mime.getTypeDescriptorByMIMEType(mimeType); return descriptor.iconFile; }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/mime_types/src/main/ets/Mime.ets#L92-L95
204d84368a732008965ee536ed329c1629a8dfdb
gitee
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
feature/main/src/main/ets/view/NavigationPage.ets
arkts
NavigationContent
导航页面内容视图 @returns {void} 无返回值
@Builder private NavigationContent() { MediumPaddingVerticalScroll() { ColumnBase({ widthValue: P100 }) { if (this.vm.hasResult) { this.ResultSection(); SpaceVerticalLarge(); } IBestCellGroup({ inset: true, outerMargin: 0 }) { ForEach(this.vm.cards, (item: NavigationCardItem, index: number) => { IBestCell({ title: item.title, label: item.description, isLink: true, leftContentWidth: P80, hasBorder: index !== this.vm.cards.length - 1, onCellClick: () => item.onClick() }); }, (_item: NavigationCardItem, index: number) => `${index}`); }; }; }; }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right private NavigationContent 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 MediumPaddingVerticalScroll ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ColumnBase ( AST#component_parameters#Left { AST#component_parameter#Left widthValue : AST#expression#Left P100 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . hasResult 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 . ResultSection 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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left SpaceVerticalLarge ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left IBestCellGroup ( AST#component_parameters#Left { AST#component_parameter#Left inset : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left outerMargin : AST#expression#Left 0 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#for_each_statement#Left ForEach ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . cards 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 NavigationCardItem AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#ui_custom_component_statement#Left IBestCell ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . title AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left label : AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . description AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left isLink : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left leftContentWidth : AST#expression#Left P80 AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left hasBorder : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right !== AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . cards AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onCellClick : 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 item AST#expression#Right . onClick AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right } AST#ui_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 NavigationCardItem AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left index AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right AST#ERROR#Left ; AST#ERROR#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder private NavigationContent() { MediumPaddingVerticalScroll() { ColumnBase({ widthValue: P100 }) { if (this.vm.hasResult) { this.ResultSection(); SpaceVerticalLarge(); } IBestCellGroup({ inset: true, outerMargin: 0 }) { ForEach(this.vm.cards, (item: NavigationCardItem, index: number) => { IBestCell({ title: item.title, label: item.description, isLink: true, leftContentWidth: P80, hasBorder: index !== this.vm.cards.length - 1, onCellClick: () => item.onClick() }); }, (_item: NavigationCardItem, index: number) => `${index}`); }; }; }; }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/feature/main/src/main/ets/view/NavigationPage.ets#L47-L70
96b6103f54401ccfc5b35271760657c0c7ba7828
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/verifycode/Index.ets
arkts
VerifyCodeViewComponent
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 { VerifyCodeViewComponent } from './src/main/ets/view/VerifyCodeView';
AST#export_declaration#Left export { VerifyCodeViewComponent } from './src/main/ets/view/VerifyCodeView' ; AST#export_declaration#Right
export { VerifyCodeViewComponent } from './src/main/ets/view/VerifyCodeView';
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/verifycode/Index.ets#L15-L15
38651f5821ec9f28c506df2396d3cbda791e08dc
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/network/src/main/ets/datasource/order/OrderNetworkDataSourceImpl.ets
arkts
refundOrder
申请订单退款 @param {RefundOrderRequest} params - 退款请求参数 @returns {Promise<NetworkResponse<boolean>>} 是否成功
async refundOrder(params: RefundOrderRequest): Promise<NetworkResponse<boolean>> { const resp: AxiosResponse<NetworkResponse<boolean>> = await NetworkClient.http.post("order/info/refund", params); return resp.data; }
AST#method_declaration#Left async refundOrder AST#parameter_list#Left ( AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left RefundOrderRequest 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 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#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 resp : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left AxiosResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left NetworkResponse 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#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left NetworkClient AST#expression#Right AST#await_expression#Right AST#expression#Right . http AST#member_expression#Right AST#expression#Right . post AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "order/info/refund" 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#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left resp AST#expression#Right . data AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async refundOrder(params: RefundOrderRequest): Promise<NetworkResponse<boolean>> { const resp: AxiosResponse<NetworkResponse<boolean>> = await NetworkClient.http.post("order/info/refund", params); return resp.data; }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/network/src/main/ets/datasource/order/OrderNetworkDataSourceImpl.ets#L49-L53
151e793d78ab1572ea1c72cd6105028eea662d85
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/iconmaincolor/src/main/ets/components/utils/ImageUtils.ets
arkts
修改HSV格式的颜色值,可根据业务需求或者UI设计自行修改S和V的值,此处只举例进行说明 @param color HSV格式的颜色
export function modifySVValue(color: ColorHsv): void { if (color.hue > 0 && color.hue <= 60) { color.saturation = 0.12; color.value = 0.93; } else if (color.hue > 60 && color.hue <= 190) { color.saturation = 0.08; color.value = 0.91; } else if (color.hue > 190 && color.hue <= 270) { color.saturation = 0.1; color.value = 0.93; } else { color.saturation = 0.08; color.value = 0.93; } }
AST#export_declaration#Left export AST#function_declaration#Left function modifySVValue AST#parameter_list#Left ( AST#parameter#Left color : AST#type_annotation#Left AST#primary_type#Left ColorHsv AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 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 color AST#expression#Right . hue AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left color AST#expression#Right AST#binary_expression#Right AST#expression#Right . hue AST#member_expression#Right AST#expression#Right <= AST#expression#Left 60 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 color AST#expression#Right . saturation AST#member_expression#Right = AST#expression#Left 0.12 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 color AST#expression#Right . value AST#member_expression#Right = AST#expression#Left 0.93 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left color AST#expression#Right . hue AST#member_expression#Right AST#expression#Right > AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left color AST#expression#Right AST#binary_expression#Right AST#expression#Right . hue AST#member_expression#Right AST#expression#Right <= AST#expression#Left 190 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 color AST#expression#Right . saturation AST#member_expression#Right = AST#expression#Left 0.08 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 color AST#expression#Right . value AST#member_expression#Right = AST#expression#Left 0.91 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left color AST#expression#Right . hue AST#member_expression#Right AST#expression#Right > AST#expression#Left 190 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left color AST#expression#Right AST#binary_expression#Right AST#expression#Right . hue AST#member_expression#Right AST#expression#Right <= AST#expression#Left 270 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 color AST#expression#Right . saturation AST#member_expression#Right = AST#expression#Left 0.1 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left color AST#expression#Right . value AST#member_expression#Right = AST#expression#Left 0.93 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 color AST#expression#Right . saturation AST#member_expression#Right = AST#expression#Left 0.08 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 color AST#expression#Right . value AST#member_expression#Right = AST#expression#Left 0.93 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#function_declaration#Right AST#export_declaration#Right
export function modifySVValue(color: ColorHsv): void { if (color.hue > 0 && color.hue <= 60) { color.saturation = 0.12; color.value = 0.93; } else if (color.hue > 60 && color.hue <= 190) { color.saturation = 0.08; color.value = 0.91; } else if (color.hue > 190 && color.hue <= 270) { color.saturation = 0.1; color.value = 0.93; } else { color.saturation = 0.08; color.value = 0.93; } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/iconmaincolor/src/main/ets/components/utils/ImageUtils.ets#L74-L88
fa878bd0f957cbb7e279d3688e81e0fc29dccb55
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/common/FeedbackService.ets
arkts
showLoading
显示加载提示
async showLoading(options: LoadingOptions): Promise<string> { const loadingId = this.generateId(); this.currentLoadingId = loadingId; hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Loading started: ${options.message}`); // 显示加载Toast await promptAction.showToast({ message: `⏳ ${options.message}`, duration: 10000 // 长时间显示,需要手动关闭 }); return loadingId; }
AST#method_declaration#Left async showLoading AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left LoadingOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left loadingId = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . generateId AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 . currentLoadingId AST#member_expression#Right = AST#expression#Left loadingId AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Loading started: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left options 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 // 显示加载Toast 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 promptAction AST#expression#Right AST#await_expression#Right AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` ⏳ AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left duration 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#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left loadingId AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async showLoading(options: LoadingOptions): Promise<string> { const loadingId = this.generateId(); this.currentLoadingId = loadingId; hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Loading started: ${options.message}`); await promptAction.showToast({ message: `⏳ ${options.message}`, duration: 10000 }); return loadingId; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/common/FeedbackService.ets#L95-L108
77dc38a60397b5d05ce8585c5966b6540988bf42
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/iab/huawei/HwSubscriber.ets
arkts
queryProducts
查询产品信息
async queryProducts(): Promise<iap.Product[] | null> { const productIds: string[] = [ HwSubscribeConstants.SKU_1, HwSubscribeConstants.SKU_2, HwSubscribeConstants.SKU_3 ]; const param: iap.QueryProductsParameter = { productType : iap.ProductType.AUTORENEWABLE, productIds : productIds }; try { const result: iap.Product[] = await iap.queryProducts(this.context, param); DebugLog.i('Succeeded in querying products.'); return result.sort((a, b) => a.id.localeCompare(b.id)) ?? []; //按id排序 } catch (err) { const e = err as BusinessError; DebugLog.e(`Failed to query products. Code: ${e.code}, message: ${e.message}`); return null; } }
AST#method_declaration#Left async queryProducts 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#qualified_type#Left iap . Product AST#qualified_type#Right AST#primary_type#Right AST#ERROR#Left [ ] AST#ERROR#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 productIds : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left HwSubscribeConstants AST#expression#Right . SKU_1 AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left HwSubscribeConstants AST#expression#Right . SKU_2 AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left HwSubscribeConstants AST#expression#Right . SKU_3 AST#member_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#variable_declaration#Left const AST#variable_declarator#Left param : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left iap . QueryProductsParameter 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 productType AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left iap AST#expression#Right . ProductType AST#member_expression#Right AST#expression#Right . AUTORENEWABLE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left productIds AST#property_name#Right : AST#expression#Left productIds 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#try_statement#Left try 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 iap AST#ERROR#Left . Product AST#ERROR#Right [ ] 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#await_expression#Left await AST#expression#Left iap AST#expression#Right AST#await_expression#Right AST#expression#Right . queryProducts AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right AST#expression#Right , AST#expression#Left param 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 . i AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Succeeded in querying products.' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . sort AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left a AST#parameter#Right , AST#parameter#Left b AST#parameter#Right ) AST#parameter_list#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 a AST#expression#Right . id AST#member_expression#Right AST#expression#Right . localeCompare AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left b 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#argument_list#Right AST#call_expression#Right AST#expression#Right ?? AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right //按id排序 } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left e = 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 DebugLog AST#expression#Right . e AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` Failed to query products. Code: 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 , message: 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_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 queryProducts(): Promise<iap.Product[] | null> { const productIds: string[] = [ HwSubscribeConstants.SKU_1, HwSubscribeConstants.SKU_2, HwSubscribeConstants.SKU_3 ]; const param: iap.QueryProductsParameter = { productType : iap.ProductType.AUTORENEWABLE, productIds : productIds }; try { const result: iap.Product[] = await iap.queryProducts(this.context, param); DebugLog.i('Succeeded in querying products.'); return result.sort((a, b) => a.id.localeCompare(b.id)) ?? []; } catch (err) { const e = err as BusinessError; DebugLog.e(`Failed to query products. Code: ${e.code}, message: ${e.message}`); return null; } }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/iab/huawei/HwSubscriber.ets#L51-L72
63e8e11d3be5327293a40e068bb5c326d35d02e1
github
mhtcgr/ToDoList_For_Harmony.git
356d4c9a507205f02870e970203022a380c8a2a1
entry/src/main/ets/pages/TodoPage.ets
arkts
markTodoAsFinished
标记待办事项为完成
markTodoAsFinished(index: number) { const todo = this.todosUnfinished[index]; todo.isFinished = true; this.todosUnfinished = this.todos.filter(todo => !todo.isFinished); this.todosFinished = this.todos.filter(todo => todo.isFinished); this.model.ToDoData = this.todos; this.model.saveTodos(); }
AST#method_declaration#Left markTodoAsFinished AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left todo = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . todosUnfinished AST#member_expression#Right AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left todo AST#expression#Right . isFinished AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . todosUnfinished AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . todos AST#member_expression#Right AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left todo => AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left todo AST#expression#Right AST#unary_expression#Right AST#expression#Right . isFinished AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#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 . todosFinished AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . todos AST#member_expression#Right AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left todo => AST#expression#Left AST#member_expression#Left AST#expression#Left todo AST#expression#Right . isFinished AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . model AST#member_expression#Right AST#expression#Right . ToDoData AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . todos AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . model AST#member_expression#Right AST#expression#Right . saveTodos 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
markTodoAsFinished(index: number) { const todo = this.todosUnfinished[index]; todo.isFinished = true; this.todosUnfinished = this.todos.filter(todo => !todo.isFinished); this.todosFinished = this.todos.filter(todo => todo.isFinished); this.model.ToDoData = this.todos; this.model.saveTodos(); }
https://github.com/mhtcgr/ToDoList_For_Harmony.git/blob/356d4c9a507205f02870e970203022a380c8a2a1/entry/src/main/ets/pages/TodoPage.ets#L96-L103
581de9a9392a044125d310c0a05480b558394237
github
htliang128/arkts_oss.git
9da4a87c36272873c649f556854bd793ac337a18
htliang_oss/src/main/ets/common/comm/CustomHttpRequestOptions.ets
arkts
getMaxLimit
Getter and setter for maxLimit
getMaxLimit(): number | undefined { return this.maxLimit; }
AST#method_declaration#Left getMaxLimit AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . maxLimit AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
getMaxLimit(): number | undefined { return this.maxLimit; }
https://github.com/htliang128/arkts_oss.git/blob/9da4a87c36272873c649f556854bd793ac337a18/htliang_oss/src/main/ets/common/comm/CustomHttpRequestOptions.ets#L173-L175
f92488e03e9f961944e86334f9e8153d524967e4
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto/src/main/ets/crypto/encryption/sm2/SM2.ets
arkts
sign
签名 @param str 需要签名的字符串 @param priKey 私钥 @returns string> 签名对象
static async sign(str: string, priKey: string): Promise<string> { return CryptoUtil.sign(str, priKey, 'SM2_256', 'SM2_256|SM3', 256); }
AST#method_declaration#Left static async sign AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left priKey : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_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 . sign AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left priKey AST#expression#Right , AST#expression#Left 'SM2_256' AST#expression#Right , AST#expression#Left 'SM2_256|SM3' AST#expression#Right , AST#expression#Left 256 AST#expression#Right ) AST#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 sign(str: string, priKey: string): Promise<string> { return CryptoUtil.sign(str, priKey, 'SM2_256', 'SM2_256|SM3', 256); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto/src/main/ets/crypto/encryption/sm2/SM2.ets#L60-L62
20bf74d46164d67a5e507d75cf1117ffeb135399
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/lunar/LunarService.ets
arkts
getDayName
获取日期名称
private getDayName(day: number): string { return LunarUtils.getDayName(day); }
AST#method_declaration#Left private getDayName AST#parameter_list#Left ( AST#parameter#Left day : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LunarUtils AST#expression#Right . getDayName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left day 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 getDayName(day: number): string { return LunarUtils.getDayName(day); }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/lunar/LunarService.ets#L651-L653
b8a732d427332e8d01c3c8d23ccffee3f73d8386
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/ar/ARCardService.ets
arkts
AR模型接口
export interface ARModel { id: string; name: string; type: ModelType; filePath: string; texture?: string; animations: ModelAnimation[]; physics: PhysicsConfig; transform: Transform3D; metadata: Record<string, any>; }
AST#export_declaration#Left export AST#interface_declaration#Left interface ARModel AST#object_type#Left { AST#type_member#Left id : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left type : AST#type_annotation#Left AST#primary_type#Left ModelType AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left filePath : 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 texture ? : 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 animations : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ModelAnimation [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left physics : AST#type_annotation#Left AST#primary_type#Left PhysicsConfig AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left transform : AST#type_annotation#Left AST#primary_type#Left Transform3D AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left metadata : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left any AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface ARModel { id: string; name: string; type: ModelType; filePath: string; texture?: string; animations: ModelAnimation[]; physics: PhysicsConfig; transform: Transform3D; metadata: Record<string, any>; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/ar/ARCardService.ets#L97-L107
cb5e029e6705c7ace570876634d2e55a4aeee18b
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/user/src/main/ets/navigation/UserGraph.ets
arkts
@file 用户模块导航图 @author Joker.X
export class UserGraph implements RouteGraph { /** * 注册用户模块导航路由 */ register(): void { RouteBuild.register(UserRoutes.Profile, wrapBuilder(ProfileNav)); RouteBuild.register(UserRoutes.AddressList, wrapBuilder(AddressListNav)); RouteBuild.register(UserRoutes.AddressDetail, wrapBuilder(AddressDetailNav)); RouteBuild.register(UserRoutes.Footprint, wrapBuilder(FootprintNav)); } }
AST#export_declaration#Left export AST#class_declaration#Left class UserGraph AST#implements_clause#Left implements RouteGraph AST#implements_clause#Right AST#class_body#Left { /** * 注册用户模块导航路由 */ 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 UserRoutes AST#expression#Right . Profile 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 ProfileNav 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 UserRoutes AST#expression#Right . AddressList 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 AddressListNav 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 UserRoutes AST#expression#Right . AddressDetail 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 AddressDetailNav 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 UserRoutes AST#expression#Right . Footprint 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 FootprintNav 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 } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class UserGraph implements RouteGraph { register(): void { RouteBuild.register(UserRoutes.Profile, wrapBuilder(ProfileNav)); RouteBuild.register(UserRoutes.AddressList, wrapBuilder(AddressListNav)); RouteBuild.register(UserRoutes.AddressDetail, wrapBuilder(AddressDetailNav)); RouteBuild.register(UserRoutes.Footprint, wrapBuilder(FootprintNav)); } }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/user/src/main/ets/navigation/UserGraph.ets#L12-L22
eed51c86f6f0a782864acaa4cf0cec3c1f970a9c
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/lunar/LunarService.ets
arkts
setUseOnlineData
设置是否使用联网数据 @param useOnline 是否使用联网数据
setUseOnlineData(useOnline: boolean): void { this.useOnlineData = useOnline; hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Online lunar data ${useOnline ? 'enabled' : 'disabled'}`); }
AST#method_declaration#Left setUseOnlineData AST#parameter_list#Left ( AST#parameter#Left useOnline : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . useOnlineData AST#member_expression#Right = AST#expression#Left useOnline 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 ` Online lunar data AST#template_substitution#Left $ { AST#expression#Left AST#conditional_expression#Left AST#expression#Left useOnline AST#expression#Right ? AST#expression#Left 'enabled' AST#expression#Right : AST#expression#Left 'disabled' AST#expression#Right AST#conditional_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
setUseOnlineData(useOnline: boolean): void { this.useOnlineData = useOnline; hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Online lunar data ${useOnline ? 'enabled' : 'disabled'}`); }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/lunar/LunarService.ets#L409-L412
558c24964d36950f5f8080a4339d349928f69464
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/imagecompression/src/main/ets/view/ImageCompression.ets
arkts
packing
packing压缩 @param sourcePixelMap 原始待压缩图片的PixelMap @param imageQuality 图片质量参数 @param packingFormat 目标格式。当前只支持"image/jpeg"、"image/webp" 和 "image/png" @returns data 返回压缩后的图片数据
async packing(sourcePixelMap: image.PixelMap, imageQuality: number, packingFormat: string): Promise<ArrayBuffer> { const imagePackerApi = image.createImagePacker(); const packOpts: image.PackingOption = { format: 'image/' + packingFormat, quality: imageQuality }; const data: ArrayBuffer = await imagePackerApi.packing(sourcePixelMap, packOpts); return data; }
AST#method_declaration#Left async packing AST#parameter_list#Left ( AST#parameter#Left sourcePixelMap : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left image . PixelMap AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left imageQuality : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left packingFormat : 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 ArrayBuffer AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left imagePackerApi = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left image AST#expression#Right . createImagePacker AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left packOpts : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left image . PackingOption AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left format AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left 'image/' AST#expression#Right + AST#expression#Left packingFormat AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left quality AST#property_name#Right : AST#expression#Left imageQuality AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left data : 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#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left imagePackerApi AST#expression#Right AST#await_expression#Right AST#expression#Right . packing AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sourcePixelMap AST#expression#Right , AST#expression#Left packOpts 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 data AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async packing(sourcePixelMap: image.PixelMap, imageQuality: number, packingFormat: string): Promise<ArrayBuffer> { const imagePackerApi = image.createImagePacker(); const packOpts: image.PackingOption = { format: 'image/' + packingFormat, quality: imageQuality }; const data: ArrayBuffer = await imagePackerApi.packing(sourcePixelMap, packOpts); return data; }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/imagecompression/src/main/ets/view/ImageCompression.ets#L388-L393
0258425e4f101f0a7f43b2e0a34fd9273556d26a
gitee
openharmony/developtools_profiler
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/components/AxisBase.ets
arkts
resetAxisMaximum
By calling this method, any custom maximum value that has been previously set is reseted, and the calculation is done automatically.
public resetAxisMaximum(): void { this.mCustomAxisMax = false; }
AST#method_declaration#Left public resetAxisMaximum 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 . mCustomAxisMax AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
public resetAxisMaximum(): void { this.mCustomAxisMax = false; }
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/components/AxisBase.ets#L670-L672
3de5dc5be8d0b21256d8e77b574f78544a625f98
gitee
Application-Security-Automation/Arktan.git
3ad9cb05235e38b00cd5828476aa59a345afa1c0
dataset/completeness/function_call/return_value_passing/return_value_passing_002_F.ets
arkts
Introduction 返回值传递
export function return_value_passing_002_F(taint_src : string) { let _t = taint_src; let _clean = "clean"; let t = f(_clean); taint.Sink(t); }
AST#export_declaration#Left export AST#function_declaration#Left function return_value_passing_002_F AST#parameter_list#Left ( AST#parameter#Left taint_src : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left _t = AST#expression#Left taint_src 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 _clean = AST#expression#Left "clean" AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left t = AST#expression#Left AST#call_expression#Left AST#expression#Left f AST#expression#Right AST#argument_list#Left ( AST#expression#Left _clean AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left taint AST#expression#Right . Sink AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left t AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function return_value_passing_002_F(taint_src : string) { let _t = taint_src; let _clean = "clean"; let t = f(_clean); taint.Sink(t); }
https://github.com/Application-Security-Automation/Arktan.git/blob/3ad9cb05235e38b00cd5828476aa59a345afa1c0/dataset/completeness/function_call/return_value_passing/return_value_passing_002_F.ets#L6-L11
683fa4f27864db8575d1b47bd2230e8f4a2e0aa1
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/CoreFile/AppFileBackup/entry/src/main/ets/backuprestore/BackupRestore.ets
arkts
[End session_backup]
export async function sessionBackup(): Promise<void> { gSession = createSessionBackup(); // 此处可根据backup.getLocalCapabilities()提供的能力文件,选择需要备份的应用 // 也可直接根据应用包名称进行备份 const backupApps: string[] = [ 'com.samples.filebackupextension', ] await gSession.appendBundles(backupApps); Logger.info('appendBundles success'); }
AST#export_declaration#Left export AST#function_declaration#Left async function sessionBackup AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left gSession = AST#expression#Left AST#call_expression#Left AST#expression#Left createSessionBackup 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 // 此处可根据backup.getLocalCapabilities()提供的能力文件,选择需要备份的应用 // 也可直接根据应用包名称进行备份 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left backupApps : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'com.samples.filebackupextension' 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 AST#await_expression#Left await AST#expression#Left gSession AST#expression#Right AST#await_expression#Right AST#expression#Right . appendBundles AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left backupApps AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'appendBundles success' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export async function sessionBackup(): Promise<void> { gSession = createSessionBackup(); const backupApps: string[] = [ 'com.samples.filebackupextension', ] await gSession.appendBundles(backupApps); Logger.info('appendBundles success'); }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/CoreFile/AppFileBackup/entry/src/main/ets/backuprestore/BackupRestore.ets#L134-L143
0b6d5b1b5f38247578e191f6fe7525593aae1df3
gitee
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/utils/Poolable.ets
arkts
Copyright (C) 2022 Huawei Device Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
export abstract class Poolable { public static NO_OWNER = -1; public currentOwnerId = Poolable.NO_OWNER; abstract instantiate(): Poolable; }
AST#export_declaration#Left export AST#class_declaration#Left abstract class Poolable AST#class_body#Left { AST#property_declaration#Left public static NO_OWNER = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left public currentOwnerId = AST#expression#Left AST#member_expression#Left AST#expression#Left Poolable AST#expression#Right . NO_OWNER AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#method_declaration#Left abstract instantiate AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left Poolable AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export abstract class Poolable { public static NO_OWNER = -1; public currentOwnerId = Poolable.NO_OWNER; abstract instantiate(): Poolable; }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/utils/Poolable.ets#L16-L21
7dd3c15c8ae730031b386886b34f9bc62368411d
gitee
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@ohos.arkui.advanced.Chip.d.ets
arkts
Defines chip symbolglyph options. @interface ChipSymbolGlyphOptions @syscap SystemCapability.ArkUI.ArkUI.Full @atomicservice @since 12
export interface ChipSymbolGlyphOptions { /** * Symbol normal. * * @type { ?SymbolGlyphModifier } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ normal?: SymbolGlyphModifier; /** * Symbol activated. * * @type { ?SymbolGlyphModifier } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ activated?: SymbolGlyphModifier; }
AST#export_declaration#Left export AST#interface_declaration#Left interface ChipSymbolGlyphOptions AST#object_type#Left { /** * Symbol normal. * * @type { ?SymbolGlyphModifier } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#type_member#Left normal ? : AST#type_annotation#Left AST#primary_type#Left SymbolGlyphModifier AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * Symbol activated. * * @type { ?SymbolGlyphModifier } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#type_member#Left activated ? : AST#type_annotation#Left AST#primary_type#Left SymbolGlyphModifier 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 ChipSymbolGlyphOptions { normal?: SymbolGlyphModifier; activated?: SymbolGlyphModifier; }
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.arkui.advanced.Chip.d.ets#L370-L391
2a4a3f88541f0d8f7998f6e99eee41ab90dd0de8
gitee
harmonyos/samples
f5d967efaa7666550ee3252d118c3c73a77686f5
ETSUI/BorderImageSample/entry/src/main/ets/common/util/StringUtil.ets
arkts
String Util for all features.
export class StringUtil { /** * Numbers turn into percentages. * * @param figure , postice number; * @return {string} percentage. */ public static numberToPercentage(figure: number): string { return figure + '%'; } }
AST#export_declaration#Left export AST#class_declaration#Left class StringUtil AST#class_body#Left { /** * Numbers turn into percentages. * * @param figure , postice number; * @return {string} percentage. */ AST#method_declaration#Left public static numberToPercentage AST#parameter_list#Left ( AST#parameter#Left figure : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left figure AST#expression#Right + AST#expression#Left '%' AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class StringUtil { public static numberToPercentage(figure: number): string { return figure + '%'; } }
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/ETSUI/BorderImageSample/entry/src/main/ets/common/util/StringUtil.ets#L19-L30
30d61c7701c7c2c9046daf1af6f2908b6b329f19
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/util/src/main/ets/notification/NotificationUtil.ets
arkts
获取指定类型的通知渠道 @param {notificationManager.SlotType} type 通知渠道类型,例如社交通信、服务提醒、内容咨询等类型。 @returns {Promise<notificationManager.NotificationSlot>} 返回通知渠道对象。
export async function get(type: notificationManager.SlotType): Promise<notificationManager.NotificationSlot> { return notificationManager.getSlot(type); }
AST#export_declaration#Left export AST#function_declaration#Left async function get AST#parameter_list#Left ( AST#parameter#Left type : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left notificationManager . SlotType AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left notificationManager . NotificationSlot AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left notificationManager AST#expression#Right . getSlot AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left type AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export async function get(type: notificationManager.SlotType): Promise<notificationManager.NotificationSlot> { return notificationManager.getSlot(type); }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/util/src/main/ets/notification/NotificationUtil.ets#L382-L384
aad863d61735f4aa927e4176479a0c3f326f5584
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/applicationexception/src/main/ets/model/PreferencesManager.ets
arkts
getFaultMessage
获取数据异常信息 @param faultMessage 异常信息集合
public static async getFaultMessage(faultDataSource: FaultDataSource): Promise<void> { logger.info(`getFaultMessage start`); try { // TODO:知识点:通过dataPreferencesManager.get方法获取异常信息数据 const data: dataPreferences.ValueType = await dataPreferencesManager.get('faultMessage', []); if (typeof data === 'string') { const faultData: Array<string> = JSON.parse(data); // 将异常数据添加到懒加载数据源中 faultData.forEach((item: string) => { faultDataSource.pushData(item); }) // 双向数据绑定懒加载数据源长度,更新数据源长度 AppStorage.setOrCreate('faultDataSourceLength', faultDataSource.totalCount()) logger.info('Succeeded in getting value of faultMessage.'); } } catch (err) { logger.error("Failed to get value of 'catch err'. code =" + err.code + ", message =" + err.message); } }
AST#method_declaration#Left public static async getFaultMessage AST#parameter_list#Left ( AST#parameter#Left faultDataSource : AST#type_annotation#Left AST#primary_type#Left FaultDataSource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` getFaultMessage start ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // TODO:知识点:通过dataPreferencesManager.get方法获取异常信息数据 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left dataPreferences . 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#await_expression#Left await AST#expression#Left dataPreferencesManager AST#expression#Right AST#await_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'faultMessage' AST#expression#Right , AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left data AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left 'string' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left faultData : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data 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 faultData AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left faultDataSource AST#expression#Right . pushData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left item AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // 双向数据绑定懒加载数据源长度,更新数据源长度 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'faultDataSourceLength' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left faultDataSource AST#expression#Right . totalCount 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 logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Succeeded in getting value of faultMessage.' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left 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 AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left "Failed to get value of 'catch err'. code =" AST#expression#Right + AST#expression#Left err AST#expression#Right AST#binary_expression#Right AST#expression#Right . code AST#member_expression#Right AST#expression#Right + AST#expression#Left ", message =" AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left err AST#expression#Right AST#binary_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public static async getFaultMessage(faultDataSource: FaultDataSource): Promise<void> { logger.info(`getFaultMessage start`); try { const data: dataPreferences.ValueType = await dataPreferencesManager.get('faultMessage', []); if (typeof data === 'string') { const faultData: Array<string> = JSON.parse(data); faultData.forEach((item: string) => { faultDataSource.pushData(item); }) AppStorage.setOrCreate('faultDataSourceLength', faultDataSource.totalCount()) logger.info('Succeeded in getting value of faultMessage.'); } } catch (err) { logger.error("Failed to get value of 'catch err'. code =" + err.code + ", message =" + err.message); } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/applicationexception/src/main/ets/model/PreferencesManager.ets#L68-L86
7b2414dfeb6bf234eba29cf4ec0b82f4296cfdf5
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/ArkUISample/EventProject/entry/src/main/ets/pages/singlegesture/SwipeGesture.ets
arkts
Swipe
[Start catch_swipe_gesture_event]
@Entry @Component export struct Swipe { @State rotateAngle: number = 0; @State speed: number = 1; build() { NavDestination() { Column({ space: 12 }) { Column() { Column() { Text('SwipeGesture speed\n' + this.speed) Text('SwipeGesture angle\n' + this.rotateAngle) } .border({ width: 3 }) .width(300) .height(200) .margin(100) // 在Column组件上绑定旋转,通过滑动手势的滑动速度和角度修改旋转的角度 .rotate({ angle: this.rotateAngle }) .gesture( // 绑定滑动手势且限制仅在竖直方向滑动时触发 SwipeGesture({ direction: SwipeDirection.Vertical }) // 当滑动手势触发时,获取滑动的速度和角度,实现对组件的布局参数的修改 .onAction((event: GestureEvent|undefined) => { if(event){ this.speed = event.speed; this.rotateAngle = event.angle; } }) ) } } .width('100%') .height('100%') .padding({ left: 12, right: 12 }) } .backgroundColor('#f1f2f3') .title($r('app.string.singlegesture_SwipeGesture_title')) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Entry AST#decorator#Right AST#decorator#Left @ Component AST#decorator#Right export struct Swipe AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right rotateAngle : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right speed : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1 AST#expression#Right ; AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left NavDestination ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 12 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'SwipeGesture speed\n' AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . speed AST#member_expression#Right AST#expression#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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'SwipeGesture angle\n' AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . rotateAngle AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . border ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width 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 . width ( AST#expression#Left 300 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 200 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left 100 AST#expression#Right ) // 在Column组件上绑定旋转,通过滑动手势的滑动速度和角度修改旋转的角度 AST#modifier_chain_expression#Left . rotate ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left angle AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rotateAngle AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . gesture ( // 绑定滑动手势且限制仅在竖直方向滑动时触发 AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left SwipeGesture AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left direction AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left SwipeDirection AST#expression#Right . Vertical 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 // 当滑动手势触发时,获取滑动的速度和角度,实现对组件的布局参数的修改 . onAction AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left event : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left GestureEvent AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left event 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 . speed AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left event AST#expression#Right . speed AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rotateAngle AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left event AST#expression#Right . angle 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#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . 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 12 AST#expression#Right AST#property_assignment#Right , 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#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 '#f1f2f3' AST#expression#Right ) AST#modifier_chain_expression#Left . title ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.singlegesture_SwipeGesture_title' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Entry @Component export struct Swipe { @State rotateAngle: number = 0; @State speed: number = 1; build() { NavDestination() { Column({ space: 12 }) { Column() { Column() { Text('SwipeGesture speed\n' + this.speed) Text('SwipeGesture angle\n' + this.rotateAngle) } .border({ width: 3 }) .width(300) .height(200) .margin(100) .rotate({ angle: this.rotateAngle }) .gesture( SwipeGesture({ direction: SwipeDirection.Vertical }) .onAction((event: GestureEvent|undefined) => { if(event){ this.speed = event.speed; this.rotateAngle = event.angle; } }) ) } } .width('100%') .height('100%') .padding({ left: 12, right: 12 }) } .backgroundColor('#f1f2f3') .title($r('app.string.singlegesture_SwipeGesture_title')) } }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ArkUISample/EventProject/entry/src/main/ets/pages/singlegesture/SwipeGesture.ets#L17-L57
6df4bcecaec39bf77f3b933ea7deaa540afa2d4d
gitee
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/components/XAxis.ets
arkts
setDrawCustomLabels
设置是否使用自定义Labels @param flag 是否使用自定义Labels
public setDrawCustomLabels(flag: boolean): void { this.mUseCustomLabels = flag; }
AST#method_declaration#Left public setDrawCustomLabels AST#parameter_list#Left ( AST#parameter#Left flag : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mUseCustomLabels AST#member_expression#Right = AST#expression#Left flag AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
public setDrawCustomLabels(flag: boolean): void { this.mUseCustomLabels = flag; }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/components/XAxis.ets#L203-L205
9ef1c258c47e7d71f792d413bf4e7bbf4026f161
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/model/src/main/ets/request/MessagePageRequest.ets
arkts
@file 分页查询消息请求 @author Joker.X
export class MessagePageRequest { /** * 会话ID */ sessionId?: number; /** * 页码 */ page: number = 1; /** * 每页大小 */ size: number = 20; /** * 排序字段 */ order: string = "createTime"; /** * 排序方式:"asc" 或 "desc" */ sort: string = "desc"; /** * @param {Partial<MessagePageRequest>} init - 初始化数据 */ constructor(init?: Partial<MessagePageRequest>) { if (!init) return; this.sessionId = init.sessionId ?? this.sessionId; this.page = init.page ?? this.page; this.size = init.size ?? this.size; this.order = init.order ?? this.order; this.sort = init.sort ?? this.sort; } }
AST#export_declaration#Left export AST#class_declaration#Left class MessagePageRequest AST#class_body#Left { /** * 会话ID */ AST#property_declaration#Left sessionId ? : 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 page : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1 AST#expression#Right ; AST#property_declaration#Right /** * 每页大小 */ AST#property_declaration#Left size : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 20 AST#expression#Right ; AST#property_declaration#Right /** * 排序字段 */ AST#property_declaration#Left order : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "createTime" AST#expression#Right ; AST#property_declaration#Right /** * 排序方式:"asc" 或 "desc" */ AST#property_declaration#Left sort : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "desc" AST#expression#Right ; AST#property_declaration#Right /** * @param {Partial<MessagePageRequest>} init - 初始化数据 */ AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left init ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Partial AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left MessagePageRequest AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left init AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sessionId AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . sessionId AST#member_expression#Right AST#expression#Right ?? AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . sessionId AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . page AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . page AST#member_expression#Right AST#expression#Right ?? AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . page AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . size AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . size AST#member_expression#Right AST#expression#Right ?? AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . size AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . order AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . order AST#member_expression#Right AST#expression#Right ?? AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . order AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sort AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . sort AST#member_expression#Right AST#expression#Right ?? AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . sort AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class MessagePageRequest { sessionId?: number; page: number = 1; size: number = 20; order: string = "createTime"; sort: string = "desc"; constructor(init?: Partial<MessagePageRequest>) { if (!init) return; this.sessionId = init.sessionId ?? this.sessionId; this.page = init.page ?? this.page; this.size = init.size ?? this.size; this.order = init.order ?? this.order; this.sort = init.sort ?? this.sort; } }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/model/src/main/ets/request/MessagePageRequest.ets#L5-L38
279e5c55132214ea74bb3080101ac6102ecb8ff9
github
zl3624/harmonyos_network_samples
b8664f8bf6ef5c5a60830fe616c6807e83c21f96
code/tls/TLSEchoServer/entry/src/main/ets/pages/Index.ets
arkts
getTlsConnOptions
获取tls监听配置信息
getTlsConnOptions(): socket.TLSConnectOptions { let listenAddress: socket.NetAddress = { address: '0.0.0.0', port: this.port } let context = getContext(this) let tlsSecOptions: socket.TLSSecureOptions = { cert: copy2SandboxAndReadContent(context, this.certFileUri), key: copy2SandboxAndReadContent(context, this.keyFileUri) } return { address: listenAddress, secureOptions: tlsSecOptions } }
AST#method_declaration#Left getTlsConnOptions AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left socket . TLSConnectOptions AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left listenAddress : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left socket . NetAddress AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left address AST#property_name#Right : AST#expression#Left '0.0.0.0' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left port AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . port AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left context = AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( AST#expression#Left this AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left tlsSecOptions : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left socket . TLSSecureOptions AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left cert AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left copy2SandboxAndReadContent AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . certFileUri 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 key AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left copy2SandboxAndReadContent AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . keyFileUri 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#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left address AST#property_name#Right : AST#expression#Left listenAddress AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left secureOptions AST#property_name#Right : AST#expression#Left tlsSecOptions AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
getTlsConnOptions(): socket.TLSConnectOptions { let listenAddress: socket.NetAddress = { address: '0.0.0.0', port: this.port } let context = getContext(this) let tlsSecOptions: socket.TLSSecureOptions = { cert: copy2SandboxAndReadContent(context, this.certFileUri), key: copy2SandboxAndReadContent(context, this.keyFileUri) } return { address: listenAddress, secureOptions: tlsSecOptions } }
https://github.com/zl3624/harmonyos_network_samples/blob/b8664f8bf6ef5c5a60830fe616c6807e83c21f96/code/tls/TLSEchoServer/entry/src/main/ets/pages/Index.ets#L137-L146
81efb7ce1d61ec2dba92b9b3df781db4f6b41ac8
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/customdrawtabbar/src/main/ets/components/tabsConcaveCircle/TabsConcaveCircle.ets
arkts
createCanvas
创建canvas 背景 和 凹槽
createCanvas() { if (this.circleInfo) { this.context.reset() CanvasCreateRectangle({ context: this.context, tabsBgColor: this.tabsBgColor }) CanvasClipGroove({ context: this.context, menuLength: this.tabsMenu.length, center: this.animationPositionX, }) } }
AST#method_declaration#Left createCanvas 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 . circleInfo AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right AST#expression#Right . reset AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left CanvasCreateRectangle ( AST#component_parameters#Left { AST#component_parameter#Left context : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left tabsBgColor : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . tabsBgColor 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 CanvasClipGroove ( AST#component_parameters#Left { AST#component_parameter#Left context : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left menuLength : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . tabsMenu AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left center : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . animationPositionX 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#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
createCanvas() { if (this.circleInfo) { this.context.reset() CanvasCreateRectangle({ context: this.context, tabsBgColor: this.tabsBgColor }) CanvasClipGroove({ context: this.context, menuLength: this.tabsMenu.length, center: this.animationPositionX, }) } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/customdrawtabbar/src/main/ets/components/tabsConcaveCircle/TabsConcaveCircle.ets#L111-L124
657e3a9a5f849825903fb794e768f131637766e6
gitee
jxdiaodeyi/YX_Sports.git
af5346bd3d5003c33c306ff77b4b5e9184219893
YX_Sports/entry/src/main/ets/pages/home/search.ets
arkts
historySearch
****************************************历史搜索 ********************************************//
@Builder historySearch(){ Column({ space: 5 }) { Row() { Text('历史搜索').fontSize(20) Image('/image/home/trash.png') .width(20) .height(20) .margin({right:10}) } .width('100%') .justifyContent(FlexAlign.SpaceBetween) .padding({left:10,top:5,bottom:5}) Row({space:5}) { Text('减脂') .fontSize(17) .backgroundColor('#FFEEEE') .borderRadius(15) .height(30) .padding({ left: 15, right: 15 }) Text('增肌') .fontSize(17) .backgroundColor('#FFEEEE') .borderRadius(15) .height(30) .padding({ left: 15, right: 15 }) Text('塑性') .fontSize(17) .backgroundColor('#FFEEEE') .borderRadius(15) .height(30) .padding({ left: 15, right: 15 }) Text('有氧') .fontSize(17) .backgroundColor('#FFEEEE') .borderRadius(15) .height(30) .padding({ left: 15, right: 15 }) } .padding(15) } .width('100%') .justifyContent(FlexAlign.Start) .alignItems(HorizontalAlign.Start) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right historySearch AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 5 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '历史搜索' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left '/image/home/trash.png' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( 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 right AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceBetween 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 10 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 5 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 5 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 5 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 17 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#FFEEEE' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 15 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 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 15 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 15 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '增肌' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 17 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#FFEEEE' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 15 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 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 15 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 15 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '塑性' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 17 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#FFEEEE' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 15 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 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 15 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 15 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '有氧' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 17 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#FFEEEE' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 15 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 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 15 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 15 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#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 15 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 . 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 . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#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 historySearch(){ Column({ space: 5 }) { Row() { Text('历史搜索').fontSize(20) Image('/image/home/trash.png') .width(20) .height(20) .margin({right:10}) } .width('100%') .justifyContent(FlexAlign.SpaceBetween) .padding({left:10,top:5,bottom:5}) Row({space:5}) { Text('减脂') .fontSize(17) .backgroundColor('#FFEEEE') .borderRadius(15) .height(30) .padding({ left: 15, right: 15 }) Text('增肌') .fontSize(17) .backgroundColor('#FFEEEE') .borderRadius(15) .height(30) .padding({ left: 15, right: 15 }) Text('塑性') .fontSize(17) .backgroundColor('#FFEEEE') .borderRadius(15) .height(30) .padding({ left: 15, right: 15 }) Text('有氧') .fontSize(17) .backgroundColor('#FFEEEE') .borderRadius(15) .height(30) .padding({ left: 15, right: 15 }) } .padding(15) } .width('100%') .justifyContent(FlexAlign.Start) .alignItems(HorizontalAlign.Start) }
https://github.com/jxdiaodeyi/YX_Sports.git/blob/af5346bd3d5003c33c306ff77b4b5e9184219893/YX_Sports/entry/src/main/ets/pages/home/search.ets#L65-L111
f959958b24cbe5edddf4cd6ea5a42672ec4945a5
github
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
VideoProcessBaseWeb/entry/src/main/ets/pages/Index.ets
arkts
onBackPress
[StartExclude index] [Start on_back_press]
onBackPress(): boolean | void { if (this.isFullScreen && this.handler) { this.handler.exitFullScreen(); return true; } return false; }
AST#method_declaration#Left onBackPress AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left boolean AST#primary_type#Right | AST#primary_type#Left void AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isFullScreen AST#member_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . handler AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . handler AST#member_expression#Right AST#expression#Right . exitFullScreen AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
onBackPress(): boolean | void { if (this.isFullScreen && this.handler) { this.handler.exitFullScreen(); return true; } return false; }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/VideoProcessBaseWeb/entry/src/main/ets/pages/Index.ets#L128-L134
c24113f2c77e0afe847b4e7ae859e86cf5c450a5
gitee
openharmony-tpc/ImageKnife
bc55de9e2edd79ed4646ce37177ad94b432874f7
library/src/main/ets/ImageKnife.ets
arkts
cancel
取消图片请求 @param request 图片请求request
cancel(request:ImageKnifeRequest) { if (typeof request?.imageKnifeOption.loadSrc === 'string' && !request?.drawMainSuccess) { emitter.emit(request.imageKnifeOption.loadSrc + request.componentId) } request.requestState = ImageKnifeRequestState.DESTROY }
AST#method_declaration#Left cancel AST#parameter_list#Left ( AST#parameter#Left request : AST#type_annotation#Left AST#primary_type#Left ImageKnifeRequest AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#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#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left request AST#expression#Right AST#unary_expression#Right AST#expression#Right ?. imageKnifeOption AST#member_expression#Right AST#expression#Right . loadSrc AST#member_expression#Right AST#expression#Right === AST#expression#Left 'string' AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#unary_expression#Left ! AST#expression#Left request AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ?. drawMainSuccess 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 emitter AST#expression#Right . emit AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left request AST#expression#Right . imageKnifeOption AST#member_expression#Right AST#expression#Right . loadSrc AST#member_expression#Right AST#expression#Right + AST#expression#Left request AST#expression#Right AST#binary_expression#Right AST#expression#Right . componentId AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left request AST#expression#Right . requestState AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left ImageKnifeRequestState AST#expression#Right . DESTROY AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
cancel(request:ImageKnifeRequest) { if (typeof request?.imageKnifeOption.loadSrc === 'string' && !request?.drawMainSuccess) { emitter.emit(request.imageKnifeOption.loadSrc + request.componentId) } request.requestState = ImageKnifeRequestState.DESTROY }
https://github.com/openharmony-tpc/ImageKnife/blob/bc55de9e2edd79ed4646ce37177ad94b432874f7/library/src/main/ets/ImageKnife.ets#L179-L184
d6e74222679a63854054eebde3ff253c401fd68f
gitee
2763981847/Accounting-app.git
cf8302a42588ecce1561b82e8533798157157257
entry/src/main/ets/view/StatisticalCardComponent.ets
arkts
StatisticalCardComponent
定义统计卡组件
@Component export default struct StatisticalCardComponent { // 使用@Link和@Watch修饰属性,监视accounts属性的变化 @Link @Watch('onAccountsChange') accounts: Array<Account>; // 使用@State修饰属性,声明一些状态变量 @State dayPay: number = dayStatistics(this.accounts, 0); // 今日支出 @State dayEarn: number = dayStatistics(this.accounts, 1); // 今日收入 @State monthPay: number = monthStatistics(this.accounts, 0); // 本月支出 @State monthEarn: number = monthStatistics(this.accounts, 1); // 本月收入 // 监听accounts属性的变化,触发onAccountsChange方法 onAccountsChange() { // 更新状态变量,以反映最新的统计数据 this.dayPay = dayStatistics(this.accounts, 0); this.dayEarn = dayStatistics(this.accounts, 1); this.monthPay = monthStatistics(this.accounts, 0); this.monthEarn = monthStatistics(this.accounts, 1); } // 构建组件 build() { // 使用Column布局,嵌套Row布局来展示统计信息 Column() { // 第一行,展示今日支出、收入、结余 Row() { Column() { Text('今日支出') .fontSize($r('app.float.font_size_M')); Text(this.dayPay.toString()) .fontSize($r('app.float.font_size_MP')) .fontWeight(FontWeight.Bold); }.alignItems(HorizontalAlign.Start); Column() { Text('今日收入') .fontSize($r('app.float.font_size_M')) .textAlign(TextAlign.Start); Text(this.dayEarn.toString()) .fontSize($r('app.float.font_size_MP')) .fontWeight(FontWeight.Bold); }.alignItems(HorizontalAlign.Start); Column() { Text('今日结余') .fontSize($r('app.float.font_size_M')) .textAlign(TextAlign.Start); Text((this.dayEarn - this.dayPay).toString()) .fontSize($r('app.float.font_size_MP')) .fontWeight(FontWeight.Bold); }.alignItems(HorizontalAlign.Start); }.height(CommonConstants.HALF_HEIGHT) // 设置行的高度 .width(CommonConstants.FULL_WIDTH) // 设置行的宽度 .justifyContent(FlexAlign.SpaceAround); // 设置子元素排列方式 // 第二行,展示本月支出、收入、结余 Row() { Column() { Text('本月支出') .fontSize($r('app.float.font_size_S')); Text(this.monthPay.toString()) .fontSize($r('app.float.font_size_M')) .fontWeight(FontWeight.Bold); }.alignItems(HorizontalAlign.Start); Column() { Text('本月收入') .fontSize($r('app.float.font_size_S')); Text(this.monthEarn.toString()) .fontSize($r('app.float.font_size_M')) .fontWeight(FontWeight.Bold); }.alignItems(HorizontalAlign.Start); Column() { Text('本月结余') .fontSize($r('app.float.font_size_S')); Text((this.monthEarn - this.monthPay).toString()) .fontSize($r('app.float.font_size_M')) .fontWeight(FontWeight.Bold); }.alignItems(HorizontalAlign.Start); }.height(CommonConstants.HALF_HEIGHT) // 设置行的高度 .width(CommonConstants.FULL_WIDTH) // 设置行的宽度 .justifyContent(FlexAlign.SpaceAround); // 设置子元素排列方式 } .backgroundImage($r('app.media.cardBackgroundImage')) // 设置背景图片 .backgroundImageSize(ImageSize.Cover) // 设置背景图片大小 .borderRadius($r('app.float.radius_size_M')) // 设置组件的圆角半径 .width(CommonConstants.FULL_WIDTH) // 设置组件的宽度 .height(CommonConstants.FULL_HEIGHT); // 设置组件的高度 } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export default struct StatisticalCardComponent AST#component_body#Left { // 使用@Link和@Watch修饰属性,监视accounts属性的变化 AST#property_declaration#Left AST#decorator#Left @ Link AST#decorator#Right AST#decorator#Left @ Watch ( AST#expression#Left 'onAccountsChange' AST#expression#Right ) AST#decorator#Right accounts : 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 Account AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 使用@State修饰属性,声明一些状态变量 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right dayPay : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left dayStatistics AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . accounts AST#member_expression#Right AST#expression#Right , AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right // 今日支出 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right dayEarn : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left dayStatistics AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . accounts AST#member_expression#Right AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right // 今日收入 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right monthPay : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left monthStatistics AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . accounts AST#member_expression#Right AST#expression#Right , AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right // 本月支出 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right monthEarn : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left monthStatistics AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . accounts AST#member_expression#Right AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right // 本月收入 // 监听accounts属性的变化,触发onAccountsChange方法 AST#method_declaration#Left onAccountsChange AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { // 更新状态变量,以反映最新的统计数据 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dayPay AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left dayStatistics AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . accounts AST#member_expression#Right AST#expression#Right , AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 . dayEarn AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left dayStatistics AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . accounts AST#member_expression#Right AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 . monthPay AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left monthStatistics AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . accounts AST#member_expression#Right AST#expression#Right , AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 . monthEarn AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left monthStatistics AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . accounts AST#member_expression#Right AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_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 { // 使用Column布局,嵌套Row布局来展示统计信息 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 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 . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.font_size_M' 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#ERROR#Left ; AST#ERROR#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dayPay AST#member_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.font_size_MP' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#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 '今日收入' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.font_size_M' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dayEarn AST#member_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.font_size_MP' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#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 '今日结余' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.font_size_M' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dayEarn AST#member_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . dayPay AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.font_size_MP' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#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 CommonConstants AST#expression#Right . HALF_HEIGHT AST#member_expression#Right AST#expression#Right ) // 设置行的高度 AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FULL_WIDTH AST#member_expression#Right AST#expression#Right ) // 设置行的宽度 AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceAround 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#expression_statement#Left AST#expression#Left AST#expression#Right ; AST#expression_statement#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 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 . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.font_size_S' 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#ERROR#Left ; AST#ERROR#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . monthPay AST#member_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.font_size_M' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#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 '本月收入' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.font_size_S' 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#ERROR#Left ; AST#ERROR#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . monthEarn AST#member_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.font_size_M' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#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 '本月结余' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.font_size_S' 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#ERROR#Left ; AST#ERROR#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . monthEarn AST#member_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . monthPay AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.font_size_M' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#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 CommonConstants AST#expression#Right . HALF_HEIGHT AST#member_expression#Right AST#expression#Right ) // 设置行的高度 AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FULL_WIDTH AST#member_expression#Right AST#expression#Right ) // 设置行的宽度 AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceAround 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#ERROR#Left ; AST#ERROR#Right // 设置子元素排列方式 } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . backgroundImage ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.cardBackgroundImage' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) // 设置背景图片 AST#modifier_chain_expression#Left . backgroundImageSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left ImageSize AST#expression#Right . Cover AST#member_expression#Right AST#expression#Right ) // 设置背景图片大小 AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.radius_size_M' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) // 设置组件的圆角半径 AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FULL_WIDTH AST#member_expression#Right AST#expression#Right ) // 设置组件的宽度 AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FULL_HEIGHT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right // 设置组件的高度 } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export default struct StatisticalCardComponent { @Link @Watch('onAccountsChange') accounts: Array<Account>; @State dayPay: number = dayStatistics(this.accounts, 0); @State dayEarn: number = dayStatistics(this.accounts, 1); @State monthPay: number = monthStatistics(this.accounts, 0); @State monthEarn: number = monthStatistics(this.accounts, 1); onAccountsChange() { this.dayPay = dayStatistics(this.accounts, 0); this.dayEarn = dayStatistics(this.accounts, 1); this.monthPay = monthStatistics(this.accounts, 0); this.monthEarn = monthStatistics(this.accounts, 1); } build() { Column() { Row() { Column() { Text('今日支出') .fontSize($r('app.float.font_size_M')); Text(this.dayPay.toString()) .fontSize($r('app.float.font_size_MP')) .fontWeight(FontWeight.Bold); }.alignItems(HorizontalAlign.Start); Column() { Text('今日收入') .fontSize($r('app.float.font_size_M')) .textAlign(TextAlign.Start); Text(this.dayEarn.toString()) .fontSize($r('app.float.font_size_MP')) .fontWeight(FontWeight.Bold); }.alignItems(HorizontalAlign.Start); Column() { Text('今日结余') .fontSize($r('app.float.font_size_M')) .textAlign(TextAlign.Start); Text((this.dayEarn - this.dayPay).toString()) .fontSize($r('app.float.font_size_MP')) .fontWeight(FontWeight.Bold); }.alignItems(HorizontalAlign.Start); }.height(CommonConstants.HALF_HEIGHT) .width(CommonConstants.FULL_WIDTH) .justifyContent(FlexAlign.SpaceAround); Row() { Column() { Text('本月支出') .fontSize($r('app.float.font_size_S')); Text(this.monthPay.toString()) .fontSize($r('app.float.font_size_M')) .fontWeight(FontWeight.Bold); }.alignItems(HorizontalAlign.Start); Column() { Text('本月收入') .fontSize($r('app.float.font_size_S')); Text(this.monthEarn.toString()) .fontSize($r('app.float.font_size_M')) .fontWeight(FontWeight.Bold); }.alignItems(HorizontalAlign.Start); Column() { Text('本月结余') .fontSize($r('app.float.font_size_S')); Text((this.monthEarn - this.monthPay).toString()) .fontSize($r('app.float.font_size_M')) .fontWeight(FontWeight.Bold); }.alignItems(HorizontalAlign.Start); }.height(CommonConstants.HALF_HEIGHT) .width(CommonConstants.FULL_WIDTH) .justifyContent(FlexAlign.SpaceAround); } .backgroundImage($r('app.media.cardBackgroundImage')) .backgroundImageSize(ImageSize.Cover) 大小 .borderRadius($r('app.float.radius_size_M')) .width(CommonConstants.FULL_WIDTH) .height(CommonConstants.FULL_HEIGHT); } }
https://github.com/2763981847/Accounting-app.git/blob/cf8302a42588ecce1561b82e8533798157157257/entry/src/main/ets/view/StatisticalCardComponent.ets#L7-L97
97c24f5a116ca3627c0af51edfec1d51b09f7ac9
github
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/data/BaseDataSet.ets
arkts
setColorsByList
###### ###### COLOR SETTING RELATED METHODS ##### ###### Sets the colors that should be used fore this DataSet. Colors are reused as soon as the number of Entries the DataSet represents is higher than the size of the colors array. If you are using colors from the resources, make sure that the colors are already prepared (by calling getResources().getColor(...)) before adding them to the DataSet. @param colors
public setColorsByList(colors: JArrayList<Number>): void { this.mColors = colors; }
AST#method_declaration#Left public setColorsByList AST#parameter_list#Left ( AST#parameter#Left colors : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left JArrayList AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left 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#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 . mColors AST#member_expression#Right = AST#expression#Left colors AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
public setColorsByList(colors: JArrayList<Number>): void { this.mColors = colors; }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/data/BaseDataSet.ets#L147-L149
39d12c50828a43ff6a7804c862a227f11588a18c
gitee
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
ETSUI/SwiperArkTS/entry/src/main/ets/common/constants/PictureConstants.ets
arkts
Pictures of banner.
export const PICTURE_BANNER: PictureItem[] = [ { id: '1', name: '怒海', description: '怒海波涛', image: $r("app.media.ic_image1") }, { id: '2', name: '大山深处', description: '大山深处感人的亲情之歌', image: $r("app.media.ic_image2") }, { id: '3', name: '荒漠', description: '荒漠的亲情之歌', image: $r("app.media.ic_image3") } ];
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left PICTURE_BANNER : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left PictureItem [ ] 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 id AST#property_name#Right : AST#expression#Left '1' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left name AST#property_name#Right : AST#expression#Left '怒海' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left description AST#property_name#Right : AST#expression#Left '怒海波涛' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left image AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.ic_image1" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left id AST#property_name#Right : AST#expression#Left '2' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left name AST#property_name#Right : AST#expression#Left '大山深处' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left description AST#property_name#Right : AST#expression#Left '大山深处感人的亲情之歌' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left image AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.ic_image2" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left id AST#property_name#Right : AST#expression#Left '3' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left name AST#property_name#Right : AST#expression#Left '荒漠' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left description AST#property_name#Right : AST#expression#Left '荒漠的亲情之歌' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left image AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.ic_image3" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
export const PICTURE_BANNER: PictureItem[] = [ { id: '1', name: '怒海', description: '怒海波涛', image: $r("app.media.ic_image1") }, { id: '2', name: '大山深处', description: '大山深处感人的亲情之歌', image: $r("app.media.ic_image2") }, { id: '3', name: '荒漠', description: '荒漠的亲情之歌', image: $r("app.media.ic_image3") } ];
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/ETSUI/SwiperArkTS/entry/src/main/ets/common/constants/PictureConstants.ets#L21-L25
6ccb3d5c49993a797d76de5821369ed19fbc2035
gitee
wuyuanwuhui99/harmony-arkts-music-app-ui.git
fc75b993b76293666f9122f527ea3bc6caf7f75c
entry/src/main/ets/pages/MusicAuthorMusicListPage.ets
arkts
useMusicListByAuthorId
@description: 根据收藏夹id查询音乐列表 @date: 2024-07-16 23:39 @author wuwenqiang
useMusicListByAuthorId(){ getMusicListByAuthorIdService(this.musicAuthor!.authorId,this.pageNum,PAGE_SIZE).then((res) => { this.musicList.push(...res.data); this.total = res.total; }) }
AST#method_declaration#Left useMusicListByAuthorId 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 getMusicListByAuthorIdService ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . musicAuthor AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . authorId AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . pageNum AST#member_expression#Right AST#expression#Right , AST#expression#Left PAGE_SIZE AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . then ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left res AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . musicList AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#spread_element#Left ... AST#expression#Left AST#member_expression#Left AST#expression#Left res AST#expression#Right . data AST#member_expression#Right AST#expression#Right AST#spread_element#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . total AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left res AST#expression#Right . total AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
useMusicListByAuthorId(){ getMusicListByAuthorIdService(this.musicAuthor!.authorId,this.pageNum,PAGE_SIZE).then((res) => { this.musicList.push(...res.data); this.total = res.total; }) }
https://github.com/wuyuanwuhui99/harmony-arkts-music-app-ui.git/blob/fc75b993b76293666f9122f527ea3bc6caf7f75c/entry/src/main/ets/pages/MusicAuthorMusicListPage.ets#L41-L46
bb4dbfaba5c811aa44fe0b8cdda3424b6659540a
github
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@system.router.d.ets
arkts
Define ParamsInterface. @typedef { object } ParamsInterface @syscap SystemCapability.ArkUI.ArkUI.Full @since 7 @deprecated since 8
export type ParamsInterface = Record<string,Object> /** * Defines the Router interface. * * @syscap SystemCapability.ArkUI.ArkUI.Lite * @since 3 * @deprecated since 8 * @useinstead ohos.router#router */ declare class Router { /** * Navigates to a specified page in the application based on the page URL and parameters. * * @param { RouterOptions } options Options. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 3 * @deprecated since 8 */ static push(options: RouterOptions): void; /** * Replaces the current page with another one in the application. The current page is destroyed after replacement. * * @param { RouterOptions } options Options. * @syscap SystemCapability.ArkUI.ArkUI.Lite * @since 3 * @deprecated since 8 */ static replace(options: RouterOptions): void; /** * Returns to the previous page or a specified page. * * @param { BackRouterOptions } options Options. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 3 * @deprecated since 8 */ static back(options?: BackRouterOptions): void; /** * Obtains information about the current page params. * * @returns { ParamsInterface } Page params. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 7 * @deprecated since 8 */ static getParams(): ParamsInterface; /** * Clears all historical pages and retains only the current page at the top of the stack. * * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 3 * @deprecated since 8 */ static clear(): void; /** * Obtains the number of pages in the current stack. * * @returns { string } Number of pages in the stack. The maximum value is 32. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 3 * @deprecated since 8 */ static getLength(): string; /** * Obtains information about the current page state. * * @returns { RouterState } Page state. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 3 * @deprecated since 8 */ static getState(): RouterState; /** * Pop up dialog to ask whether to back * * @param { EnableAlertBeforeBackPageOptions } options Options. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 6 * @deprecated since 8 */ static enableAlertBeforeBackPage(options: EnableAlertBeforeBackPageOptions): void; /** * cancel enableAlertBeforeBackPage * * @param { DisableAlertBeforeBackPageOptions } options Options. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 6 * @deprecated since 8 */ static disableAlertBeforeBackPage(options?: DisableAlertBeforeBackPageOptions): void; }
AST#export_declaration#Left export AST#ERROR#Left type ParamsInterface = 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 /** * Defines the Router interface. * * @syscap SystemCapability.ArkUI.ArkUI.Lite * @since 3 * @deprecated since 8 * @useinstead ohos.router#router */ declare AST#ERROR#Right AST#class_declaration#Left class Router AST#class_body#Left { /** * Navigates to a specified page in the application based on the page URL and parameters. * * @param { RouterOptions } options Options. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 3 * @deprecated since 8 */ AST#method_declaration#Left static push AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left RouterOptions 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#method_declaration#Right /** * Replaces the current page with another one in the application. The current page is destroyed after replacement. * * @param { RouterOptions } options Options. * @syscap SystemCapability.ArkUI.ArkUI.Lite * @since 3 * @deprecated since 8 */ AST#method_declaration#Left static replace AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left RouterOptions 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#method_declaration#Right /** * Returns to the previous page or a specified page. * * @param { BackRouterOptions } options Options. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 3 * @deprecated since 8 */ AST#method_declaration#Left static back AST#parameter_list#Left ( AST#parameter#Left options ? : AST#type_annotation#Left AST#primary_type#Left BackRouterOptions 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#method_declaration#Right /** * Obtains information about the current page params. * * @returns { ParamsInterface } Page params. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 7 * @deprecated since 8 */ AST#method_declaration#Left static getParams AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left ParamsInterface AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right /** * Clears all historical pages and retains only the current page at the top of the stack. * * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 3 * @deprecated since 8 */ AST#method_declaration#Left static clear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right /** * Obtains the number of pages in the current stack. * * @returns { string } Number of pages in the stack. The maximum value is 32. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 3 * @deprecated since 8 */ AST#method_declaration#Left static getLength AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right /** * Obtains information about the current page state. * * @returns { RouterState } Page state. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 3 * @deprecated since 8 */ AST#method_declaration#Left static getState AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left RouterState AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right /** * Pop up dialog to ask whether to back * * @param { EnableAlertBeforeBackPageOptions } options Options. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 6 * @deprecated since 8 */ AST#method_declaration#Left static enableAlertBeforeBackPage AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left EnableAlertBeforeBackPageOptions 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#method_declaration#Right /** * cancel enableAlertBeforeBackPage * * @param { DisableAlertBeforeBackPageOptions } options Options. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 6 * @deprecated since 8 */ AST#method_declaration#Left static disableAlertBeforeBackPage AST#parameter_list#Left ( AST#parameter#Left options ? : AST#type_annotation#Left AST#primary_type#Left DisableAlertBeforeBackPageOptions 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#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export type ParamsInterface = Record<string,Object> declare class Router { static push(options: RouterOptions): void; static replace(options: RouterOptions): void; static back(options?: BackRouterOptions): void; static getParams(): ParamsInterface; static clear(): void; static getLength(): string; static getState(): RouterState; static enableAlertBeforeBackPage(options: EnableAlertBeforeBackPageOptions): void; static disableAlertBeforeBackPage(options?: DisableAlertBeforeBackPageOptions): void; }
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@system.router.d.ets#L233-L332
d08dd8f550c7a431e02c15457550fa45a1663557
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/datas/model/SearchManager.ets
arkts
deleteLearnTimes
MARK: - 数据操作和方法 清空学习次数
async deleteLearnTimes(): Promise<void> { this.allWords.forEach(word => { word.learnTimes = 0; }); await WordUserDbAccess.shared.clearLearnTimes() }
AST#method_declaration#Left async deleteLearnTimes AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . allWords AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left word => 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 word AST#expression#Right . learnTimes AST#member_expression#Right = AST#expression#Left 0 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left WordUserDbAccess AST#expression#Right AST#await_expression#Right AST#expression#Right . shared AST#member_expression#Right AST#expression#Right . clearLearnTimes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
async deleteLearnTimes(): Promise<void> { this.allWords.forEach(word => { word.learnTimes = 0; }); await WordUserDbAccess.shared.clearLearnTimes() }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/datas/model/SearchManager.ets#L775-L780
3d048691b493e94e6da429dd72d4f09de7747f82
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/iab/SubscribeManager.ets
arkts
定义通知相关的常量
export class SubscribeManagerNotification { static readonly expireDateUpdated = "SubscribeManager.subscribeItem.expiresDateMs.updated" }
AST#export_declaration#Left export AST#class_declaration#Left class SubscribeManagerNotification AST#class_body#Left { AST#property_declaration#Left static readonly expireDateUpdated = AST#expression#Left "SubscribeManager.subscribeItem.expiresDateMs.updated" AST#expression#Right AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class SubscribeManagerNotification { static readonly expireDateUpdated = "SubscribeManager.subscribeItem.expiresDateMs.updated" }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/iab/SubscribeManager.ets#L18-L22
3d4b5f7b233355d8895478c8bc4256c03dc08b9c
github
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
core/designsystem/src/main/ets/component/Column.ets
arkts
渲染布局 @returns {void} 无返回值 @example ColumnSpaceAroundStart() { Text("A"); Text("B"); Text("C"); }
build(): void { ColumnBase({ options: this.options, justifyContent: FlexAlign.SpaceAround, alignItems: HorizontalAlign.Start, widthValue: this.widthValue, heightValue: this.heightValue, sizeValue: this.sizeValue, paddingValue: this.paddingValue, marginValue: this.marginValue, fillMaxSize: this.fillMaxSize, bgColor: this.bgColor, onTap: this.onTap, content: this.content }); }
AST#build_method#Left build ( ) : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#build_body#Left { AST#ui_custom_component_statement#Left ColumnBase ( AST#component_parameters#Left { AST#component_parameter#Left options : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left justifyContent : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceAround 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 . Start AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left widthValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . widthValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left heightValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . heightValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left sizeValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sizeValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left paddingValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . paddingValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left marginValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . marginValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left fillMaxSize : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . fillMaxSize AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left bgColor : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bgColor AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onTap : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onTap AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left content : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . content AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right } AST#build_body#Right AST#build_method#Right
build(): void { ColumnBase({ options: this.options, justifyContent: FlexAlign.SpaceAround, alignItems: HorizontalAlign.Start, 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#L1164-L1179
f52b15b1bc6fb6934390c60a55cabe92baff8d5e
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
harmonyos/src/main/ets/pages/SearchPage.ets
arkts
searchContacts
搜索联系人
private async searchContacts(keyword: string): Promise<Contact[]> { if (this.activeTab === 'greetings') return []; return await this.contactService.searchContacts({ keyword, pageSize: 50 }); }
AST#method_declaration#Left private async searchContacts AST#parameter_list#Left ( AST#parameter#Left keyword : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Contact [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . activeTab AST#member_expression#Right AST#expression#Right === AST#expression#Left 'greetings' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#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 keyword AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left pageSize AST#property_name#Right : AST#expression#Left 50 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private async searchContacts(keyword: string): Promise<Contact[]> { if (this.activeTab === 'greetings') return []; return await this.contactService.searchContacts({ keyword, pageSize: 50 }); }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/pages/SearchPage.ets#L135-L142
c8eeedecea3ed072b89cd8e770d0dd73b0c1b42d
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_rcp/src/main/ets/rcp/EfRcp.ets
arkts
addSysCodeEvent
添加统一的系统框架级别编码拦截操作 @param codeEvent 系统级别编码操作事件 efRcpConfig.sysCodeEvent @returns
addSysCodeEvent(codeEvent: efRcpConfig.sysCodeEvent): EfRcp { if (this.cfg.interceptors) { this.cfg.interceptors.push(new EfSysCodeInterceptor(codeEvent)); } else { this.cfg.interceptors = [new EfSysCodeInterceptor(codeEvent)]; } return this; }
AST#method_declaration#Left addSysCodeEvent AST#parameter_list#Left ( AST#parameter#Left codeEvent : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left efRcpConfig . sysCodeEvent 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 EfRcp 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#member_expression#Left AST#expression#Left this AST#expression#Right . cfg AST#member_expression#Right AST#expression#Right . interceptors AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cfg AST#member_expression#Right AST#expression#Right . interceptors 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 EfSysCodeInterceptor AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left codeEvent 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 } else { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cfg AST#member_expression#Right AST#expression#Right . interceptors AST#member_expression#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 EfSysCodeInterceptor AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left codeEvent AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left this AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
addSysCodeEvent(codeEvent: efRcpConfig.sysCodeEvent): EfRcp { if (this.cfg.interceptors) { this.cfg.interceptors.push(new EfSysCodeInterceptor(codeEvent)); } else { this.cfg.interceptors = [new EfSysCodeInterceptor(codeEvent)]; } return this; }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_rcp/src/main/ets/rcp/EfRcp.ets#L222-L229
1369919b3b059ea964399a8d389f5ef9c12185e4
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/contacts/ContactImportPage.ets
arkts
buildTabBar
构建标签栏
@Builder buildTabBar() { Row() { this.buildTabItem('CSV格式', 0) this.buildTabItem('JSON格式', 1) this.buildTabItem('复制粘贴', 2) } .width('100%') .height('50vp') .backgroundColor('#ffffff') .border({ width: { bottom: 1 }, color: '#e5e5e5' }) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildTabBar 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 Row ( ) 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 . buildTabItem AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'CSV格式' 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buildTabItem AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'JSON格式' AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buildTabItem AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '复制粘贴' AST#expression#Right , AST#expression#Left 2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#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 '50vp' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#ffffff' AST#expression#Right ) AST#modifier_chain_expression#Left . border ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 1 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left '#e5e5e5' 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#builder_function_body#Right AST#method_declaration#Right
@Builder buildTabBar() { Row() { this.buildTabItem('CSV格式', 0) this.buildTabItem('JSON格式', 1) this.buildTabItem('复制粘贴', 2) } .width('100%') .height('50vp') .backgroundColor('#ffffff') .border({ width: { bottom: 1 }, color: '#e5e5e5' }) }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/contacts/ContactImportPage.ets#L79-L90
e6a0940240392a03a8a6fb68e23a1eda1e39e5b3
github
bigbear20240612/planner_build-.git
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
entry/src/main/ets/common/utils/StorageUtils.ets
arkts
putString
存储字符串数据 @param key 存储键 @param value 存储值
static async putString(key: string, value: string): Promise<void> { const dataPreferences = StorageUtils.dataPreferences; if (!dataPreferences) { console.error('Preferences not initialized'); return; } try { await dataPreferences.put(key, value); await dataPreferences.flush(); } catch (error) { console.error(`Failed to put string for key ${key}:`, error); } }
AST#method_declaration#Left static async putString 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 string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left dataPreferences = AST#expression#Left AST#member_expression#Left AST#expression#Left StorageUtils AST#expression#Right . dataPreferences AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left dataPreferences AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Preferences not initialized' 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left dataPreferences AST#expression#Right AST#await_expression#Right AST#expression#Right . put AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right , AST#expression#Left value AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#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 dataPreferences AST#expression#Right AST#await_expression#Right AST#expression#Right . flush AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` Failed to put string for key AST#template_substitution#Left $ { AST#expression#Left key AST#expression#Right } AST#template_substitution#Right : ` AST#template_literal#Right AST#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static async putString(key: string, value: string): Promise<void> { const dataPreferences = StorageUtils.dataPreferences; if (!dataPreferences) { console.error('Preferences not initialized'); return; } try { await dataPreferences.put(key, value); await dataPreferences.flush(); } catch (error) { console.error(`Failed to put string for key ${key}:`, error); } }
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/common/utils/StorageUtils.ets#L24-L37
7c2bd80db64fee08e654d26b283521c8b36796bc
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/common/routermodule/src/main/ets/interceptor/Interceptor.ets
arkts
定义拦截器方法
export class Interceptor { // 定义拦截器容器 private static list: Array<InterceptorExecute> = []; /** * 注册拦截页面 * * @param interceptorFnc 子模块传过来的自定义拦截函数 */ public static registerInterceptorPage(interceptorFnc: InterceptorExecute): void { Interceptor.list.push(interceptorFnc); } /** * 公共拦截器逻辑 * * @param appUri 接收传过来的路由名 * @param param 路由参数 */ public static interceptor(appUri: string, param?: string): boolean { // 循环拦截器容器中所有的子模块自定义的拦截函数 for (let i = 0; i < Interceptor.list.length; i++) { if (Interceptor.list[i].executeFunction(appUri, param)) return true; // 如果子模块拦截函数返回true,即需要拦截 } // 否则就放行 return false; } }
AST#export_declaration#Left export AST#class_declaration#Left class Interceptor AST#class_body#Left { // 定义拦截器容器 AST#property_declaration#Left private static list : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left InterceptorExecute AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right /** * 注册拦截页面 * * @param interceptorFnc 子模块传过来的自定义拦截函数 */ AST#method_declaration#Left public static registerInterceptorPage AST#parameter_list#Left ( AST#parameter#Left interceptorFnc : AST#type_annotation#Left AST#primary_type#Left InterceptorExecute 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 Interceptor AST#expression#Right . list AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left interceptorFnc AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /** * 公共拦截器逻辑 * * @param appUri 接收传过来的路由名 * @param param 路由参数 */ AST#method_declaration#Left public static interceptor AST#parameter_list#Left ( AST#parameter#Left appUri : 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 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#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left Interceptor AST#expression#Right AST#binary_expression#Right AST#expression#Right . list AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( 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 Interceptor AST#expression#Right . list AST#member_expression#Right AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . executeFunction AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left appUri AST#expression#Right , AST#expression#Left param AST#expression#Right ) 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 true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right // 如果子模块拦截函数返回true,即需要拦截 } AST#block_statement#Right AST#for_statement#Right AST#statement#Right // 否则就放行 AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class Interceptor { private static list: Array<InterceptorExecute> = []; public static registerInterceptorPage(interceptorFnc: InterceptorExecute): void { Interceptor.list.push(interceptorFnc); } public static interceptor(appUri: string, param?: string): boolean { for (let i = 0; i < Interceptor.list.length; i++) { if (Interceptor.list[i].executeFunction(appUri, param)) return true; } return false; } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/common/routermodule/src/main/ets/interceptor/Interceptor.ets#L42-L70
92c9f438c8abdac04ecd6b989af55cde4c42bece
gitee
Tianpei-Shi/MusicDash.git
4db7ea82fb9d9fa5db7499ccdd6d8d51a4bb48d5
src/services/CloudDBService.ets
arkts
getUserPlayHistory
获取用户的播放历史记录
async getUserPlayHistory(userId: number): Promise<CloudDBZoneObject[]> { try { // 模拟获取播放历史 console.log(`获取用户播放历史,用户ID: ${userId}`); const historyText = userId === 1001 ? "稻香,晴天,七里香" : "演员,绅士,意外"; const songTitles: string[] = historyText.split(','); const songs: CloudDBZoneObject[] = songTitles.map((title, index) => { const song: CloudDBZoneObject = { id: `${userId}_${index}_${Date.now()}`, userId: userId, songId: 1000 + index, songTitle: title, songArtist: userId === 1001 ? "周杰伦" : "薛之谦", playedTime: Date.now() - index * 86400000 // 每首歌相差一天 }; return song; }); return songs; } catch (error) { console.error('获取播放历史记录失败:', error); return []; } }
AST#method_declaration#Left async getUserPlayHistory AST#parameter_list#Left ( AST#parameter#Left userId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left CloudDBZoneObject [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 模拟获取播放历史 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 获取用户播放历史,用户ID: AST#template_substitution#Left $ { AST#expression#Left userId AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left historyText = AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left userId AST#expression#Right === AST#expression#Left 1001 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left "稻香,晴天,七里香" AST#expression#Right : AST#expression#Left "演员,绅士,意外" AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left songTitles : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left historyText AST#expression#Right . split AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left ',' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left songs : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left CloudDBZoneObject [ ] 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 songTitles AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left title 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 song : AST#type_annotation#Left AST#primary_type#Left CloudDBZoneObject 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 ` AST#template_substitution#Left $ { AST#expression#Left userId AST#expression#Right } AST#template_substitution#Right _ AST#template_substitution#Left $ { AST#expression#Left index AST#expression#Right } AST#template_substitution#Right _ AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Date AST#expression#Right . 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 ` 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 userId AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left songId AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left 1000 AST#expression#Right + AST#expression#Left index AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left songTitle AST#property_name#Right : AST#expression#Left title AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left songArtist AST#property_name#Right : AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left userId AST#expression#Right === AST#expression#Left 1001 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left "周杰伦" AST#expression#Right : AST#expression#Left "薛之谦" AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left playedTime AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Date AST#expression#Right . now AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right - AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right * AST#expression#Left 86400000 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right // 每首歌相差一天 } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left song AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left songs AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '获取播放历史记录失败:' AST#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async getUserPlayHistory(userId: number): Promise<CloudDBZoneObject[]> { try { console.log(`获取用户播放历史,用户ID: ${userId}`); const historyText = userId === 1001 ? "稻香,晴天,七里香" : "演员,绅士,意外"; const songTitles: string[] = historyText.split(','); const songs: CloudDBZoneObject[] = songTitles.map((title, index) => { const song: CloudDBZoneObject = { id: `${userId}_${index}_${Date.now()}`, userId: userId, songId: 1000 + index, songTitle: title, songArtist: userId === 1001 ? "周杰伦" : "薛之谦", playedTime: Date.now() - index * 86400000 }; return song; }); return songs; } catch (error) { console.error('获取播放历史记录失败:', error); return []; } }
https://github.com/Tianpei-Shi/MusicDash.git/blob/4db7ea82fb9d9fa5db7499ccdd6d8d51a4bb48d5/src/services/CloudDBService.ets#L148-L171
5049542c9cdbfb7b3fffa817a9b13538b8aabbd6
github
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/charts/PieChartModel.ets
arkts
setCenterTextOffset
Sets the offset the center text should have from it's original position in vp. Default x = 0, y = 0 @param x @param y
public setCenterTextOffset(x: number, y: number): void { this.mCenterTextOffset.x = Utils.handleDataValues(x); this.mCenterTextOffset.y = Utils.handleDataValues(y); }
AST#method_declaration#Left public setCenterTextOffset 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 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . mCenterTextOffset AST#member_expression#Right AST#expression#Right . x AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Utils AST#expression#Right . handleDataValues AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left x AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mCenterTextOffset AST#member_expression#Right AST#expression#Right . y AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Utils AST#expression#Right . handleDataValues AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left y 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
public setCenterTextOffset(x: number, y: number): void { this.mCenterTextOffset.x = Utils.handleDataValues(x); this.mCenterTextOffset.y = Utils.handleDataValues(y); }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/charts/PieChartModel.ets#L593-L596
e7520e6523c3362a7957d84a31e52d14846a8e0f
gitee
open9527/OpenHarmony
fdea69ed722d426bf04e817ec05bff4002e81a4e
libs/core/src/main/ets/utils/NetConnectionUtils.ets
arkts
hasDefaultNetSync
检查默认数据网络是否被激活
static hasDefaultNetSync(): boolean { return connection.hasDefaultNetSync(); }
AST#method_declaration#Left static hasDefaultNetSync AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left connection AST#expression#Right . hasDefaultNetSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static hasDefaultNetSync(): boolean { return connection.hasDefaultNetSync(); }
https://github.com/open9527/OpenHarmony/blob/fdea69ed722d426bf04e817ec05bff4002e81a4e/libs/core/src/main/ets/utils/NetConnectionUtils.ets#L27-L29
2037e84028cf07b7fc161b3023f8e8c978f502af
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/pipwindow/src/main/ets/util/TimeTools.ets
arkts
对视频数字进行整改 @param num 视频相关数字 @returns 未超过10数字前添加0,超过10未做整改
export function fillNum(num: number) { if (num < 10) { return `0${num}`; } return num.toString(); }
AST#export_declaration#Left export AST#function_declaration#Left function fillNum AST#parameter_list#Left ( AST#parameter#Left num : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left num AST#expression#Right < AST#expression#Left 10 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#template_literal#Left ` 0 AST#template_substitution#Left $ { AST#expression#Left num 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#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 num AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function fillNum(num: number) { if (num < 10) { return `0${num}`; } return num.toString(); }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/pipwindow/src/main/ets/util/TimeTools.ets#L21-L26
895d2ebb5d4293f0cd1c36f7b92a24d04199e61a
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/components/Sounds/Cloud/Download/CBook/CBookManager.ets
arkts
clearAllCBooks
清空所有 CBook,以便可以重新刷新
public clearAllCBooks(): void { this.cmetaInfoManager.clearAll((fileName) => { this.removeBookDb(CMetaInfoHelper.baseName(fileName)); }); }
AST#method_declaration#Left public clearAllCBooks AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cmetaInfoManager AST#member_expression#Right AST#expression#Right . clearAll 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 fileName 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 this AST#expression#Right . removeBookDb 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 CMetaInfoHelper AST#expression#Right . baseName AST#member_expression#Right 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#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
public clearAllCBooks(): void { this.cmetaInfoManager.clearAll((fileName) => { this.removeBookDb(CMetaInfoHelper.baseName(fileName)); }); }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/components/Sounds/Cloud/Download/CBook/CBookManager.ets#L245-L249
cbde55b18d22ef126300a5a41fdf81c806eb1a33
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/livedetectionandencryptiond/src/main/ets/pages/LiveDetectionAndEncryptionPage.ets
arkts
encodeAndUpload
模拟加密上传 @param encodeData 加密和上传的数据
encodeAndUpload(encodeData: string) { encryptMessagePromise(encodeData, cryptoFramework.CryptoMode.ENCRYPT_MODE) .then((res) => { let base = new util.Base64Helper(); // 获取到的uint8array转换成字符串 this.uploadContent = base.encodeToStringSync(res); }) }
AST#method_declaration#Left encodeAndUpload AST#parameter_list#Left ( AST#parameter#Left encodeData : 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 encryptMessagePromise ( AST#expression#Left encodeData AST#expression#Right , 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#ui_component#Right AST#modifier_chain_expression#Left . then ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left res AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left base = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left util AST#expression#Right AST#new_expression#Right AST#expression#Right . Base64Helper 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 // 获取到的uint8array转换成字符串 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 . uploadContent AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left base AST#expression#Right . encodeToStringSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left res AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
encodeAndUpload(encodeData: string) { encryptMessagePromise(encodeData, cryptoFramework.CryptoMode.ENCRYPT_MODE) .then((res) => { let base = new util.Base64Helper(); this.uploadContent = base.encodeToStringSync(res); }) }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/livedetectionandencryptiond/src/main/ets/pages/LiveDetectionAndEncryptionPage.ets#L101-L108
263ad75666e3c368bce3945c7ea16739d27664d7
gitee
ThePivotPoint/ArkTS-LSP-Server-Plugin.git
6231773905435f000d00d94b26504433082ba40b
packages/declarations/ets/api/@ohos.file.RecentPhotoComponent.d.ets
arkts
Recent photo info @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core @atomicservice @since 13
export declare class RecentPhotoInfo { /** * The dateTaken of photos or videos * * @type { ?number } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 13 */ dateTaken?: number; /** * The identifier of photos or videos * * @type { ?string } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 13 */ identifier?: string; }
AST#export_declaration#Left export AST#ERROR#Left declare AST#ERROR#Right AST#class_declaration#Left class RecentPhotoInfo AST#class_body#Left { /** * The dateTaken of photos or videos * * @type { ?number } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 13 */ AST#property_declaration#Left dateTaken ? : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * The identifier of photos or videos * * @type { ?string } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 13 */ AST#property_declaration#Left identifier ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export declare class RecentPhotoInfo { dateTaken?: number; identifier?: string; }
https://github.com/ThePivotPoint/ArkTS-LSP-Server-Plugin.git/blob/6231773905435f000d00d94b26504433082ba40b/packages/declarations/ets/api/@ohos.file.RecentPhotoComponent.d.ets#L141-L160
0d672d838ab00b6e3e0e156ca8ba1f03d4c68517
github
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@system.prompt.d.ets
arkts
Defines the response of ShowDialog. @interface ShowDialogSuccessResponse @syscap SystemCapability.ArkUI.ArkUI.Full @since 3 Defines the response of ShowDialog. @interface ShowDialogSuccessResponse @syscap SystemCapability.ArkUI.ArkUI.Full @atomicservice @since 11
export interface ShowDialogSuccessResponse { /** * Defines the index of data. * * @type { number } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 3 */ /** * Defines the index of data. * * @type { number } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ index: number; }
AST#export_declaration#Left export AST#interface_declaration#Left interface ShowDialogSuccessResponse AST#object_type#Left { /** * Defines the index of data. * * @type { number } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 3 */ /** * Defines the index of data. * * @type { number } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ AST#type_member#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface ShowDialogSuccessResponse { index: number; }
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@system.prompt.d.ets#L130-L147
14c7e1bada8b0bc3b0072105e4ee5b1c58ca02f7
gitee
openharmony/xts_acts
5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686
arkui/ace_ets_module_ui/ace_ets_module_commonAttrsLayout/ace_ets_module_commonAttrsLayout_nowear_api11/entry/src/main/ets/MainAbility/pages/comSizeAbility/WaterFlowDataSource.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 WaterFlowDataSource implements IDataSource { private dataArray: number[] = [] private listeners: DataChangeListener[] = [] constructor
AST#export_declaration#Left export AST#ERROR#Left class WaterFlowDataSource AST#implements_clause#Left implements IDataSource AST#implements_clause#Right { AST#property_declaration#Left private dataArray : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#property_declaration#Right private listeners : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left DataChangeListener [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#ERROR#Right AST#variable_declaration#Left const AST#variable_declarator#Left ructor AST#variable_declarator#Right AST#variable_declaration#Right AST#export_declaration#Right
export class WaterFlowDataSource implements IDataSource { private dataArray: number[] = [] private listeners: DataChangeListener[] = [] constructor
https://github.com/openharmony/xts_acts/blob/5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686/arkui/ace_ets_module_ui/ace_ets_module_commonAttrsLayout/ace_ets_module_commonAttrsLayout_nowear_api11/entry/src/main/ets/MainAbility/pages/comSizeAbility/WaterFlowDataSource.ets#L15-L19
b899246f97122fbea4e8a14568adc212967a06ff
gitee
sithvothykiv/dialog_hub.git
b676c102ef2d05f8994d170abe48dcc40cd39005
custom_dialog/src/main/ets/core/DialogCoreHandler.ets
arkts
openCustomDialog
创建并弹出dialogContent对应的自定义弹窗 @param contentView 自定义弹窗中显示的组件内容。 @param options 弹窗样式。
openCustomDialog<T extends IBaseDialogOptions>(contentView: WrappedBuilder<[T]>, options: T): string { if (!options.dialogId) { options.dialogId = this.generateDialogId(); } if (options.uiContext) { this.openBaseCustomDialog(options.uiContext, contentView, options); } else { window.getLastWindow(getContext()).then((result: window.Window) => { this.openBaseCustomDialog(result.getUIContext(), contentView, options); }) } return options.dialogId; }
AST#method_declaration#Left openCustomDialog AST#type_parameters#Left < AST#type_parameter#Left T extends AST#type_annotation#Left AST#primary_type#Left IBaseDialogOptions AST#primary_type#Right AST#type_annotation#Right AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left contentView : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left WrappedBuilder AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left options AST#expression#Right AST#unary_expression#Right AST#expression#Right . dialogId AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . dialogId AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . generateDialogId 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#ui_if_statement#Right AST#ui_control_flow#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . uiContext AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . openBaseCustomDialog AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . uiContext AST#member_expression#Right AST#expression#Right , AST#expression#Left contentView AST#expression#Right , AST#expression#Left options AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } else { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . getLastWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left result : 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . openBaseCustomDialog 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 result 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 contentView AST#expression#Right , AST#expression#Left options AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#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 options AST#expression#Right . dialogId AST#member_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
openCustomDialog<T extends IBaseDialogOptions>(contentView: WrappedBuilder<[T]>, options: T): string { if (!options.dialogId) { options.dialogId = this.generateDialogId(); } if (options.uiContext) { this.openBaseCustomDialog(options.uiContext, contentView, options); } else { window.getLastWindow(getContext()).then((result: window.Window) => { this.openBaseCustomDialog(result.getUIContext(), contentView, options); }) } return options.dialogId; }
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/core/DialogCoreHandler.ets#L37-L52
66629518d8697cda872aca7cacf5b9f14948d2a3
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/utils/LoadingUtility.ets
arkts
hideLoading
=============================== 隐藏加载提示 ===============================
static hideLoading() { if (LoadingUtility.loadingDialog) { LoadingUtility.loadingDialog.close() LoadingUtility.loadingDialog = null } }
AST#method_declaration#Left static hideLoading 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 LoadingUtility AST#expression#Right . loadingDialog AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LoadingUtility AST#expression#Right . loadingDialog 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 LoadingUtility AST#expression#Right . loadingDialog 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#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
static hideLoading() { if (LoadingUtility.loadingDialog) { LoadingUtility.loadingDialog.close() LoadingUtility.loadingDialog = null } }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/utils/LoadingUtility.ets#L30-L35
1e06517edd5a7d58ec0b4d36b418aa07d39ae256
github
huaweicloud/huaweicloud-iot-device-sdk-arkts.git
72954bea19e7e7f93567487b036c0664457bdaf3
huaweicloud_iot_device_library/src/main/ets/service/IService.ets
arkts
服务接口类
export interface IService { /** * 读属性回调 * * @param fields 指定读取的字段名,不指定则读取全部可读字段 * @return 属性值,json格式 */ onRead(fields?: string[]): object; /** * 写属性回调 * * @param properties 属性期望值 * @return 操作结果jsonObject */ onWrite(properties: object): IotResult; /** * 命令回调 * * @param command 命令 * @return 执行结果 */ onCommand(command: Command): CommandRsp; /** * 事件回调 * * @param deviceEvent 事件 */ onEvent(deviceEvent: DeviceEvent): void; }
AST#export_declaration#Left export AST#interface_declaration#Left interface IService AST#object_type#Left { /** * 读属性回调 * * @param fields 指定读取的字段名,不指定则读取全部可读字段 * @return 属性值,json格式 */ AST#type_member#Left onRead AST#parameter_list#Left ( AST#parameter#Left fields ? : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left object AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * 写属性回调 * * @param properties 属性期望值 * @return 操作结果jsonObject */ AST#type_member#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#type_member#Right ; /** * 命令回调 * * @param command 命令 * @return 执行结果 */ AST#type_member#Left onCommand AST#parameter_list#Left ( AST#parameter#Left command : AST#type_annotation#Left AST#primary_type#Left Command AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left CommandRsp AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * 事件回调 * * @param deviceEvent 事件 */ AST#type_member#Left onEvent AST#parameter_list#Left ( AST#parameter#Left deviceEvent : AST#type_annotation#Left AST#primary_type#Left DeviceEvent 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#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface IService { onRead(fields?: string[]): object; onWrite(properties: object): IotResult; onCommand(command: Command): CommandRsp; onEvent(deviceEvent: DeviceEvent): void; }
https://github.com/huaweicloud/huaweicloud-iot-device-sdk-arkts.git/blob/72954bea19e7e7f93567487b036c0664457bdaf3/huaweicloud_iot_device_library/src/main/ets/service/IService.ets#L23-L54
793bd1f753eea20f9f810ba2752220d87fec77a0
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/vibrateeffect/src/main/ets/VibrateEffect.ets
arkts
aboutToAppear
UIContext实例对象
aboutToAppear() { this.uiContext = this.getUIContext?.(); }
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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . uiContext AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getUIContext 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#builder_function_body#Right AST#method_declaration#Right
aboutToAppear() { this.uiContext = this.getUIContext?.(); }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/vibrateeffect/src/main/ets/VibrateEffect.ets#L43-L45
f7a7cd77b0d993af90ee4c3297a21d6cfe072b23
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/SystemFeature/Security/DLP/entry/src/main/ets/feature/DlpManager.ets
arkts
genTestOptionalDlpProperty
生成可选参数的DLP策略
async genTestOptionalDlpProperty(): Promise<dlpPermission.DLPProperty> { let accountInfo = await this.getOsAccountInfo(); let property: dlpPermission.DLPProperty = { 'ownerAccount': accountInfo.distributedInfo.name, 'ownerAccountID': accountInfo.distributedInfo.id, 'ownerAccountType': dlpPermission.AccountType.CLOUD_ACCOUNT, 'contactAccount': accountInfo.distributedInfo.name, 'offlineAccess': true, }; return property; }
AST#method_declaration#Left async genTestOptionalDlpProperty AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left dlpPermission . DLPProperty AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left accountInfo = 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 . getOsAccountInfo 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 property : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left dlpPermission . DLPProperty 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 'ownerAccount' AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left accountInfo AST#expression#Right . distributedInfo AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'ownerAccountID' AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left accountInfo AST#expression#Right . distributedInfo AST#member_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'ownerAccountType' AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dlpPermission AST#expression#Right . AccountType AST#member_expression#Right AST#expression#Right . CLOUD_ACCOUNT AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'contactAccount' AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left accountInfo AST#expression#Right . distributedInfo AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'offlineAccess' 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left property AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async genTestOptionalDlpProperty(): Promise<dlpPermission.DLPProperty> { let accountInfo = await this.getOsAccountInfo(); let property: dlpPermission.DLPProperty = { 'ownerAccount': accountInfo.distributedInfo.name, 'ownerAccountID': accountInfo.distributedInfo.id, 'ownerAccountType': dlpPermission.AccountType.CLOUD_ACCOUNT, 'contactAccount': accountInfo.distributedInfo.name, 'offlineAccess': true, }; return property; }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/Security/DLP/entry/src/main/ets/feature/DlpManager.ets#L155-L165
0e50d5fa48b7c069dd5834784283629c897adf35
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
ArkUI/StateManagement/entry/src/main/ets/segment/segment7.ets
arkts
ArticleCardView
[EndExclude Case4] Article card component of the Explore module
@Component export struct ArticleCardView { // 3.Get the user information object userData on the ExploreArticleList card with the @StorageLink decorator @StorageLink('userData') userData: UserData | null = null; @Prop articleItem: LearningResource = new LearningResource(); // 4.Calculate whether the current article is favorite or not according to the favorite information array isCollected(): boolean { return !!this.userData && this.userData.collectedIds.some((id: string) => id === this.articleItem.id); } // 7.Handling interface like interaction logic: when the userData state sub-property collectedIds received using the @StorageLink decorator is modified, the new value is synchronized to AppStorage handleCollected(): void { // [StartExclude Case4] const resourceId = this.articleItem.id; // [EndExclude Case4] const index = this.userData?.collectedIds.findIndex((id: string) => id === this.articleItem.id) as number; if (index === -1) { this.userData?.collectedIds.push(resourceId); } else { this.userData?.collectedIds.splice(index, 1); } // ... } build() { ActionButtonView({ // 5.Determine whether the favorite icon is highlighted according to whether the current article has been favorited by the user or not imgResource: this.isCollected() ? $r('app.media.icon') : $r('app.media.icon'), count: this.articleItem.collectionCount, textWidth: 77 }) .onClick(() => { // 6.When the user clicks on the favorites icon, the function that handles changes to the status of the favorites is called this.handleCollected(); }) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ArticleCardView AST#component_body#Left { // 3.Get the user information object userData on the ExploreArticleList card with the @StorageLink decorator AST#property_declaration#Left AST#decorator#Left @ StorageLink ( AST#expression#Left 'userData' AST#expression#Right ) AST#decorator#Right userData : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left UserData 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 AST#decorator#Left @ Prop AST#decorator#Right articleItem : AST#type_annotation#Left AST#primary_type#Left LearningResource 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 LearningResource 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 // 4.Calculate whether the current article is favorite or not according to the favorite information array AST#method_declaration#Left isCollected AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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#unary_expression#Left ! AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#unary_expression#Right AST#expression#Right . userData AST#member_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . userData AST#member_expression#Right AST#expression#Right . collectedIds AST#member_expression#Right AST#expression#Right . some AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left id : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left id AST#expression#Right === AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . articleItem AST#member_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // 7.Handling interface like interaction logic: when the userData state sub-property collectedIds received using the @StorageLink decorator is modified, the new value is synchronized to AppStorage AST#method_declaration#Left handleCollected 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 { // [StartExclude Case4] AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left resourceId = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . articleItem AST#member_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // [EndExclude Case4] AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left index = 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . userData AST#member_expression#Right AST#expression#Right ?. collectedIds 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 AST#parameter_list#Left ( AST#parameter#Left id : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left id AST#expression#Right === AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . articleItem AST#member_expression#Right AST#expression#Right . id 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 as AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 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#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 . userData AST#member_expression#Right AST#expression#Right ?. collectedIds AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left resourceId AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . userData AST#member_expression#Right AST#expression#Right ?. collectedIds AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // ... } AST#block_statement#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 ActionButtonView ( AST#component_parameters#Left { // 5.Determine whether the favorite icon is highlighted according to whether the current article has been favorited by the user or not AST#component_parameter#Left imgResource : AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isCollected 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#resource_expression#Left $r ( AST#expression#Left 'app.media.icon' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.icon' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left count : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . articleItem AST#member_expression#Right AST#expression#Right . collectionCount AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left textWidth : AST#expression#Left 77 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { // 6.When the user clicks on the favorites icon, the function that handles changes to the status of the favorites is called 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 . handleCollected 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#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 ArticleCardView { @StorageLink('userData') userData: UserData | null = null; @Prop articleItem: LearningResource = new LearningResource(); isCollected(): boolean { return !!this.userData && this.userData.collectedIds.some((id: string) => id === this.articleItem.id); } handleCollected(): void { const resourceId = this.articleItem.id; const index = this.userData?.collectedIds.findIndex((id: string) => id === this.articleItem.id) as number; if (index === -1) { this.userData?.collectedIds.push(resourceId); } else { this.userData?.collectedIds.splice(index, 1); } } build() { ActionButtonView({ imgResource: this.isCollected() ? $r('app.media.icon') : $r('app.media.icon'), count: this.articleItem.collectionCount, textWidth: 77 }) .onClick(() => { this.handleCollected(); }) } }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ArkUI/StateManagement/entry/src/main/ets/segment/segment7.ets#L76-L113
ba79ecd8b861390acd7da44e7e6fa62c9f9bcfb7
gitee
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_rcp/src/main/ets/rcp/EfBusinessCodeInterceptor.ets
arkts
intercept
拦截器 @param context @param next @returns
async intercept(context: rcp.RequestContext, next: rcp.RequestHandler): Promise<rcp.Response> { try { //响应对象 const response = await next.handle(context); //无监听则抛出异常 if (this.businessCodeEventListener) { //设置监听 //1.将响应数据转换成json if (response) { let code = this.businessCodeEventListener.businessCodeName; //如果有业务异常编码code if (code) { //转换为json字符串 let resultStr = response.toString(); if (resultStr) { //提取code对应的json let jsonFragment = this.extractJsonFragment(resultStr, code); if (jsonFragment) { //提取code对应的值 let codeValue = this.getValueFromJsonFragment(jsonFragment, code); //传递给回调事件 this.businessCodeEventListener.listener(codeValue); } } } else { let efRcpError = new EfRcpError(10010, '业务级别响应码监听异常', '未设置业务编码监听对应的code属性efRcpConfig.businessCodeEvent.businessCodeName~'); return Promise.reject(efRcpError); } } } else { let efRcpError = new EfRcpError(10010, '业务级别响应码监听异常', '启用业务级别响应码监听请设置efRcpConfig.businessCodeEvent属性~'); return Promise.reject(efRcpError); } return response; } catch (error) { let b = error as BusinessError; //抛出 return Promise.reject(b); } }
AST#method_declaration#Left async intercept AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left rcp . RequestContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left next : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left rcp . RequestHandler AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left rcp . Response AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { //响应对象 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left response = 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 next AST#expression#Right AST#await_expression#Right AST#expression#Right . handle AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //无监听则抛出异常 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . businessCodeEventListener AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { //设置监听 //1.将响应数据转换成json AST#statement#Left AST#if_statement#Left if ( AST#expression#Left response AST#expression#Right ) 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#member_expression#Left AST#expression#Left this AST#expression#Right . businessCodeEventListener AST#member_expression#Right AST#expression#Right . businessCodeName AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //如果有业务异常编码code AST#statement#Left AST#if_statement#Left if ( AST#expression#Left code AST#expression#Right ) AST#block_statement#Left { //转换为json字符串 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left resultStr = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left resultStr AST#expression#Right ) AST#block_statement#Left { //提取code对应的json AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left jsonFragment = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . extractJsonFragment AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left resultStr AST#expression#Right , AST#expression#Left code 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 jsonFragment AST#expression#Right ) AST#block_statement#Left { //提取code对应的值 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left codeValue = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getValueFromJsonFragment AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left jsonFragment AST#expression#Right , AST#expression#Left code AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //传递给回调事件 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . businessCodeEventListener AST#member_expression#Right AST#expression#Right . listener AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left codeValue 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 else AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left efRcpError = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left EfRcpError AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 10010 AST#expression#Right , AST#expression#Left '业务级别响应码监听异常' AST#expression#Right , AST#expression#Left '未设置业务编码监听对应的code属性efRcpConfig.businessCodeEvent.businessCodeName~' 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 Promise AST#expression#Right . reject AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left efRcpError 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#if_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left efRcpError = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left EfRcpError AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 10010 AST#expression#Right , AST#expression#Left '业务级别响应码监听异常' AST#expression#Right , AST#expression#Left '启用业务级别响应码监听请设置efRcpConfig.businessCodeEvent属性~' 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 Promise AST#expression#Right . reject AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left efRcpError 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 response AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left b = AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //抛出 AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Promise AST#expression#Right . reject AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left b AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async intercept(context: rcp.RequestContext, next: rcp.RequestHandler): Promise<rcp.Response> { try { const response = await next.handle(context); if (this.businessCodeEventListener) { if (response) { let code = this.businessCodeEventListener.businessCodeName; if (code) { let resultStr = response.toString(); if (resultStr) { let jsonFragment = this.extractJsonFragment(resultStr, code); if (jsonFragment) { let codeValue = this.getValueFromJsonFragment(jsonFragment, code); this.businessCodeEventListener.listener(codeValue); } } } else { let efRcpError = new EfRcpError(10010, '业务级别响应码监听异常', '未设置业务编码监听对应的code属性efRcpConfig.businessCodeEvent.businessCodeName~'); return Promise.reject(efRcpError); } } } else { let efRcpError = new EfRcpError(10010, '业务级别响应码监听异常', '启用业务级别响应码监听请设置efRcpConfig.businessCodeEvent属性~'); return Promise.reject(efRcpError); } return response; } catch (error) { let b = error as BusinessError; return Promise.reject(b); } }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_rcp/src/main/ets/rcp/EfBusinessCodeInterceptor.ets#L43-L84
de375a1c3a1446099007bdf04dabaf8d9a25c7ae
gitee
tomorrowKreswell/Ledger.git
1f2783ae70b8540d677af8a27f29db1b4089ea69
ledger/entry/src/main/ets/view/AddDialogComponent.ets
arkts
声明一个 CustomDialog,用于创建自定义对话框组件
@CustomDialog export default struct AddDialogComponent { controller?: CustomDialogController; // 对话框控制器 @Link isInsert: boolean; // 是否插入新记录的标志 @Link newAccount: Account; // 新账户的数据 confirm?: (isInsert: boolean, newAccount: Account) => void; // 确认操作的回调函数 private scroller: Scroller = new Scroller(); // 滚动器实例 private inputAmount = ''; // 输入的金额字符串 private inputDesc = ''; // 输入的描述字符串 @State payList: Array<AccountClassification> = PayList; // 支出列表 @State earnList: Array<AccountClassification> = EarnList; // 收入列表 @State bgColor: string = ''; // 背景颜色 @State curIndex: number = 0; // 当前选中的支付或收入索引 @State curType: string = ''; // 当前选中的支付或收入类型 private selectedDate: Date = this.newAccount.date // 选中的日期,默认为新账户的日期 // 由于@State修饰Date类型时会出现错误,所以这里声明两个辅助变量 @State dateString: string = formatDateTime(this.selectedDate, 'yyyy.MM.dd') // 日期字符串 @State timeString: string = formatDateTime(this.selectedDate, 'HH:mm') // 时间字符串 // 构建 Tab 标签页 @Builder TabBuilder(index: number) { Column() { Text(index === 0 ? $r('app.string.pay_text') : $r('app.string.income_text')) .fontSize($r('app.float.font_size_M')) .fontColor(this.curIndex === index ? $r('app.color.main_color') : Color.Gray) } .width($r('app.float.component_size_MP')) .padding({ top: $r('app.float.edge_size_LM'), bottom: $r('app.float.edge_size_S') }) .margin({ bottom: $r('app.float.edge_size_S') }) .border(this.curIndex === index ? { width: { bottom: $r('app.float.border_size_M') }, color: $r('app.color.main_color') } : { color: Color.White }) } // 当即将出现时触发的生命周期函数 aboutToAppear() { this.inputAmount = this.newAccount.amount.toString(); // 初始化输入金额 this.curIndex = this.newAccount.accountType; // 初始化当前支付或收入索引 this.curType = this.newAccount.typeText; // 初始化当前支付或收入类型 } // 选择支付或收入类型 selectAccount(item: AccountClassification) { this.newAccount.accountType = item.accountType; this.newAccount.typeText = item.typeText; this.curType = item.typeText; } // 构建对话框内容 build() { Column({ space: CommonConstants.SPACE_M }) { // 关闭按钮 Image($rawfile('half.png')) .width($r('app.float.component_size_L')) .height($r('app.float.component_size_S')) .onClick(() => { this.controller?.close(); }) // 顶部标签页切换 Tabs({ barPosition: BarPosition.Start, index: this.curIndex }) { // 支出标签页 TabContent() { // 支出类型列表 Grid(this.scroller) { ForEach(this.payList, (item: AccountClassification) => { GridItem() { Column() { Image(this.curType === item.typeText ? item.iconSelected : item.icon) .width($r('app.float.image_size')) .aspectRatio(CommonConstants.FULL_SIZE) Text(item.typeText) .fontSize($r('app.float.font_size_S')) .fontColor(this.curType === item.typeText ? Color.White : $r('app.color.main_color')) .margin({ top: $r('app.float.edge_size_S') }) } .width($r('app.float.component_size_LP')) .aspectRatio(CommonConstants.FULL_SIZE) .padding({ top: $r('app.float.edge_size_M') }) .margin({ top: $r('app.float.edge_size_MP'), left: $r('app.float.edge_size_M') }) .align(Alignment.TopStart) .backgroundColor(this.curType === item.typeText ? $r('app.color.main_color') : $r('app.color.background_color')) .borderRadius($r('app.float.radius_size_S')) .onClick(() => { this.selectAccount(item); }) } }) } .columnsTemplate('1fr 1fr 1fr 1fr') .scrollBar(BarState.Off) } .tabBar(this.TabBuilder(0)) .margin({ bottom: $r('app.float.edge_size_LP') })
AST#decorated_export_declaration#Left AST#decorator#Left @ CustomDialog AST#decorator#Right export default AST#ERROR#Left struct AddDialogComponent { 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 @ Link AST#decorator#Right isInsert : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 是否插入新记录的标志 AST#property_declaration#Left AST#decorator#Left @ Link AST#decorator#Right newAccount : AST#type_annotation#Left AST#primary_type#Left Account AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 新账户的数据 AST#property_declaration#Left confirm ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left isInsert : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left newAccount : AST#type_annotation#Left AST#primary_type#Left Account 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#property_declaration#Right // 确认操作的回调函数 AST#property_declaration#Left private scroller : AST#type_annotation#Left AST#primary_type#Left Scroller AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Scroller AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right // 滚动器实例 AST#property_declaration#Left private inputAmount = AST#expression#Left '' AST#expression#Right ; AST#property_declaration#Right // 输入的金额字符串 AST#property_declaration#Left private inputDesc = AST#expression#Left '' AST#expression#Right ; AST#property_declaration#Right // 输入的描述字符串 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right payList : 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 AccountClassification 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 PayList AST#expression#Right ; AST#property_declaration#Right // 支出列表 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right earnList : 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 AccountClassification 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 EarnList AST#expression#Right ; AST#property_declaration#Right // 收入列表 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right bgColor : 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 curIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right // 当前选中的支付或收入索引 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right curType : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right ; AST#property_declaration#Right // 当前选中的支付或收入类型 AST#property_declaration#Left private selectedDate : AST#type_annotation#Left AST#primary_type#Left Date 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 . newAccount AST#member_expression#Right AST#expression#Right . date AST#member_expression#Right AST#expression#Right // 选中的日期,默认为新账户的日期 // 由于@State修饰Date类型时会出现错误,所以这里声明两个辅助变量 AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right dateString : 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 formatDateTime AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedDate AST#member_expression#Right AST#expression#Right , AST#expression#Left 'yyyy.MM.dd' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right // 日期字符串 AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right timeString : 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 formatDateTime AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedDate AST#member_expression#Right AST#expression#Right , AST#expression#Left 'HH:mm' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right // 时间字符串 // 构建 Tab 标签页 AST#property_declaration#Right AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right TabBuilder AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left 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#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.pay_text' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.income_text' 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 . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.font_size_M' 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 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 . curIndex AST#member_expression#Right AST#expression#Right === AST#expression#Left index AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.main_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left Color AST#expression#Right AST#conditional_expression#Right AST#expression#Right . Gray AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.component_size_MP' 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 top AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.edge_size_LM' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.edge_size_S' 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 . 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.edge_size_S' 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 . border ( 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 . curIndex AST#member_expression#Right AST#expression#Right === AST#expression#Left index AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.border_size_M' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.main_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#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 // 当即将出现时触发的生命周期函数 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputAmount AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . newAccount AST#member_expression#Right AST#expression#Right . amount 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#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 . curIndex AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . newAccount AST#member_expression#Right AST#expression#Right . accountType AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right // 初始化当前支付或收入索引 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . curType AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . newAccount AST#member_expression#Right AST#expression#Right . typeText AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right // 初始化当前支付或收入类型 } AST#builder_function_body#Right AST#method_declaration#Right // 选择支付或收入类型 AST#method_declaration#Left selectAccount AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left AccountClassification AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . newAccount AST#member_expression#Right AST#expression#Right . accountType AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . accountType AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . newAccount AST#member_expression#Right AST#expression#Right . typeText AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . typeText AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . curType AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . typeText AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right // 构建对话框内容 AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . SPACE_M AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { // 关闭按钮 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#call_expression#Left AST#expression#Left $rawfile AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'half.png' 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#resource_expression#Left $r ( AST#expression#Left 'app.float.component_size_L' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.component_size_S' 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 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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 顶部标签页切换 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Tabs ( AST#component_parameters#Left { AST#component_parameter#Left barPosition : AST#expression#Left AST#member_expression#Left AST#expression#Left BarPosition AST#expression#Right . Start AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left index : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . curIndex AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#ERROR#Left { // 支出标签页 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left TabContent ( ) AST#ui_component#Right AST#ERROR#Left { // 支出类型列表 Grid ( this AST#ERROR#Right AST#modifier_chain_expression#Left . scroller AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ) AST#ERROR#Right { AST#property_name#Left ForEach AST#property_name#Right ( this AST#ERROR#Right AST#modifier_chain_expression#Left . payList AST#ERROR#Left , AST#ERROR#Right ( AST#expression#Left AST#arrow_function#Left item : AST#type_annotation#Left AST#primary_type#Left AccountClassification AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ) AST#ERROR#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left GridItem 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#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 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left Column AST#property_name#Right 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left Image AST#expression#Right AST#argument_list#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 . curType AST#member_expression#Right AST#expression#Right === AST#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . typeText AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . iconSelected AST#member_expression#Right AST#expression#Right : AST#expression#Left item AST#expression#Right AST#conditional_expression#Right AST#expression#Right . icon AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.image_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . aspectRatio 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 . FULL_SIZE 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#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 Text AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . typeText AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontSize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.font_size_S' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontColor AST#member_expression#Right 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 this AST#expression#Right . curType AST#member_expression#Right AST#expression#Right === AST#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . typeText AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.main_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . margin 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 top AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.edge_size_S' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#property_assignment#Right AST#object_literal#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.component_size_LP' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . aspectRatio 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 . FULL_SIZE AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . padding 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 top AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.edge_size_M' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . margin 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 top AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.edge_size_MP' AST#expression#Right ) AST#resource_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.float.edge_size_M' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . align AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . TopStart AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . backgroundColor AST#member_expression#Right 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 this AST#expression#Right . curType AST#member_expression#Right AST#expression#Right === AST#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . typeText AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.main_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.background_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . borderRadius AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.radius_size_S' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . onClick AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectAccount AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left item AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#ERROR#Left } AST#ERROR#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 . columnsTemplate ( AST#expression#Left '1fr 1fr 1fr 1fr' AST#expression#Right ) AST#modifier_chain_expression#Left . scrollBar ( AST#expression#Left AST#member_expression#Left AST#expression#Left BarState AST#expression#Right . Off AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#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 . tabBar AST#ERROR#Right AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . TabBuilder 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#parenthesized_expression#Right AST#expression#Right . margin 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 bottom AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.edge_size_LP' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#decorated_export_declaration#Right
@CustomDialog export default struct AddDialogComponent { controller?: CustomDialogController; @Link isInsert: boolean; @Link newAccount: Account; confirm?: (isInsert: boolean, newAccount: Account) => void; private scroller: Scroller = new Scroller(); private inputAmount = ''; private inputDesc = ''; @State payList: Array<AccountClassification> = PayList; @State earnList: Array<AccountClassification> = EarnList; @State bgColor: string = ''; @State curIndex: number = 0; @State curType: string = ''; private selectedDate: Date = this.newAccount.date @State dateString: string = formatDateTime(this.selectedDate, 'yyyy.MM.dd') @State timeString: string = formatDateTime(this.selectedDate, 'HH:mm') @Builder TabBuilder(index: number) { Column() { Text(index === 0 ? $r('app.string.pay_text') : $r('app.string.income_text')) .fontSize($r('app.float.font_size_M')) .fontColor(this.curIndex === index ? $r('app.color.main_color') : Color.Gray) } .width($r('app.float.component_size_MP')) .padding({ top: $r('app.float.edge_size_LM'), bottom: $r('app.float.edge_size_S') }) .margin({ bottom: $r('app.float.edge_size_S') }) .border(this.curIndex === index ? { width: { bottom: $r('app.float.border_size_M') }, color: $r('app.color.main_color') } : { color: Color.White }) } aboutToAppear() { this.inputAmount = this.newAccount.amount.toString(); this.curIndex = this.newAccount.accountType; this.curType = this.newAccount.typeText; } selectAccount(item: AccountClassification) { this.newAccount.accountType = item.accountType; this.newAccount.typeText = item.typeText; this.curType = item.typeText; } build() { Column({ space: CommonConstants.SPACE_M }) { Image($rawfile('half.png')) .width($r('app.float.component_size_L')) .height($r('app.float.component_size_S')) .onClick(() => { this.controller?.close(); }) Tabs({ barPosition: BarPosition.Start, index: this.curIndex }) { TabContent() { Grid(this.scroller) { ForEach(this.payList, (item: AccountClassification) => { GridItem() { Column() { Image(this.curType === item.typeText ? item.iconSelected : item.icon) .width($r('app.float.image_size')) .aspectRatio(CommonConstants.FULL_SIZE) Text(item.typeText) .fontSize($r('app.float.font_size_S')) .fontColor(this.curType === item.typeText ? Color.White : $r('app.color.main_color')) .margin({ top: $r('app.float.edge_size_S') }) } .width($r('app.float.component_size_LP')) .aspectRatio(CommonConstants.FULL_SIZE) .padding({ top: $r('app.float.edge_size_M') }) .margin({ top: $r('app.float.edge_size_MP'), left: $r('app.float.edge_size_M') }) .align(Alignment.TopStart) .backgroundColor(this.curType === item.typeText ? $r('app.color.main_color') : $r('app.color.background_color')) .borderRadius($r('app.float.radius_size_S')) .onClick(() => { this.selectAccount(item); }) } }) } .columnsTemplate('1fr 1fr 1fr 1fr') .scrollBar(BarState.Off) } .tabBar(this.TabBuilder(0)) .margin({ bottom: $r('app.float.edge_size_LP') })
https://github.com/tomorrowKreswell/Ledger.git/blob/1f2783ae70b8540d677af8a27f29db1b4089ea69/ledger/entry/src/main/ets/view/AddDialogComponent.ets#L10-L106
b665c65dda8e0291a8e6f5da84c3b1ee29b5d9a5
github
zqaini002/YaoYaoLingXian.git
5095b12cbeea524a87c42d0824b1702978843d39
YaoYaoLingXian/entry/src/main/ets/pages/community/PostCreatePage.ets
arkts
submitPost
提交帖子
async submitPost(): Promise<void> { try { // 检查用户是否已登录 if (!this.userSession.isLoggedIn()) { const toastOpts: ToastOptions = { message: '请先登录后再发布', duration: 2000 }; promptAction.showToast(toastOpts); // 跳转到登录页面 router.pushUrl({ url: 'pages/user/LoginPage', params: { redirectUrl: 'pages/community/PostCreatePage' } }); return; } // 表单验证 if (!this.post.content.trim()) { const toastOpts: ToastOptions = { message: '内容不能为空', duration: 2000 }; promptAction.showToast(toastOpts); return; } // 检查是否关联了梦想 if (!this.post.dreamId) { const toastOpts: ToastOptions = { message: '请关联一个梦想后再发布', duration: 2000 }; promptAction.showToast(toastOpts); // 可选:自动弹出梦想选择器 this.showDreamSelector = true; return; } this.isSubmitting = true; console.info('开始提交帖子,标题:', this.post.title || '无标题'); // 确保设置了用户ID this.post.userId = this.userSession.getUserId() || 0; // 如果有选择图片,需要先上传图片 let uploadedImages: string[] = []; if (this.selectedImages.length > 0) { console.info(`开始上传图片,数量: ${this.selectedImages.length}`); // 遍历上传图片 for (const imageUri of this.selectedImages) { try { console.info(`处理图片: ${imageUri}`); let base64Data = await this.convertImageToBase64(imageUri); if (base64Data) { // 构造上传参数 const uploadParams: ApiService.UploadImageParams = { fileName: imageUri.substring(imageUri.lastIndexOf('/') + 1), base64Image: base64Data }; console.info('上传图片参数准备完成,开始上传...'); const response = await ApiService.uploadImage(uploadParams); if (response && response.url) { console.info(`图片上传成功,URL: ${response.url}`); uploadedImages.push(response.url); } else { console.error('图片上传返回结果异常:', response); } } } catch (error) { const err: Error = error instanceof Error ? error : new Error(String(error)); console.error(`上传图片失败: ${err.message}`); const toastOpts: ToastOptions = { message: `图片上传失败: ${err.message}`, duration: 2000 }; promptAction.showToast(toastOpts); } } } console.info(`图片上传完成,成功上传${uploadedImages.length}张图片`); // 创建新的Post对象 const postData: Post = { id: this.post.id, userId: this.post.userId, title: this.post.title, content: this.post.content, likeCount: this.post.likeCount, commentCount: this.post.commentCount, createdAt: this.post.createdAt, updatedAt: this.post.updatedAt, dreamId: this.post.dreamId, // 直接设置为空字符串,让ApiService处理转换 images: '' }; // 记录上传的图片URLs供日志查看 console.info('上传的图片URLs:', JSON.stringify(uploadedImages)); // 处理images字段 - 如果有上传图片,将数组转换为逗号分隔字符串 if (uploadedImages.length > 0) { postData.images = uploadedImages.join(','); } console.info('准备提交帖子数据:', JSON.stringify(postData)); // 调用API创建帖子 const createdPost = await ApiService.createPost(postData); console.info('帖子创建成功:', createdPost); const toastOpts: ToastOptions = { message: '发布成功', duration: 2000 }; promptAction.showToast(toastOpts); // 返回社区页面 router.back(); } catch (error) { const err: Error = error instanceof Error ? error : new Error(String(error)); console.error(`发布失败: ${err.message}`); const toastOpts: ToastOptions = { message: `发布失败: ${err.message}`, duration: 2000 }; promptAction.showToast(toastOpts); } finally { this.isSubmitting = false; } }
AST#method_declaration#Left async submitPost AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 检查用户是否已登录 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . userSession AST#member_expression#Right AST#expression#Right . isLoggedIn AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left toastOpts : AST#type_annotation#Left AST#primary_type#Left ToastOptions AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left '请先登录后再发布' AST#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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left toastOpts AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 跳转到登录页面 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left router AST#expression#Right . pushUrl AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left 'pages/user/LoginPage' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left params AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left redirectUrl AST#property_name#Right : AST#expression#Left 'pages/community/PostCreatePage' 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#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 表单验证 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#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 . post AST#member_expression#Right AST#expression#Right . content AST#member_expression#Right AST#expression#Right . trim AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left toastOpts : AST#type_annotation#Left AST#primary_type#Left ToastOptions AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left '内容不能为空' AST#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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left toastOpts AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 检查是否关联了梦想 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . post AST#member_expression#Right AST#expression#Right . dreamId AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left toastOpts : AST#type_annotation#Left AST#primary_type#Left ToastOptions AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left '请关联一个梦想后再发布' AST#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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left toastOpts AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 可选:自动弹出梦想选择器 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showDreamSelector 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#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isSubmitting AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '开始提交帖子,标题:' AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . post AST#member_expression#Right AST#expression#Right . title AST#member_expression#Right AST#expression#Right || AST#expression#Left '无标题' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 确保设置了用户ID 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 . post AST#member_expression#Right AST#expression#Right . userId AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . userSession AST#member_expression#Right AST#expression#Right . getUserId AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 如果有选择图片,需要先上传图片 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left uploadedImages : 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedImages AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 开始上传图片,数量: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedImages AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 遍历上传图片 AST#statement#Left AST#for_statement#Left for ( const imageUri of AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedImages AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 处理图片: AST#template_substitution#Left $ { AST#expression#Left imageUri AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left base64Data = 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 . convertImageToBase64 AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left imageUri 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 base64Data AST#expression#Right ) AST#block_statement#Left { // 构造上传参数 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left uploadParams : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left ApiService . UploadImageParams 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 fileName AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left imageUri AST#expression#Right . substring 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 imageUri AST#expression#Right . lastIndexOf 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 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left base64Image AST#property_name#Right : AST#expression#Left base64Data 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 console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '上传图片参数准备完成,开始上传...' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left response = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left ApiService AST#expression#Right AST#await_expression#Right AST#expression#Right . uploadImage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uploadParams AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left response AST#expression#Right && AST#expression#Left response AST#expression#Right AST#binary_expression#Right AST#expression#Right . url AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 图片上传成功,URL: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . url AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left uploadedImages AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . url AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 response 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#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left err : AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right = 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#variable_declarator#Right AST#ERROR#Left ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right AST#ERROR#Left : AST#ERROR#Left new Error AST#ERROR#Right AST#type_annotation#Left AST#primary_type#Left AST#parenthesized_type#Left ( AST#ERROR#Left String AST#ERROR#Right AST#type_annotation#Left AST#primary_type#Left AST#parenthesized_type#Left ( AST#type_annotation#Left AST#primary_type#Left error AST#primary_type#Right AST#type_annotation#Right ) AST#parenthesized_type#Right AST#primary_type#Right AST#type_annotation#Right ) AST#parenthesized_type#Right AST#primary_type#Right AST#type_annotation#Right ; console AST#ERROR#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 上传图片失败: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left 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#ERROR#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left toastOpts : AST#type_annotation#Left AST#primary_type#Left ToastOptions AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` 图片上传失败: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left toastOpts AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 图片上传完成,成功上传 AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left uploadedImages AST#expression#Right . length AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right 张图片 ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 创建新的Post对象 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left postData : AST#type_annotation#Left AST#primary_type#Left Post 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#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . post AST#member_expression#Right AST#expression#Right . id AST#member_expression#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 . post 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 title 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 . post AST#member_expression#Right AST#expression#Right . title AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left content AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . post AST#member_expression#Right AST#expression#Right . content AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left likeCount 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 . post AST#member_expression#Right AST#expression#Right . likeCount AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left commentCount 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 . post AST#member_expression#Right AST#expression#Right . commentCount AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left createdAt 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 . post AST#member_expression#Right AST#expression#Right . createdAt AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left updatedAt 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 . post AST#member_expression#Right AST#expression#Right . updatedAt AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left dreamId 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 . post AST#member_expression#Right AST#expression#Right . dreamId AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 直接设置为空字符串,让ApiService处理转换 AST#property_assignment#Left AST#property_name#Left images AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 记录上传的图片URLs供日志查看 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 '上传的图片URLs:' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uploadedImages 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 // 处理images字段 - 如果有上传图片,将数组转换为逗号分隔字符串 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 uploadedImages 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 postData AST#expression#Right . images AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left uploadedImages AST#expression#Right . join AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left ',' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '准备提交帖子数据:' AST#expression#Right , AST#expression#Left 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 postData 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 // 调用API创建帖子 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left createdPost = 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 . createPost AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left postData AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '帖子创建成功:' AST#expression#Right , AST#expression#Left createdPost 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 toastOpts : AST#type_annotation#Left AST#primary_type#Left ToastOptions AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left '发布成功' AST#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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left toastOpts AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 返回社区页面 AST#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#variable_declaration#Left const AST#variable_declarator#Left err : AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right = 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#variable_declarator#Right AST#ERROR#Left ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right AST#ERROR#Left : AST#ERROR#Left new Error AST#ERROR#Right AST#type_annotation#Left AST#primary_type#Left AST#parenthesized_type#Left ( AST#ERROR#Left String AST#ERROR#Right AST#type_annotation#Left AST#primary_type#Left AST#parenthesized_type#Left ( AST#type_annotation#Left AST#primary_type#Left error AST#primary_type#Right AST#type_annotation#Right ) AST#parenthesized_type#Right AST#primary_type#Right AST#type_annotation#Right ) AST#parenthesized_type#Right AST#primary_type#Right AST#type_annotation#Right ; console AST#ERROR#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 发布失败: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left 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#ERROR#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left toastOpts : AST#type_annotation#Left AST#primary_type#Left ToastOptions AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` 发布失败: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left toastOpts AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#finally_clause#Left finally AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isSubmitting 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 submitPost(): Promise<void> { try { if (!this.userSession.isLoggedIn()) { const toastOpts: ToastOptions = { message: '请先登录后再发布', duration: 2000 }; promptAction.showToast(toastOpts); router.pushUrl({ url: 'pages/user/LoginPage', params: { redirectUrl: 'pages/community/PostCreatePage' } }); return; } if (!this.post.content.trim()) { const toastOpts: ToastOptions = { message: '内容不能为空', duration: 2000 }; promptAction.showToast(toastOpts); return; } if (!this.post.dreamId) { const toastOpts: ToastOptions = { message: '请关联一个梦想后再发布', duration: 2000 }; promptAction.showToast(toastOpts); this.showDreamSelector = true; return; } this.isSubmitting = true; console.info('开始提交帖子,标题:', this.post.title || '无标题'); this.post.userId = this.userSession.getUserId() || 0; let uploadedImages: string[] = []; if (this.selectedImages.length > 0) { console.info(`开始上传图片,数量: ${this.selectedImages.length}`); for (const imageUri of this.selectedImages) { try { console.info(`处理图片: ${imageUri}`); let base64Data = await this.convertImageToBase64(imageUri); if (base64Data) { const uploadParams: ApiService.UploadImageParams = { fileName: imageUri.substring(imageUri.lastIndexOf('/') + 1), base64Image: base64Data }; console.info('上传图片参数准备完成,开始上传...'); const response = await ApiService.uploadImage(uploadParams); if (response && response.url) { console.info(`图片上传成功,URL: ${response.url}`); uploadedImages.push(response.url); } else { console.error('图片上传返回结果异常:', response); } } } catch (error) { const err: Error = error instanceof Error ? error : new Error(String(error)); console.error(`上传图片失败: ${err.message}`); const toastOpts: ToastOptions = { message: `图片上传失败: ${err.message}`, duration: 2000 }; promptAction.showToast(toastOpts); } } } console.info(`图片上传完成,成功上传${uploadedImages.length}张图片`); const postData: Post = { id: this.post.id, userId: this.post.userId, title: this.post.title, content: this.post.content, likeCount: this.post.likeCount, commentCount: this.post.commentCount, createdAt: this.post.createdAt, updatedAt: this.post.updatedAt, dreamId: this.post.dreamId, images: '' }; console.info('上传的图片URLs:', JSON.stringify(uploadedImages)); if (uploadedImages.length > 0) { postData.images = uploadedImages.join(','); } console.info('准备提交帖子数据:', JSON.stringify(postData)); const createdPost = await ApiService.createPost(postData); console.info('帖子创建成功:', createdPost); const toastOpts: ToastOptions = { message: '发布成功', duration: 2000 }; promptAction.showToast(toastOpts); router.back(); } catch (error) { const err: Error = error instanceof Error ? error : new Error(String(error)); console.error(`发布失败: ${err.message}`); const toastOpts: ToastOptions = { message: `发布失败: ${err.message}`, duration: 2000 }; promptAction.showToast(toastOpts); } finally { this.isSubmitting = false; } }
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/pages/community/PostCreatePage.ets#L149-L288
8457be2941c951b6256d5506af2d036afc8438c2
github