nwo
stringclasses 304
values | sha
stringclasses 304
values | path
stringlengths 9
214
| language
stringclasses 1
value | identifier
stringlengths 0
49
| docstring
stringlengths 1
34.2k
| function
stringlengths 8
59.4k
| ast_function
stringlengths 71
497k
| obf_function
stringlengths 8
39.4k
| url
stringlengths 102
324
| function_sha
stringlengths 40
40
| source
stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
harmonyos/samples
|
f5d967efaa7666550ee3252d118c3c73a77686f5
|
HarmonyOS_NEXT/Security/Huks/entry/src/main/ets/model/HuksModel.ets
|
arkts
|
getImportKeyProperties
|
导入SM4密钥属性信息
|
function getImportKeyProperties(properties: HuksProperties[]): void {
let index = 0;
properties[index++] = {
tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
value: huks.HuksKeyAlg.HUKS_ALG_SM4
};
properties[index++] = {
tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128
};
properties[index++] = {
tag: huks.HuksTag.HUKS_TAG_PURPOSE,
value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT |
huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
};
return;
}
|
AST#function_declaration#Left function getImportKeyProperties AST#parameter_list#Left ( AST#parameter#Left properties : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left HuksProperties [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left index = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left properties AST#expression#Right [ AST#expression#Left AST#update_expression#Left AST#expression#Left index AST#expression#Right ++ AST#update_expression#Right 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left tag AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left huks AST#expression#Right . HuksTag AST#member_expression#Right AST#expression#Right . HUKS_TAG_ALGORITHM AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left huks AST#expression#Right . HuksKeyAlg AST#member_expression#Right AST#expression#Right . HUKS_ALG_SM4 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left properties AST#expression#Right [ AST#expression#Left AST#update_expression#Left AST#expression#Left index AST#expression#Right ++ AST#update_expression#Right 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left tag AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left huks AST#expression#Right . HuksTag AST#member_expression#Right AST#expression#Right . HUKS_TAG_KEY_SIZE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left huks AST#expression#Right . HuksKeySize AST#member_expression#Right AST#expression#Right . HUKS_SM4_KEY_SIZE_128 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left properties AST#expression#Right [ AST#expression#Left AST#update_expression#Left AST#expression#Left index AST#expression#Right ++ AST#update_expression#Right 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left tag AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left huks AST#expression#Right . HuksTag AST#member_expression#Right AST#expression#Right . HUKS_TAG_PURPOSE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left huks AST#expression#Right . HuksKeyPurpose AST#member_expression#Right AST#expression#Right . HUKS_KEY_PURPOSE_ENCRYPT AST#member_expression#Right AST#expression#Right | AST#expression#Left huks AST#expression#Right AST#binary_expression#Right AST#expression#Right . HuksKeyPurpose AST#member_expression#Right AST#expression#Right . HUKS_KEY_PURPOSE_DECRYPT AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
|
function getImportKeyProperties(properties: HuksProperties[]): void {
let index = 0;
properties[index++] = {
tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
value: huks.HuksKeyAlg.HUKS_ALG_SM4
};
properties[index++] = {
tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128
};
properties[index++] = {
tag: huks.HuksTag.HUKS_TAG_PURPOSE,
value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT |
huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
};
return;
}
|
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/HarmonyOS_NEXT/Security/Huks/entry/src/main/ets/model/HuksModel.ets#L215-L231
|
4050d1d8eb698b6553fc513e720767d88f2d9ed4
|
gitee
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_dialog/src/main/ets/dialog/DialogBuilder.ets
|
arkts
|
ToastTipBuilder
|
ToastTip
|
@Builder
export function ToastTipBuilder(options: ToastTipOptions) {
ToastTipView({ options: options });
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function ToastTipBuilder AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left ToastTipOptions 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 ToastTipView ( 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 ToastTipBuilder(options: ToastTipOptions) {
ToastTipView({ options: options });
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_dialog/src/main/ets/dialog/DialogBuilder.ets#L214-L217
|
76bfed14de376f356d1d2b882c71046af094b91f
|
gitee
|
wuyuanwuhui999/harmony-arkts-movie-app-ui.git
|
d5e9bebe1dca2759cba417d2b6b402941d3bc273
|
entry/src/main/ets/pages/MoviePlayPage.ets
|
arkts
|
blockStyle
|
电影分组
|
@Styles blockStyle(){
.backgroundColor(colors.blockColor)
.borderRadius(size.blockBorderRaduis)
.padding(size.pagePadding)
.width('100%')
.margin({ top: size.pagePadding })
}
|
AST#method_declaration#Left AST#decorator#Left @ Styles AST#decorator#Right blockStyle AST#parameter_list#Left ( ) AST#parameter_list#Right AST#extend_function_body#Left { AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left colors AST#expression#Right . blockColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#member_expression#Left AST#expression#Left size AST#expression#Right . blockBorderRaduis AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#member_expression#Left AST#expression#Left size AST#expression#Right . pagePadding AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left size AST#expression#Right . pagePadding 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#modifier_chain_expression#Right } AST#extend_function_body#Right AST#method_declaration#Right
|
@Styles blockStyle(){
.backgroundColor(colors.blockColor)
.borderRadius(size.blockBorderRaduis)
.padding(size.pagePadding)
.width('100%')
.margin({ top: size.pagePadding })
}
|
https://github.com/wuyuanwuhui999/harmony-arkts-movie-app-ui.git/blob/d5e9bebe1dca2759cba417d2b6b402941d3bc273/entry/src/main/ets/pages/MoviePlayPage.ets#L26-L32
|
09085350985eb2865813151b17d3e12078af6289
|
github
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/DocsSample/Notification/Notification/entry/src/main/ets/publish/PublishOperation.ets
|
arkts
|
notificationManager
|
发布通知
|
notificationManager.publish(notificationRequest, (err: Base.BusinessError) => {
if (err) {
hilog.error(DOMAIN_NUMBER, TAG,
`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
return;
}
hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in publishing notification.');
}
|
AST#method_declaration#Left notificationManager AST#ERROR#Left . publish ( AST#parameter#Left notificationRequest AST#parameter#Right , AST#ERROR#Right AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left Base . BusinessError AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#ERROR#Left => AST#ERROR#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left err AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN_NUMBER AST#expression#Right , AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to publish notification. Code is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , message is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN_NUMBER AST#expression#Right , AST#expression#Left TAG AST#expression#Right , AST#expression#Left 'Succeeded in publishing notification.' 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
|
notificationManager.publish(notificationRequest, (err: Base.BusinessError) => {
if (err) {
hilog.error(DOMAIN_NUMBER, TAG,
`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
return;
}
hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in publishing notification.');
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/Notification/Notification/entry/src/main/ets/publish/PublishOperation.ets#L63-L70
|
d661a44cb0145e3400898ccb67a5c32630060ec1
|
gitee
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/models/managers/timeto/TimeToManager.ets
|
arkts
|
getLastResult
|
获取上次执行结果,返回 true/false/undefined
|
public static getLastResult(type: TimeToType): boolean | undefined {
return TimeToManager.getLastResultByName(type);
}
|
AST#method_declaration#Left public static getLastResult AST#parameter_list#Left ( AST#parameter#Left type : AST#type_annotation#Left AST#primary_type#Left TimeToType AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left boolean AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left TimeToManager AST#expression#Right . getLastResultByName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left type AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public static getLastResult(type: TimeToType): boolean | undefined {
return TimeToManager.getLastResultByName(type);
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/managers/timeto/TimeToManager.ets#L49-L51
|
bf470eac4421c8a9ae599f72a54c03ed6758c110
|
github
|
Piagari/arkts_example.git
|
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
|
hmos_app-main/hmos_app-main/legado-Harmony-master/entry/src/main/ets/common/model/SearchConfig.ets
|
arkts
|
@author 2008
@datetime 2024/8/15 0:06
@className: SearchConfig
|
export class SearchConfig {
path: string;
method: string;
body: string;
charset: string;
url: string;
webView:boolean;
constructor(path: string, method: string, body: string, charset: string, url: string, webView:boolean) {
this.path = path;
this.method = method.toUpperCase(); // 确保方法为大写
this.body = body;
this.charset = charset??'UTF-8';
this.url = url;
this.webView = webView
}
// 替换 body 中的关键字
setKeyword(keyword: string): void {
this.body = this.body.replace('{{key}}', encodeURIComponent(keyword));
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class SearchConfig AST#class_body#Left { AST#property_declaration#Left path : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left method : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left body : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left charset : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left url : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left webView : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left path : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left method : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left body : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left charset : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left url : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left webView : 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . path AST#member_expression#Right = AST#expression#Left path AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . method AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left method AST#expression#Right . toUpperCase AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 . body AST#member_expression#Right = AST#expression#Left body 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 . charset AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left charset AST#expression#Right ?? AST#expression#Left 'UTF-8' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . url AST#member_expression#Right = AST#expression#Left url AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . webView AST#member_expression#Right = AST#expression#Left webView 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 // 替换 body 中的关键字 AST#method_declaration#Left setKeyword 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 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 . body 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 . body AST#member_expression#Right AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '{{key}}' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left encodeURIComponent AST#expression#Right AST#argument_list#Left ( AST#expression#Left keyword 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#builder_function_body#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class SearchConfig {
path: string;
method: string;
body: string;
charset: string;
url: string;
webView:boolean;
constructor(path: string, method: string, body: string, charset: string, url: string, webView:boolean) {
this.path = path;
this.method = method.toUpperCase();
this.body = body;
this.charset = charset??'UTF-8';
this.url = url;
this.webView = webView
}
setKeyword(keyword: string): void {
this.body = this.body.replace('{{key}}', encodeURIComponent(keyword));
}
}
|
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/legado-Harmony-master/entry/src/main/ets/common/model/SearchConfig.ets#L6-L27
|
d1daaf16bff1f00c841a1ac99523228556039f8b
|
github
|
|
openharmony/xts_acts
|
5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686
|
arkui/ace_ets_module_ui/ace_ets_module_scroll/ace_ets_module_scroll_nowear_api11/entry/src/main/ets/MainAbility/pages/WaterFlow/WaterFlow_attribute/WaterFlowDataSource.ets
|
arkts
|
Delete1stItem
|
删除第一个元素
|
public Delete1stItem(): void {
this.dataArray.splice(0, 1);
this.notifyDataDelete(0);
}
|
AST#method_declaration#Left public Delete1stItem AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . notifyDataDelete AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
public Delete1stItem(): void {
this.dataArray.splice(0, 1);
this.notifyDataDelete(0);
}
|
https://github.com/openharmony/xts_acts/blob/5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686/arkui/ace_ets_module_ui/ace_ets_module_scroll/ace_ets_module_scroll_nowear_api11/entry/src/main/ets/MainAbility/pages/WaterFlow/WaterFlow_attribute/WaterFlowDataSource.ets#L104-L107
|
14874898f7512ecdd54bea903b3fa682ba09e325
|
gitee
|
from-north-to-north/OpenHarmony_p7885
|
f6ea526c039db535a7c958fa154ccfcb3668b37c
|
hap/Cpu_info_float_windows/hap/Cpu_info_3.8/entry/src/main/ets/controller/FloatWindowController.ets
|
arkts
|
createAndShowFloatWindow
|
创建悬浮窗
|
private async createAndShowFloatWindow(context: common.UIAbilityContext) {
if (context.isTerminating()) {
return;
}
console.info(TAG,` createAndShowWindow`);
let w = display.getDefaultDisplaySync().width;//获取屏幕宽度
let h = display.getDefaultDisplaySync().height;//获取屏幕宽度
// 创建应用子窗口
this.floatWindow = await window.createWindow({
name: 'DemoFloatWindow',
windowType: window.WindowType.TYPE_FLOAT,
ctx: context
});
// 设置悬浮窗位置
await this.floatWindow.moveWindowTo(w - FLOAT_SIZE - 200, h - FLOAT_SIZE - 800);
// 设置悬浮窗大小
await this.floatWindow.resize(FLOAT_SIZE + 185, FLOAT_SIZE + 130);
//// 为悬浮窗加载页面内容,这里可以设置在main_pages.json中配置的页面
await this.floatWindow.setUIContent('pages/Float');
this.floatWindow.setWindowBackgroundColor('#0009cf40');
// 显示悬浮窗。
await this.floatWindow.showWindow();
}
|
AST#method_declaration#Left private async createAndShowFloatWindow AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . isTerminating AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` createAndShowWindow ` 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 w = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left display AST#expression#Right . getDefaultDisplaySync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //获取屏幕宽度 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left h = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left display AST#expression#Right . getDefaultDisplaySync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //获取屏幕宽度 // 创建应用子窗口 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . floatWindow AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left window AST#expression#Right AST#await_expression#Right AST#expression#Right . createWindow 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 name AST#property_name#Right : AST#expression#Left 'DemoFloatWindow' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left windowType AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . WindowType AST#member_expression#Right AST#expression#Right . TYPE_FLOAT AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left ctx AST#property_name#Right : AST#expression#Left context AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 设置悬浮窗位置 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . floatWindow AST#member_expression#Right AST#expression#Right . moveWindowTo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left w AST#expression#Right - AST#expression#Left FLOAT_SIZE AST#expression#Right AST#binary_expression#Right AST#expression#Right - AST#expression#Left 200 AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left h AST#expression#Right - AST#expression#Left FLOAT_SIZE AST#expression#Right AST#binary_expression#Right AST#expression#Right - AST#expression#Left 800 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 设置悬浮窗大小 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#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 . floatWindow AST#member_expression#Right AST#expression#Right . resize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left FLOAT_SIZE AST#expression#Right + AST#expression#Left 185 AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left FLOAT_SIZE AST#expression#Right + AST#expression#Left 130 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 //// 为悬浮窗加载页面内容,这里可以设置在main_pages.json中配置的页面 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . floatWindow AST#member_expression#Right AST#expression#Right . setUIContent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'pages/Float' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . floatWindow AST#member_expression#Right AST#expression#Right . setWindowBackgroundColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '#0009cf40' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 显示悬浮窗。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . floatWindow AST#member_expression#Right AST#expression#Right . showWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private async createAndShowFloatWindow(context: common.UIAbilityContext) {
if (context.isTerminating()) {
return;
}
console.info(TAG,` createAndShowWindow`);
let w = display.getDefaultDisplaySync().width;
let h = display.getDefaultDisplaySync().height;
this.floatWindow = await window.createWindow({
name: 'DemoFloatWindow',
windowType: window.WindowType.TYPE_FLOAT,
ctx: context
});
await this.floatWindow.moveWindowTo(w - FLOAT_SIZE - 200, h - FLOAT_SIZE - 800);
await this.floatWindow.resize(FLOAT_SIZE + 185, FLOAT_SIZE + 130);
await this.floatWindow.setUIContent('pages/Float');
this.floatWindow.setWindowBackgroundColor('#0009cf40');
await this.floatWindow.showWindow();
}
|
https://github.com/from-north-to-north/OpenHarmony_p7885/blob/f6ea526c039db535a7c958fa154ccfcb3668b37c/hap/Cpu_info_float_windows/hap/Cpu_info_3.8/entry/src/main/ets/controller/FloatWindowController.ets#L60-L92
|
b8b2c6aedd0c4018c7d2edda3b9de2898aa795a1
|
gitee
|
JackJiang2011/harmonychat.git
|
bca3f3e1ce54d763720510f99acf595a49e37879
|
entry/src/main/ets/pages/utils/ToolKits.ets
|
arkts
|
setStatusBarColor
|
设置全面屏状态栏颜色。
@param context 上下文对象
@param statusBarContentColor 状态栏文本颜色
@param statusBarColor 状态栏背景色
|
static setStatusBarColor(context: common.BaseContext, statusBarContentColor: string, statusBarColor: string) {
// window.getLastWindow(context).then((windowClass: window.Window) => { // 这种方式获得window对象时,在page首次启动后,为啥在onPageShow里调用setStatusBarColor没效果?
try {
let windowClass = AppStorage.get<window.Window>('window')
windowClass?.setWindowSystemBarProperties({
statusBarContentColor: statusBarContentColor,//color,
statusBarColor: statusBarColor,
// navigationBarColor: '#0000ff',
// navigationBarContentColor: '#fff00f'
});
} catch (exception) {
ClientCoreSDK.Log.error(TAG+ 'Failed to set the system bar properties. Cause: ' + JSON.stringify(exception));
}
// });
}
|
AST#method_declaration#Left static setStatusBarColor AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . BaseContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left statusBarContentColor : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left statusBarColor : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { // window.getLastWindow(context).then((windowClass: window.Window) => { // 这种方式获得window对象时,在page首次启动后,为啥在onPageShow里调用setStatusBarColor没效果? AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left windowClass = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left 'window' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left w AST#ERROR#Right in AST#expression#Left dowClass AST#expression#Right AST#binary_expression#Right AST#expression#Right ?. setWindowSystemBarProperties AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left statusBarContentColor AST#property_name#Right : AST#expression#Left statusBarContentColor AST#expression#Right AST#property_assignment#Right , //color, AST#property_assignment#Left AST#property_name#Left statusBarColor AST#property_name#Right : AST#expression#Left statusBarColor AST#expression#Right AST#property_assignment#Right , // navigationBarColor: '#0000ff', // navigationBarContentColor: '#fff00f' } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( exception ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ClientCoreSDK AST#expression#Right . Log AST#member_expression#Right AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left TAG AST#expression#Right + AST#expression#Left 'Failed to set the system bar properties. Cause: ' AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left exception AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right // }); } AST#block_statement#Right AST#method_declaration#Right
|
static setStatusBarColor(context: common.BaseContext, statusBarContentColor: string, statusBarColor: string) {
try {
let windowClass = AppStorage.get<window.Window>('window')
windowClass?.setWindowSystemBarProperties({
statusBarContentColor: statusBarContentColor,
statusBarColor: statusBarColor,
});
} catch (exception) {
ClientCoreSDK.Log.error(TAG+ 'Failed to set the system bar properties. Cause: ' + JSON.stringify(exception));
}
}
|
https://github.com/JackJiang2011/harmonychat.git/blob/bca3f3e1ce54d763720510f99acf595a49e37879/entry/src/main/ets/pages/utils/ToolKits.ets#L47-L62
|
1f8e940b47725209f6d5b41ae20d7cc1fa70ff84
|
github
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/pages/SimpleBirthdayApp.ets
|
arkts
|
buildBirthdayCard
|
构建生日卡片
|
@Builder
buildBirthdayCard(contact: Contact, isToday: boolean) {
Row({ space: 12 }) {
// 头像
Column() {
Text(contact.name.charAt(0))
.fontSize(20)
.fontWeight(FontWeight.Bold)
.fontColor('#FFFFFF')
}
.width(48)
.height(48)
.borderRadius(24)
.backgroundColor(isToday ? '#ff6b6b' : '#4ECDC4')
.justifyContent(FlexAlign.Center)
// 信息
Column({ space: 4 }) {
Row({ space: 8 }) {
Text(contact.name)
.fontSize(16)
.fontWeight(FontWeight.Medium)
.fontColor('#333333')
if (contact.birthday.isLunar) {
Text('农历')
.fontSize(10)
.fontColor('#ff6b6b')
.backgroundColor('#fff0f0')
.padding({ left: 6, right: 6, top: 2, bottom: 2 })
.borderRadius(8)
}
}
.alignItems(VerticalAlign.Center)
Row({ space: 8 }) {
Text(isToday ? '今日公历之星' : '今日农历之星')
.fontSize(12)
.fontColor(isToday ? '#ff6b6b' : '#4ECDC4')
Text(`${contact.relation} • ${contact.birthday.age}岁`)
.fontSize(12)
.fontColor('#666666')
}
if (isToday) {
Text('今日公历生日代表')
.fontSize(10)
.fontColor('#999999')
}
// 星级评价
Row({ space: 2 }) {
ForEach(Array(5).fill(0), (_: number, index: number) => {
Text('⭐')
.fontSize(12)
.opacity(index < (contact.intimacyLevel || 3) ? 1 : 0.3)
})
}
.margin({ top: 4 })
}
.alignItems(HorizontalAlign.Start)
.layoutWeight(1)
// 发祝福按钮
Button('发祝福')
.type(ButtonType.Capsule)
.fontSize(12)
.backgroundColor('#4ECDC4')
.fontColor('#FFFFFF')
.width(60)
.height(32)
.onClick(() => {
promptAction.showToast({
message: `向 ${contact.name} 发送祝福`,
duration: 2000
});
})
}
.width('100%')
.padding(16)
.backgroundColor('#f8f9fa')
.borderRadius(12)
.onClick(() => {
promptAction.showToast({
message: `查看 ${contact.name} 的详细信息`,
duration: 2000
});
})
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildBirthdayCard AST#parameter_list#Left ( AST#parameter#Left contact : AST#type_annotation#Left AST#primary_type#Left Contact AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left isToday : 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#container_content_body#Left { 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 contact AST#expression#Right . name AST#member_expression#Right AST#expression#Right . charAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#FFFFFF' 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 48 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 48 AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left isToday AST#expression#Right ? AST#expression#Left '#ff6b6b' AST#expression#Right : AST#expression#Left '#4ECDC4' AST#expression#Right AST#conditional_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 . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 信息 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 4 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 8 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left contact AST#expression#Right . name AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . 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#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left contact AST#expression#Right . birthday AST#member_expression#Right AST#expression#Right . isLunar AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '农历' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 10 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#ff6b6b' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#fff0f0' 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 . borderRadius ( AST#expression#Left 8 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left VerticalAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 8 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left isToday AST#expression#Right ? AST#expression#Left '今日公历之星' AST#expression#Right : AST#expression#Left '今日农历之星' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left isToday AST#expression#Right ? AST#expression#Left '#ff6b6b' AST#expression#Right : AST#expression#Left '#4ECDC4' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left contact AST#expression#Right . relation AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right • AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left contact AST#expression#Right . birthday AST#member_expression#Right AST#expression#Right . age AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right 岁 ` AST#template_literal#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#666666' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#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 isToday AST#expression#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 10 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#999999' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right // 星级评价 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 2 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#call_expression#Left AST#expression#Left Array AST#expression#Right AST#argument_list#Left ( AST#expression#Left 5 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fill 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#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left _ : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '⭐' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right < AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left contact AST#expression#Right . intimacyLevel AST#member_expression#Right AST#expression#Right || AST#expression#Left 3 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 1 AST#expression#Right : AST#expression#Left 0.3 AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#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 . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 发祝福按钮 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left 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 . Capsule AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#4ECDC4' AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#FFFFFF' AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 32 AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` 向 AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left contact AST#expression#Right . name 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#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 . padding ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#f8f9fa' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` 查看 AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left contact AST#expression#Right . name 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#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
buildBirthdayCard(contact: Contact, isToday: boolean) {
Row({ space: 12 }) {
Column() {
Text(contact.name.charAt(0))
.fontSize(20)
.fontWeight(FontWeight.Bold)
.fontColor('#FFFFFF')
}
.width(48)
.height(48)
.borderRadius(24)
.backgroundColor(isToday ? '#ff6b6b' : '#4ECDC4')
.justifyContent(FlexAlign.Center)
Column({ space: 4 }) {
Row({ space: 8 }) {
Text(contact.name)
.fontSize(16)
.fontWeight(FontWeight.Medium)
.fontColor('#333333')
if (contact.birthday.isLunar) {
Text('农历')
.fontSize(10)
.fontColor('#ff6b6b')
.backgroundColor('#fff0f0')
.padding({ left: 6, right: 6, top: 2, bottom: 2 })
.borderRadius(8)
}
}
.alignItems(VerticalAlign.Center)
Row({ space: 8 }) {
Text(isToday ? '今日公历之星' : '今日农历之星')
.fontSize(12)
.fontColor(isToday ? '#ff6b6b' : '#4ECDC4')
Text(`${contact.relation} • ${contact.birthday.age}岁`)
.fontSize(12)
.fontColor('#666666')
}
if (isToday) {
Text('今日公历生日代表')
.fontSize(10)
.fontColor('#999999')
}
Row({ space: 2 }) {
ForEach(Array(5).fill(0), (_: number, index: number) => {
Text('⭐')
.fontSize(12)
.opacity(index < (contact.intimacyLevel || 3) ? 1 : 0.3)
})
}
.margin({ top: 4 })
}
.alignItems(HorizontalAlign.Start)
.layoutWeight(1)
Button('发祝福')
.type(ButtonType.Capsule)
.fontSize(12)
.backgroundColor('#4ECDC4')
.fontColor('#FFFFFF')
.width(60)
.height(32)
.onClick(() => {
promptAction.showToast({
message: `向 ${contact.name} 发送祝福`,
duration: 2000
});
})
}
.width('100%')
.padding(16)
.backgroundColor('#f8f9fa')
.borderRadius(12)
.onClick(() => {
promptAction.showToast({
message: `查看 ${contact.name} 的详细信息`,
duration: 2000
});
})
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/SimpleBirthdayApp.ets#L586-L675
|
2ba2f28dec1696e63546d3b66c74a1c11cf16489
|
github
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/watermark/src/main/ets/view/MainView.ets
|
arkts
|
showToast
|
弹窗函数
|
showToast() {
promptAction.showToast({
message: $r('app.string.water_mark_toast_message')
})
}
|
AST#method_declaration#Left showToast 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 promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.water_mark_toast_message' 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#builder_function_body#Right AST#method_declaration#Right
|
showToast() {
promptAction.showToast({
message: $r('app.string.water_mark_toast_message')
})
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/watermark/src/main/ets/view/MainView.ets#L85-L89
|
22f261ef3fad56b16da4e39de33829079b9da55b
|
gitee
|
wasd09090030/MyHongmengProject.git
|
a8ed386b658ceeac69ef5bc42a92d78c7980821c
|
entry/src/main/ets/components/TimerPage.ets
|
arkts
|
TimerContent
|
倒计时内容
|
@Builder
TimerContent() {
Column() {
// 显示当前关联的任务(如果有)
if (this.currentTask) {
Row({ space: 12 }) {
SymbolGlyph($r('sys.symbol.flag_fill'))
.fontSize(24)
.fontColor(['#007DFF'])
Column({ space: 4 }) {
Text('当前专注任务')
.fontSize(12)
.fontColor('#999999')
Text(this.currentTask.name)
.fontSize(16)
.fontColor('#007DFF')
.fontWeight(FontWeight.Medium)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
.alignItems(HorizontalAlign.Start)
.layoutWeight(1)
}
.width('90%')
.padding({ left: 16, right: 16, top: 14, bottom: 14 })
.backgroundColor('#E8F4FF')
.borderRadius(12)
.margin({ top: 8, bottom: 16 })
}
// 预设快速计时
if (!this.timerRunning && this.timerRemaining === 0) {
Column({ space: 12 }) {
Text('快速设置')
.fontSize(16)
.fontWeight(FontWeight.Medium)
.fontColor('#666666')
.margin({ top: 12 })
Row({ space: 10 }) {
ForEach(this.presets, (preset: number) => {
Button(`${preset / 60}分钟`)
.fontSize(15)
.height(40)
.layoutWeight(1)
.type(ButtonType.Normal)
.backgroundColor('#E8F4FF')
.fontColor('#007DFF')
.borderRadius(10)
.onClick(() => this.setPresetTimer(preset))
})
}
.width('90%')
}
.width('100%')
.margin({ bottom: 20 })
Divider()
.width('85%')
.color('#E5E5E5')
.margin({ top: 16, bottom: 16 })
}
// 时间显示或设置
if (this.timerRunning || this.timerRemaining > 0) {
// 运行中显示倒计时
Column() {
Text(this.formatTimerTime())
.fontSize(72)
.fontWeight(FontWeight.Bold)
.fontFamily('monospace')
.fontColor(this.timerRemaining <= 60 && this.timerRunning ? '#FF3B30' : '#1A1A1A')
.letterSpacing(6)
.animation({
duration: 300,
curve: Curve.EaseInOut
})
}
.width('100%')
.padding({ top: 80, bottom: 80 })
.justifyContent(FlexAlign.Center)
} else {
// 设置界面
Row({ space: 8 }) {
Column({ space: 8 }) {
Text('时')
.fontSize(14)
.fontColor('#999999')
TextInput({ text: this.timerHours.toString() })
.width(70)
.height(90)
.fontSize(36)
.fontWeight(FontWeight.Medium)
.textAlign(TextAlign.Center)
.type(InputType.Number)
.backgroundColor('#F8F8F8')
.borderRadius(12)
.onChange((value: string) => {
this.timerHours = Math.max(0, Math.min(23, parseInt(value) || 0));
})
}
Text(':')
.fontSize(48)
.fontColor('#CCCCCC')
.margin({ top: 20 })
Column({ space: 8 }) {
Text('分')
.fontSize(14)
.fontColor('#999999')
TextInput({ text: this.timerMinutes.toString() })
.width(70)
.height(90)
.fontSize(36)
.fontWeight(FontWeight.Medium)
.textAlign(TextAlign.Center)
.type(InputType.Number)
.backgroundColor('#F8F8F8')
.borderRadius(12)
.onChange((value: string) => {
this.timerMinutes = Math.max(0, Math.min(59, parseInt(value) || 0));
})
}
Text(':')
.fontSize(48)
.fontColor('#CCCCCC')
.margin({ top: 20 })
Column({ space: 8 }) {
Text('秒')
.fontSize(14)
.fontColor('#999999')
TextInput({ text: this.timerSeconds.toString() })
.width(70)
.height(90)
.fontSize(36)
.fontWeight(FontWeight.Medium)
.textAlign(TextAlign.Center)
.type(InputType.Number)
.backgroundColor('#F8F8F8')
.borderRadius(12)
.onChange((value: string) => {
this.timerSeconds = Math.max(0, Math.min(59, parseInt(value) || 0));
})
}
}
.margin({ top: 60, bottom: 60 })
}
// 控制按钮
Row({ space: 16 }) {
if (!this.timerRunning && this.timerRemaining === 0) {
Button('开始')
.width(80)
.height(80)
.fontSize(16)
.fontWeight(FontWeight.Medium)
.type(ButtonType.Circle)
.backgroundColor('#34C759')
.enabled(this.timerHours + this.timerMinutes + this.timerSeconds > 0)
.opacity(this.timerHours + this.timerMinutes + this.timerSeconds > 0 ? 1 : 0.4)
.shadow({
radius: 16,
color: '#34C75933',
offsetY: 8
})
.onClick(() => this.startTimer())
} else if (this.timerRunning) {
Button('暂停')
.width(80)
.height(80)
.fontSize(16)
.fontWeight(FontWeight.Medium)
.type(ButtonType.Circle)
.backgroundColor('#FF9500')
.shadow({
radius: 12,
color: '#FF950033',
offsetY: 6
})
.onClick(() => this.pauseTimer())
Button('取消')
.width(80)
.height(80)
.fontSize(16)
.fontWeight(FontWeight.Medium)
.type(ButtonType.Circle)
.backgroundColor('#FF3B30')
.shadow({
radius: 12,
color: '#FF3B3033',
offsetY: 6
})
.onClick(() => this.cancelTimer())
} else {
Button('继续')
.width(80)
.height(80)
.fontSize(16)
.fontWeight(FontWeight.Medium)
.type(ButtonType.Circle)
.backgroundColor('#34C759')
.shadow({
radius: 12,
color: '#34C75933',
offsetY: 6
})
.onClick(() => this.startTimer())
Button('取消')
.width(80)
.height(80)
.fontSize(16)
.fontWeight(FontWeight.Medium)
.type(ButtonType.Circle)
.backgroundColor('#8E8E93')
.shadow({
radius: 12,
color: '#8E8E9333',
offsetY: 6
})
.onClick(() => this.cancelTimer())
}
}
.justifyContent(FlexAlign.Center)
.margin({ bottom: 20 })
// 完成任务按钮(仅在有关联任务且计时器运行中时显示)
if (this.currentTask && (this.timerRunning || this.timerRemaining > 0)) {
Button('提前完成任务')
.width('80%')
.height(35)
.fontSize(17)
.fontWeight(FontWeight.Medium)
.type(ButtonType.Normal)
.backgroundColor('#34C759')
.fontColor(Color.White)
.borderRadius(25)
.shadow({
radius: 12,
color: '#34C75933',
offsetY: 6
})
.margin({ top: 24 })
.onClick(() => this.completeTaskEarly())
}
}
.width('100%')
.height('100%')
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right TimerContent AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { // 显示当前关联的任务(如果有) AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentTask AST#member_expression#Right AST#expression#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 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 SymbolGlyph ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'sys.symbol.flag_fill' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left '#007DFF' AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#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#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#999999' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentTask AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#007DFF' 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 . maxLines ( AST#expression#Left 1 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#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#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '90%' AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 14 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 14 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#E8F4FF' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 8 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right // 预设快速计时 AST#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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . timerRunning AST#member_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . timerRemaining AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 12 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '快速设置' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#666666' AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 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#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 10 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 . presets AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left preset : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#binary_expression#Left AST#expression#Left preset AST#expression#Right / AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right } AST#template_substitution#Right 分钟 ` AST#template_literal#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 15 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#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 '#E8F4FF' AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#007DFF' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 10 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 . setPresetTimer AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left preset 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#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 . width ( AST#expression#Left '90%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 20 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Divider ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '85%' AST#expression#Right ) AST#modifier_chain_expression#Left . color ( AST#expression#Left '#E5E5E5' AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#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#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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . timerRunning AST#member_expression#Right AST#expression#Right || AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . timerRemaining AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { // 运行中显示倒计时 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . formatTimerTime 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 72 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontFamily ( AST#expression#Left 'monospace' AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . timerRemaining AST#member_expression#Right AST#expression#Right <= AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . timerRunning AST#member_expression#Right AST#expression#Right ? AST#expression#Left '#FF3B30' AST#expression#Right : AST#expression#Left '#1A1A1A' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . letterSpacing ( AST#expression#Left 6 AST#expression#Right ) AST#modifier_chain_expression#Left . animation ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left 300 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left curve AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Curve AST#expression#Right . EaseInOut 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#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 80 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 80 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 8 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 8 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '时' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#999999' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left TextInput ( AST#component_parameters#Left { AST#component_parameter#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 . timerHours 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#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 70 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 90 AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 36 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 . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . type ( AST#expression#Left AST#member_expression#Left AST#expression#Left InputType AST#expression#Right . Number AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#F8F8F8' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . onChange ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . timerHours AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . max AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . min AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 23 AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left parseInt AST#expression#Right AST#argument_list#Left ( AST#expression#Left value AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left ':' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 48 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#CCCCCC' AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 20 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 8 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '分' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#999999' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left TextInput ( AST#component_parameters#Left { AST#component_parameter#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 . timerMinutes 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#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 70 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 90 AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 36 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 . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . type ( AST#expression#Left AST#member_expression#Left AST#expression#Left InputType AST#expression#Right . Number AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#F8F8F8' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . onChange ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . timerMinutes AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . max AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . min AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 59 AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left parseInt AST#expression#Right AST#argument_list#Left ( AST#expression#Left value AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left ':' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 48 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#CCCCCC' AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 20 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 8 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '秒' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#999999' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left TextInput ( AST#component_parameters#Left { AST#component_parameter#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 . timerSeconds 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#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 70 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 90 AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 36 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 . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . type ( AST#expression#Left AST#member_expression#Left AST#expression#Left InputType AST#expression#Right . Number AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#F8F8F8' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . onChange ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . timerSeconds AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . max AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . min AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 59 AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left parseInt AST#expression#Right AST#argument_list#Left ( AST#expression#Left value AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 60 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 60 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#ui_if_statement#Right AST#ui_control_flow#Right // 控制按钮 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 16 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . timerRunning AST#member_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . timerRemaining AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left '开始' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 80 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 80 AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#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 . backgroundColor ( AST#expression#Left '#34C759' AST#expression#Right ) AST#modifier_chain_expression#Left . enabled ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . timerHours AST#member_expression#Right AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . timerMinutes AST#member_expression#Right AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . timerSeconds AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . timerHours AST#member_expression#Right AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . timerMinutes AST#member_expression#Right AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . timerSeconds AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 1 AST#expression#Right : AST#expression#Left 0.4 AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . shadow ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left '#34C75933' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetY AST#property_name#Right : AST#expression#Left 8 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . 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 . startTimer AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 } else AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . timerRunning AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left '暂停' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 80 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 80 AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#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 . backgroundColor ( AST#expression#Left '#FF9500' AST#expression#Right ) AST#modifier_chain_expression#Left . shadow ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left '#FF950033' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetY 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 . pauseTimer AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left '取消' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 80 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 80 AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#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 . backgroundColor ( AST#expression#Left '#FF3B30' AST#expression#Right ) AST#modifier_chain_expression#Left . shadow ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left '#FF3B3033' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetY 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 . cancelTimer AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 } else { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left '继续' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 80 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 80 AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#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 . backgroundColor ( AST#expression#Left '#34C759' AST#expression#Right ) AST#modifier_chain_expression#Left . shadow ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left '#34C75933' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetY 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 . startTimer AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left '取消' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 80 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 80 AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#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 . backgroundColor ( AST#expression#Left '#8E8E93' AST#expression#Right ) AST#modifier_chain_expression#Left . shadow ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left '#8E8E9333' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetY 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 . cancelTimer AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#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 20 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 完成任务按钮(仅在有关联任务且计时器运行中时显示) AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentTask AST#member_expression#Right AST#expression#Right && 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#member_expression#Left AST#expression#Left this AST#expression#Right . timerRunning AST#member_expression#Right AST#expression#Right || AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . timerRemaining 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#binary_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left '提前完成任务' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '80%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 35 AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 17 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 . 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 '#34C759' 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 . borderRadius ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . shadow ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left '#34C75933' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetY 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 . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 24 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 . completeTaskEarly AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
TimerContent() {
Column() {
if (this.currentTask) {
Row({ space: 12 }) {
SymbolGlyph($r('sys.symbol.flag_fill'))
.fontSize(24)
.fontColor(['#007DFF'])
Column({ space: 4 }) {
Text('当前专注任务')
.fontSize(12)
.fontColor('#999999')
Text(this.currentTask.name)
.fontSize(16)
.fontColor('#007DFF')
.fontWeight(FontWeight.Medium)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
.alignItems(HorizontalAlign.Start)
.layoutWeight(1)
}
.width('90%')
.padding({ left: 16, right: 16, top: 14, bottom: 14 })
.backgroundColor('#E8F4FF')
.borderRadius(12)
.margin({ top: 8, bottom: 16 })
}
if (!this.timerRunning && this.timerRemaining === 0) {
Column({ space: 12 }) {
Text('快速设置')
.fontSize(16)
.fontWeight(FontWeight.Medium)
.fontColor('#666666')
.margin({ top: 12 })
Row({ space: 10 }) {
ForEach(this.presets, (preset: number) => {
Button(`${preset / 60}分钟`)
.fontSize(15)
.height(40)
.layoutWeight(1)
.type(ButtonType.Normal)
.backgroundColor('#E8F4FF')
.fontColor('#007DFF')
.borderRadius(10)
.onClick(() => this.setPresetTimer(preset))
})
}
.width('90%')
}
.width('100%')
.margin({ bottom: 20 })
Divider()
.width('85%')
.color('#E5E5E5')
.margin({ top: 16, bottom: 16 })
}
if (this.timerRunning || this.timerRemaining > 0) {
Column() {
Text(this.formatTimerTime())
.fontSize(72)
.fontWeight(FontWeight.Bold)
.fontFamily('monospace')
.fontColor(this.timerRemaining <= 60 && this.timerRunning ? '#FF3B30' : '#1A1A1A')
.letterSpacing(6)
.animation({
duration: 300,
curve: Curve.EaseInOut
})
}
.width('100%')
.padding({ top: 80, bottom: 80 })
.justifyContent(FlexAlign.Center)
} else {
Row({ space: 8 }) {
Column({ space: 8 }) {
Text('时')
.fontSize(14)
.fontColor('#999999')
TextInput({ text: this.timerHours.toString() })
.width(70)
.height(90)
.fontSize(36)
.fontWeight(FontWeight.Medium)
.textAlign(TextAlign.Center)
.type(InputType.Number)
.backgroundColor('#F8F8F8')
.borderRadius(12)
.onChange((value: string) => {
this.timerHours = Math.max(0, Math.min(23, parseInt(value) || 0));
})
}
Text(':')
.fontSize(48)
.fontColor('#CCCCCC')
.margin({ top: 20 })
Column({ space: 8 }) {
Text('分')
.fontSize(14)
.fontColor('#999999')
TextInput({ text: this.timerMinutes.toString() })
.width(70)
.height(90)
.fontSize(36)
.fontWeight(FontWeight.Medium)
.textAlign(TextAlign.Center)
.type(InputType.Number)
.backgroundColor('#F8F8F8')
.borderRadius(12)
.onChange((value: string) => {
this.timerMinutes = Math.max(0, Math.min(59, parseInt(value) || 0));
})
}
Text(':')
.fontSize(48)
.fontColor('#CCCCCC')
.margin({ top: 20 })
Column({ space: 8 }) {
Text('秒')
.fontSize(14)
.fontColor('#999999')
TextInput({ text: this.timerSeconds.toString() })
.width(70)
.height(90)
.fontSize(36)
.fontWeight(FontWeight.Medium)
.textAlign(TextAlign.Center)
.type(InputType.Number)
.backgroundColor('#F8F8F8')
.borderRadius(12)
.onChange((value: string) => {
this.timerSeconds = Math.max(0, Math.min(59, parseInt(value) || 0));
})
}
}
.margin({ top: 60, bottom: 60 })
}
Row({ space: 16 }) {
if (!this.timerRunning && this.timerRemaining === 0) {
Button('开始')
.width(80)
.height(80)
.fontSize(16)
.fontWeight(FontWeight.Medium)
.type(ButtonType.Circle)
.backgroundColor('#34C759')
.enabled(this.timerHours + this.timerMinutes + this.timerSeconds > 0)
.opacity(this.timerHours + this.timerMinutes + this.timerSeconds > 0 ? 1 : 0.4)
.shadow({
radius: 16,
color: '#34C75933',
offsetY: 8
})
.onClick(() => this.startTimer())
} else if (this.timerRunning) {
Button('暂停')
.width(80)
.height(80)
.fontSize(16)
.fontWeight(FontWeight.Medium)
.type(ButtonType.Circle)
.backgroundColor('#FF9500')
.shadow({
radius: 12,
color: '#FF950033',
offsetY: 6
})
.onClick(() => this.pauseTimer())
Button('取消')
.width(80)
.height(80)
.fontSize(16)
.fontWeight(FontWeight.Medium)
.type(ButtonType.Circle)
.backgroundColor('#FF3B30')
.shadow({
radius: 12,
color: '#FF3B3033',
offsetY: 6
})
.onClick(() => this.cancelTimer())
} else {
Button('继续')
.width(80)
.height(80)
.fontSize(16)
.fontWeight(FontWeight.Medium)
.type(ButtonType.Circle)
.backgroundColor('#34C759')
.shadow({
radius: 12,
color: '#34C75933',
offsetY: 6
})
.onClick(() => this.startTimer())
Button('取消')
.width(80)
.height(80)
.fontSize(16)
.fontWeight(FontWeight.Medium)
.type(ButtonType.Circle)
.backgroundColor('#8E8E93')
.shadow({
radius: 12,
color: '#8E8E9333',
offsetY: 6
})
.onClick(() => this.cancelTimer())
}
}
.justifyContent(FlexAlign.Center)
.margin({ bottom: 20 })
if (this.currentTask && (this.timerRunning || this.timerRemaining > 0)) {
Button('提前完成任务')
.width('80%')
.height(35)
.fontSize(17)
.fontWeight(FontWeight.Medium)
.type(ButtonType.Normal)
.backgroundColor('#34C759')
.fontColor(Color.White)
.borderRadius(25)
.shadow({
radius: 12,
color: '#34C75933',
offsetY: 6
})
.margin({ top: 24 })
.onClick(() => this.completeTaskEarly())
}
}
.width('100%')
.height('100%')
}
|
https://github.com/wasd09090030/MyHongmengProject.git/blob/a8ed386b658ceeac69ef5bc42a92d78c7980821c/entry/src/main/ets/components/TimerPage.ets#L271-L525
|
9433c9d2c6e7e0d4ab62937f15c86d52bc745672
|
github
|
openharmony-tpc/ohos_mpchart
|
4fb43a7137320ef2fee2634598f53d93975dfb4a
|
library/src/main/ets/components/animation/ChartAnimator.ets
|
arkts
|
animateX
|
/** * Animates values along the X axis, in a linear fashion. * * @param durationMillis animation duration public animateX(durationMillis:number) { animateX(durationMillis, Easing.Linear); }
Animates values along the X axis.
@param durationMillis animation duration
@param easing EasingFunction
|
public animateX(durationMillis: number): void;
|
AST#method_declaration#Left public animateX AST#parameter_list#Left ( AST#parameter#Left durationMillis : 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#method_declaration#Right
|
public animateX(durationMillis: number): void;
|
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/animation/ChartAnimator.ets#L97-L97
|
0a9b58c568219b75868da27812bd2311e76385dc
|
gitee
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/models/managers/plan/plandb/PlanDbAccess.ets
|
arkts
|
createDbIfNeeds
|
private constructor() { //createFolderIfNeeds(this.getDbFolder()); this.db = new DBAccessor(this.getDbPath(), null, false); this.createDbIfNeeds(); } getDbFolder():string { return BookManager.getCurrentDirectoryOfUserData() } getDbPath(): string { return BookManager.getCurrentPathOfUserData() } refreshDb(): void { this.createDbIfNeeds(); } ====== 创建表(如果不存在) ======
|
createDbIfNeeds(): void {
if (!this.db) return;
const sqlPlan = `CREATE TABLE IF NOT EXISTS "${Tables.Plan.name}" (
"${Tables.Plan.Col.planId}" INTEGER PRIMARY KEY NOT NULL,
"${Tables.Plan.Col.planName}" TEXT,
"${Tables.Plan.Col.bookId}" INTEGER,
"${Tables.Plan.Col.countPerDay}" INTEGER,
"${Tables.Plan.Col.startDate}" TEXT,
"${Tables.Plan.Col.distances}" TEXT,
"${Tables.Plan.Col.process}" TEXT
)`;
const sqlPiece = `CREATE TABLE IF NOT EXISTS "${Tables.Piece.name}" (
"${Tables.Piece.Col.planId}" INTEGER,
"${Tables.Piece.Col.pieceNo}" INTEGER,
"${Tables.Piece.Col.wordId}" INTEGER
)`;
const sqlBox = `CREATE TABLE IF NOT EXISTS "${Tables.Box.name}" (
"${Tables.Box.Col.planId}" INTEGER,
"${Tables.Box.Col.num}" INTEGER,
"${Tables.Box.Col.distance}" INTEGER,
"${Tables.Box.Col.pieceNo}" INTEGER
)`;
const sqlLearn = `CREATE TABLE IF NOT EXISTS "${Tables.Learn.name}" (
"${Tables.Learn.Col.planId}" INTEGER,
"${Tables.Learn.Col.bookId}" INTEGER,
"${Tables.Learn.Col.num}" INTEGER,
"${Tables.Learn.Col.distance}" INTEGER,
"${Tables.Learn.Col.pieceNo}" INTEGER,
"${Tables.Learn.Col.wordId}" INTEGER,
"${Tables.Learn.Col.learnDate}" TEXT
)`;
this.db.updateDb(sqlPlan);
this.db.updateDb(sqlPiece);
this.db.updateDb(sqlBox);
this.db.updateDb(sqlLearn);
}
|
AST#method_declaration#Left createDbIfNeeds AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . db AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left sqlPlan = AST#expression#Left AST#template_literal#Left ` CREATE TABLE IF NOT EXISTS " AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Plan AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " (
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Plan AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . planId AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " INTEGER PRIMARY KEY NOT NULL,
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Plan AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . planName AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " TEXT,
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Plan AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . bookId AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " INTEGER,
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Plan AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . countPerDay AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " INTEGER,
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Plan AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . startDate AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " TEXT,
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Plan AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . distances AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " TEXT,
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Plan AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . process AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " TEXT
) ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left sqlPiece = AST#expression#Left AST#template_literal#Left ` CREATE TABLE IF NOT EXISTS " AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Piece AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " (
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Piece AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . planId AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " INTEGER,
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Piece AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . pieceNo AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " INTEGER,
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Piece AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . wordId AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " INTEGER
) ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left sqlBox = AST#expression#Left AST#template_literal#Left ` CREATE TABLE IF NOT EXISTS " AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Box AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " (
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Box AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . planId AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " INTEGER,
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Box AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . num AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " INTEGER,
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Box AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . distance AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " INTEGER,
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Box AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . pieceNo AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " INTEGER
) ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left sqlLearn = AST#expression#Left AST#template_literal#Left ` CREATE TABLE IF NOT EXISTS " AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Learn AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " (
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Learn AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . planId AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " INTEGER,
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Learn AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . bookId AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " INTEGER,
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Learn AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . num AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " INTEGER,
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Learn AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . distance AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " INTEGER,
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Learn AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . pieceNo AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " INTEGER,
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Learn AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . wordId AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " INTEGER,
" AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Learn AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . learnDate AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right " TEXT
) ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . db AST#member_expression#Right AST#expression#Right . updateDb AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sqlPlan AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . db AST#member_expression#Right AST#expression#Right . updateDb AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sqlPiece AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . db AST#member_expression#Right AST#expression#Right . updateDb AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sqlBox AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . db AST#member_expression#Right AST#expression#Right . updateDb AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sqlLearn 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
|
createDbIfNeeds(): void {
if (!this.db) return;
const sqlPlan = `CREATE TABLE IF NOT EXISTS "${Tables.Plan.name}" (
"${Tables.Plan.Col.planId}" INTEGER PRIMARY KEY NOT NULL,
"${Tables.Plan.Col.planName}" TEXT,
"${Tables.Plan.Col.bookId}" INTEGER,
"${Tables.Plan.Col.countPerDay}" INTEGER,
"${Tables.Plan.Col.startDate}" TEXT,
"${Tables.Plan.Col.distances}" TEXT,
"${Tables.Plan.Col.process}" TEXT
)`;
const sqlPiece = `CREATE TABLE IF NOT EXISTS "${Tables.Piece.name}" (
"${Tables.Piece.Col.planId}" INTEGER,
"${Tables.Piece.Col.pieceNo}" INTEGER,
"${Tables.Piece.Col.wordId}" INTEGER
)`;
const sqlBox = `CREATE TABLE IF NOT EXISTS "${Tables.Box.name}" (
"${Tables.Box.Col.planId}" INTEGER,
"${Tables.Box.Col.num}" INTEGER,
"${Tables.Box.Col.distance}" INTEGER,
"${Tables.Box.Col.pieceNo}" INTEGER
)`;
const sqlLearn = `CREATE TABLE IF NOT EXISTS "${Tables.Learn.name}" (
"${Tables.Learn.Col.planId}" INTEGER,
"${Tables.Learn.Col.bookId}" INTEGER,
"${Tables.Learn.Col.num}" INTEGER,
"${Tables.Learn.Col.distance}" INTEGER,
"${Tables.Learn.Col.pieceNo}" INTEGER,
"${Tables.Learn.Col.wordId}" INTEGER,
"${Tables.Learn.Col.learnDate}" TEXT
)`;
this.db.updateDb(sqlPlan);
this.db.updateDb(sqlPiece);
this.db.updateDb(sqlBox);
this.db.updateDb(sqlLearn);
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/managers/plan/plandb/PlanDbAccess.ets#L96-L136
|
0e73788e66c9106c4adc40e618c95bbe2037b3c0
|
github
|
sithvothykiv/dialog_hub.git
|
b676c102ef2d05f8994d170abe48dcc40cd39005
|
custom_dialog/src/main/ets/component/partView/DialogHeaderBuilder.ets
|
arkts
|
DialogHeaderBuilder
|
弹窗标题+按钮(如用在picker顶部,标题+按钮)
@param title 中间标题
@param primaryButton 左侧按钮
@param secondaryButton 右侧按钮
@param headerStyle 样式
@param onBtnClick 点击事件
|
@Builder
export function DialogHeaderBuilder(title: ResourceStr | undefined, headerStyle: ITextStyle | undefined,
primaryButton?: CustomButtonOptions,
secondaryButton?: CustomButtonOptions,
onBtnClick?: (isPrimary: boolean) => void) {
Row() {
if (primaryButton?.value) {
Button(primaryButton?.value)
.buttonStyle(primaryButton?.buttonStyle ?? ButtonStyleMode.TEXTUAL)
.role(primaryButton?.role ?? ButtonRole.NORMAL)
.fontColor(primaryButton?.fontColor)
.fontSize(primaryButton?.fontSize ?? 16)
.fontWeight(primaryButton?.fontWeight)
.backgroundColor(primaryButton?.background ?? Color.Transparent)
.linearGradient(primaryButton?.linearGradient)
.margin({ top: 10, bottom: 10, left: 10 })
.onClick(() => {
onBtnClick?.(true)
})
}
if (title) {
Text(title)
.textAlign(headerStyle?.textAlign ?? TextAlign.Center)
.fontColor(headerStyle?.fontColor)
.fontSize(headerStyle?.fontSize ?? 18)
.lineHeight(headerStyle?.lineHeight ?? 20)
.fontWeight(headerStyle?.fontWeight ?? FontWeight.Medium)
.textOverflow(headerStyle?.textOverflow ? { overflow: headerStyle?.textOverflow } : undefined)
.maxLines(headerStyle?.maxLines ?? 1)
.ellipsisMode(EllipsisMode.END)
.layoutWeight(1)
.constraintSize({ minHeight: headerStyle?.lineHeight ?? 20 })
} else {
Blank().layoutWeight(1)
.height(headerStyle?.lineHeight ?? 20)
}
if (secondaryButton?.value) {
Button(secondaryButton?.value)
.buttonStyle(secondaryButton?.buttonStyle ?? ButtonStyleMode.TEXTUAL)
.role(secondaryButton?.role ?? ButtonRole.NORMAL)
.fontSize(secondaryButton?.fontSize ?? 16)
.fontColor(secondaryButton?.fontColor)
.fontWeight(secondaryButton?.fontWeight)
.backgroundColor(secondaryButton?.background ?? Color.Transparent)
.linearGradient(primaryButton?.linearGradient)
.margin({ top: 10, bottom: 10, right: 10 })
.onClick(() => {
onBtnClick?.(false)
})
}
}
// .height(headerStyle?.height || (headerStyle?.lineHeight ?? 20))
.height(headerStyle?.height)
.padding(headerStyle?.padding)
.margin(headerStyle?.margin)
.border(headerStyle?.border)
.width(headerStyle?.width)
.borderRadius(headerStyle?.borderRadius)
.backgroundColor(headerStyle?.background)
.width('100%')
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function DialogHeaderBuilder AST#parameter_list#Left ( AST#parameter#Left title : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ResourceStr AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left headerStyle : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ITextStyle AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left primaryButton ? : AST#type_annotation#Left AST#primary_type#Left CustomButtonOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left secondaryButton ? : AST#type_annotation#Left AST#primary_type#Left CustomButtonOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left onBtnClick ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left isPrimary : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left primaryButton AST#expression#Right ?. value AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left AST#member_expression#Left AST#expression#Left primaryButton AST#expression#Right ?. value AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . buttonStyle ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left primaryButton AST#expression#Right ?. buttonStyle AST#member_expression#Right AST#expression#Right ?? AST#expression#Left ButtonStyleMode AST#expression#Right AST#binary_expression#Right AST#expression#Right . TEXTUAL AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . role ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left primaryButton AST#expression#Right ?. role AST#member_expression#Right AST#expression#Right ?? AST#expression#Left ButtonRole AST#expression#Right AST#binary_expression#Right AST#expression#Right . NORMAL AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left primaryButton AST#expression#Right ?. fontColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left primaryButton AST#expression#Right ?. fontSize AST#member_expression#Right AST#expression#Right ?? AST#expression#Left 16 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left primaryButton AST#expression#Right ?. fontWeight AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left primaryButton AST#expression#Right ?. background AST#member_expression#Right AST#expression#Right ?? AST#expression#Left Color AST#expression#Right AST#binary_expression#Right AST#expression#Right . Transparent AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . linearGradient ( AST#expression#Left AST#member_expression#Left AST#expression#Left primaryButton AST#expression#Right ?. linearGradient AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . 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 onBtnClick AST#expression#Right ?. AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left title AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left title AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left headerStyle AST#expression#Right ?. textAlign AST#member_expression#Right AST#expression#Right ?? AST#expression#Left TextAlign AST#expression#Right AST#binary_expression#Right AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left headerStyle AST#expression#Right ?. fontColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left headerStyle AST#expression#Right ?. fontSize AST#member_expression#Right AST#expression#Right ?? AST#expression#Left 18 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . lineHeight ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left headerStyle AST#expression#Right ?. lineHeight AST#member_expression#Right AST#expression#Right ?? AST#expression#Left 20 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left headerStyle AST#expression#Right ?. fontWeight AST#member_expression#Right AST#expression#Right ?? AST#expression#Left FontWeight AST#expression#Right AST#binary_expression#Right AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . textOverflow ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left headerStyle AST#expression#Right ?. textOverflow AST#member_expression#Right AST#expression#Right ? 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 headerStyle AST#expression#Right ?. textOverflow AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right : AST#expression#Left undefined AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . maxLines ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left headerStyle AST#expression#Right ?. maxLines AST#member_expression#Right AST#expression#Right ?? AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . ellipsisMode ( AST#expression#Left AST#member_expression#Left AST#expression#Left EllipsisMode AST#expression#Right . END AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . constraintSize ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left minHeight AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left headerStyle AST#expression#Right ?. lineHeight AST#member_expression#Right AST#expression#Right ?? AST#expression#Left 20 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 Blank ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left headerStyle AST#expression#Right ?. lineHeight AST#member_expression#Right AST#expression#Right ?? AST#expression#Left 20 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_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 secondaryButton AST#expression#Right ?. value AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left AST#member_expression#Left AST#expression#Left secondaryButton AST#expression#Right ?. value AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . buttonStyle ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left secondaryButton AST#expression#Right ?. buttonStyle AST#member_expression#Right AST#expression#Right ?? AST#expression#Left ButtonStyleMode AST#expression#Right AST#binary_expression#Right AST#expression#Right . TEXTUAL AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . role ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left secondaryButton AST#expression#Right ?. role AST#member_expression#Right AST#expression#Right ?? AST#expression#Left ButtonRole AST#expression#Right AST#binary_expression#Right AST#expression#Right . NORMAL AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left secondaryButton AST#expression#Right ?. fontSize AST#member_expression#Right AST#expression#Right ?? AST#expression#Left 16 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left secondaryButton AST#expression#Right ?. fontColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left secondaryButton AST#expression#Right ?. fontWeight AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left secondaryButton AST#expression#Right ?. background AST#member_expression#Right AST#expression#Right ?? AST#expression#Left Color AST#expression#Right AST#binary_expression#Right AST#expression#Right . Transparent AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . linearGradient ( AST#expression#Left AST#member_expression#Left AST#expression#Left primaryButton AST#expression#Right ?. linearGradient AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . 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 onBtnClick AST#expression#Right ?. AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right // .height(headerStyle?.height || (headerStyle?.lineHeight ?? 20)) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left headerStyle AST#expression#Right ?. height AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#member_expression#Left AST#expression#Left headerStyle AST#expression#Right ?. padding AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#member_expression#Left AST#expression#Left headerStyle AST#expression#Right ?. margin AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . border ( AST#expression#Left AST#member_expression#Left AST#expression#Left headerStyle AST#expression#Right ?. border AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left headerStyle AST#expression#Right ?. width AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#member_expression#Left AST#expression#Left headerStyle AST#expression#Right ?. borderRadius AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left headerStyle AST#expression#Right ?. background AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#decorated_export_declaration#Right
|
@Builder
export function DialogHeaderBuilder(title: ResourceStr | undefined, headerStyle: ITextStyle | undefined,
primaryButton?: CustomButtonOptions,
secondaryButton?: CustomButtonOptions,
onBtnClick?: (isPrimary: boolean) => void) {
Row() {
if (primaryButton?.value) {
Button(primaryButton?.value)
.buttonStyle(primaryButton?.buttonStyle ?? ButtonStyleMode.TEXTUAL)
.role(primaryButton?.role ?? ButtonRole.NORMAL)
.fontColor(primaryButton?.fontColor)
.fontSize(primaryButton?.fontSize ?? 16)
.fontWeight(primaryButton?.fontWeight)
.backgroundColor(primaryButton?.background ?? Color.Transparent)
.linearGradient(primaryButton?.linearGradient)
.margin({ top: 10, bottom: 10, left: 10 })
.onClick(() => {
onBtnClick?.(true)
})
}
if (title) {
Text(title)
.textAlign(headerStyle?.textAlign ?? TextAlign.Center)
.fontColor(headerStyle?.fontColor)
.fontSize(headerStyle?.fontSize ?? 18)
.lineHeight(headerStyle?.lineHeight ?? 20)
.fontWeight(headerStyle?.fontWeight ?? FontWeight.Medium)
.textOverflow(headerStyle?.textOverflow ? { overflow: headerStyle?.textOverflow } : undefined)
.maxLines(headerStyle?.maxLines ?? 1)
.ellipsisMode(EllipsisMode.END)
.layoutWeight(1)
.constraintSize({ minHeight: headerStyle?.lineHeight ?? 20 })
} else {
Blank().layoutWeight(1)
.height(headerStyle?.lineHeight ?? 20)
}
if (secondaryButton?.value) {
Button(secondaryButton?.value)
.buttonStyle(secondaryButton?.buttonStyle ?? ButtonStyleMode.TEXTUAL)
.role(secondaryButton?.role ?? ButtonRole.NORMAL)
.fontSize(secondaryButton?.fontSize ?? 16)
.fontColor(secondaryButton?.fontColor)
.fontWeight(secondaryButton?.fontWeight)
.backgroundColor(secondaryButton?.background ?? Color.Transparent)
.linearGradient(primaryButton?.linearGradient)
.margin({ top: 10, bottom: 10, right: 10 })
.onClick(() => {
onBtnClick?.(false)
})
}
}
.height(headerStyle?.height)
.padding(headerStyle?.padding)
.margin(headerStyle?.margin)
.border(headerStyle?.border)
.width(headerStyle?.width)
.borderRadius(headerStyle?.borderRadius)
.backgroundColor(headerStyle?.background)
.width('100%')
}
|
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/component/partView/DialogHeaderBuilder.ets#L12-L74
|
f94e1ef22f703477f86ae86d707ffaa685ef42f4
|
github
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/crypto/AES.ets
|
arkts
|
encryptECBSync
|
加密(ECB模式),异步
@param data 加密或者解密的数据。data不能为null。
@param symKey 指定加密或解密的密钥。
@param transformation 待生成Cipher的算法名称(含密钥长度)、加密模式以及填充方法的组合(AES256|ECB|PKCS7、AES192|ECB|PKCS7、AES128|ECB|PKCS7)。
@returns
|
static encryptECBSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey,
transformation: string = 'AES256|ECB|PKCS7'): cryptoFramework.DataBlob {
return AES.encryptSync(data, symKey, null, transformation);
}
|
AST#method_declaration#Left static encryptECBSync AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left symKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . SymKey AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left transformation : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'AES256|ECB|PKCS7' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#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 AES AST#expression#Right . encryptSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right , AST#expression#Left symKey AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right , AST#expression#Left transformation 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 encryptECBSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey,
transformation: string = 'AES256|ECB|PKCS7'): cryptoFramework.DataBlob {
return AES.encryptSync(data, symKey, null, transformation);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/crypto/AES.ets#L175-L178
|
8ff51ec3e7e61df61fb4bc4a453161f1ac621a1e
|
gitee
|
openharmony/developtools_profiler
|
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
|
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/data/BaseEntry.ets
|
arkts
|
getData
|
Returns the data, additional information that this Entry represents, or
null, if no data has been specified.
@return
|
public getData(): Object {
return this.mData;
}
|
AST#method_declaration#Left public getData AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mData AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public getData(): Object {
return this.mData;
}
|
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/data/BaseEntry.ets#L79-L81
|
060fbb27e11a140163ac8cf9d872d87f10bd95c9
|
gitee
|
dou101101/ZenFocus-HarmonyOS.git
|
9364599b8b20bc6377fc55ac68b991b61ceb8496
|
MyApplication/entry/src/main/ets/pages/Index.ets
|
arkts
|
startAmbientAnimations
|
=== 动画系统 ===
|
startAmbientAnimations() {
// 主树的呼吸效果
animateTo({
duration: 3000,
curve: Curve.Smooth,
iterations: -1,
playMode: PlayMode.Alternate
}, () => {
this.breathingScale = 1.05;
});
}
|
AST#method_declaration#Left startAmbientAnimations AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { // 主树的呼吸效果 AST#ui_custom_component_statement#Left animateTo ( AST#ERROR#Left AST#component_parameters#Left { AST#component_parameter#Left duration : AST#expression#Left 3000 AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left curve : AST#expression#Left AST#member_expression#Left AST#expression#Left Curve AST#expression#Right . Smooth AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left iterations : AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left playMode : AST#expression#Left AST#member_expression#Left AST#expression#Left PlayMode AST#expression#Right . Alternate AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right , AST#ERROR#Right AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . breathingScale AST#member_expression#Right = AST#expression#Left 1.05 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#ui_custom_component_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
startAmbientAnimations() {
animateTo({
duration: 3000,
curve: Curve.Smooth,
iterations: -1,
playMode: PlayMode.Alternate
}, () => {
this.breathingScale = 1.05;
});
}
|
https://github.com/dou101101/ZenFocus-HarmonyOS.git/blob/9364599b8b20bc6377fc55ac68b991b61ceb8496/MyApplication/entry/src/main/ets/pages/Index.ets#L210-L220
|
28ec8703575574f425fa2db8bcb84d1f4ac8ef87
|
github
|
wangjinyuan/JS-TS-ArkTS-database.git
|
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
|
npm/alprazolamdiv/11.5.1/package/src/structures/DMChannel.ets
|
arkts
|
setup
|
应用ArkTS约束:添加方法参数类型声明
|
setup(data: unknown): void {
super.setup(data);
if (data.recipients && data.recipients.length > 0) {
this.recipient = this.client.dataManager.newUser(data.recipients[0]);
}
this.lastMessageID = data.last_message_id ?? null;
this.lastPinTimestamp = data.last_pin_timestamp
? new Date(data.last_pin_timestamp).getTime()
: null;
}
|
AST#method_declaration#Left setup AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left unknown AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 super AST#expression#Right . setup AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . recipients AST#member_expression#Right AST#expression#Right && AST#expression#Left data AST#expression#Right AST#binary_expression#Right AST#expression#Right . recipients AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . recipient 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 . client AST#member_expression#Right AST#expression#Right . dataManager AST#member_expression#Right AST#expression#Right . newUser AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . recipients AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . lastMessageID AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . last_message_id AST#member_expression#Right AST#expression#Right ?? AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#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 . lastPinTimestamp AST#member_expression#Right = AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . last_pin_timestamp AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . last_pin_timestamp AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getTime AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
setup(data: unknown): void {
super.setup(data);
if (data.recipients && data.recipients.length > 0) {
this.recipient = this.client.dataManager.newUser(data.recipients[0]);
}
this.lastMessageID = data.last_message_id ?? null;
this.lastPinTimestamp = data.last_pin_timestamp
? new Date(data.last_pin_timestamp).getTime()
: null;
}
|
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/structures/DMChannel.ets#L24-L35
|
0b4d16b1c3c5e0d704bd1e098dce300565f3f71e
|
github
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
ArkUI/StateManagement/entry/src/main/ets/segment/segment6.ets
|
arkts
|
Segment06Builder
|
Copyright (c) 2025 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
@Builder
export function Segment06Builder() {
NavDestination(){
UserInfoView()
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function Segment06Builder 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 NavDestination ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left UserInfoView ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#decorated_export_declaration#Right
|
@Builder
export function Segment06Builder() {
NavDestination(){
UserInfoView()
}
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ArkUI/StateManagement/entry/src/main/ets/segment/segment6.ets#L15-L20
|
c8c230ddb4d3df998877788c862e959c0d981b9e
|
gitee
|
wustcat404/time-bar
|
d876c3b10aa2538ee2ea0201b9a6fbaad9b693c8
|
entry/src/main/ets/model/VideoInfo.ets
|
arkts
|
Strongly-typed metadata of a single video segment.
|
export class VideoInfo {
/** Index of the video (0-based). */
index: number = -1;
/** Video source URL. */
videoSrc: string = '';
/** Video start time in ISO 8601 (if available from metadata). */
startTime: string = '';
/** Video end time in ISO 8601 (if available from metadata). */
endTime: string = '';
/** Video duration in milliseconds (as string to align with extractor). */
duration: string = '0';
/** Optional genre/type. */
genre: string = '';
/** Optional title. */
title: string = '';
/** Video height in pixels (string form for consistency). */
videoHeight: string = '0';
/** Video width in pixels (string form for consistency). */
videoWidth: string = '0';
/** Video rotation angle in degrees. */
videoOrientation: string = '0';
}
|
AST#export_declaration#Left export AST#class_declaration#Left class VideoInfo AST#class_body#Left { /** Index of the video (0-based). */ AST#property_declaration#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right ; AST#property_declaration#Right /** Video source URL. */ AST#property_declaration#Left videoSrc : 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 /** Video start time in ISO 8601 (if available from metadata). */ AST#property_declaration#Left startTime : 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 /** Video end time in ISO 8601 (if available from metadata). */ AST#property_declaration#Left endTime : 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 /** Video duration in milliseconds (as string to align with extractor). */ AST#property_declaration#Left duration : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '0' AST#expression#Right ; AST#property_declaration#Right /** Optional genre/type. */ AST#property_declaration#Left genre : 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 /** Optional title. */ AST#property_declaration#Left title : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right ; AST#property_declaration#Right /** Video height in pixels (string form for consistency). */ AST#property_declaration#Left videoHeight : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '0' AST#expression#Right ; AST#property_declaration#Right /** Video width in pixels (string form for consistency). */ AST#property_declaration#Left videoWidth : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '0' AST#expression#Right ; AST#property_declaration#Right /** Video rotation angle in degrees. */ AST#property_declaration#Left videoOrientation : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '0' AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class VideoInfo {
index: number = -1;
videoSrc: string = '';
startTime: string = '';
endTime: string = '';
duration: string = '0';
genre: string = '';
title: string = '';
videoHeight: string = '0';
videoWidth: string = '0';
videoOrientation: string = '0';
}
|
https://github.com/wustcat404/time-bar/blob/d876c3b10aa2538ee2ea0201b9a6fbaad9b693c8/entry/src/main/ets/model/VideoInfo.ets#L18-L39
|
93521c30c87d7fb13a70200401913cd644459d91
|
gitee
|
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_dialog/src/main/ets/dialog/DialogHelper.ets
|
arkts
|
showTextPickerDialog
|
显示选择器弹框;入参参考TextPicker组件
@param options
@returns
|
static showTextPickerDialog(options: TextPickerOptions): string {
ActionParameter.initBaseDefault(options);
ActionParameter.initTextPickerDefault(options);
const dialogId = ActionBaseCore.getInstance().openCustomDialog(wrapBuilder(TextPickerDialogBuilder), options);
return dialogId;
}
|
AST#method_declaration#Left static showTextPickerDialog AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left TextPickerOptions 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ActionParameter AST#expression#Right . initBaseDefault AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left options AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ActionParameter AST#expression#Right . initTextPickerDefault AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left options AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left const AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left dialogId = 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 ActionBaseCore AST#expression#Right . getInstance AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . openCustomDialog AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left wrapBuilder AST#expression#Right AST#argument_list#Left ( AST#expression#Left TextPickerDialogBuilder AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left options AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left dialogId AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
static showTextPickerDialog(options: TextPickerOptions): string {
ActionParameter.initBaseDefault(options);
ActionParameter.initTextPickerDefault(options);
const dialogId = ActionBaseCore.getInstance().openCustomDialog(wrapBuilder(TextPickerDialogBuilder), options);
return dialogId;
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_dialog/src/main/ets/dialog/DialogHelper.ets#L258-L263
|
0c0822f0806a8b59276590326c3101f21a2b86ed
|
gitee
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Media/ImageEdit/entry/src/main/ets/viewModel/Rect.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 RectF {
/**
* Rect left edge.
*/
left: number;
/**
* Rect top edge.
*/
top: number;
/**
* Rect right edge.
*/
right: number;
/**
* Rect bottom edge.
*/
bottom: number;
/**
* Constructor.
*/
constructor() {
this.left = 0;
this.top = 0;
this.right = 0;
this.bottom = 0;
}
/**
* Set value.
* @param left
* @param top
* @param right
* @param bottom
*/
set(left: number, top: number, right: number, bottom: number): void {
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}
/**
* Get width.
* @returns
*/
getWidth(): number {
return (this.right - this.left);
}
/**
* Get height.
* @returns
*/
getHeight(): number {
return (this.bottom - this.top);
}
/**
* Get diagonal.
* @returns
*/
getDiagonal(): number {
return Math.hypot(this.getWidth(), this.getHeight());
}
/**
* Get the center point of x.
* @returns
*/
getCenterX(): number {
return (this.left + this.getWidth() / 2);
}
/**
* Get the center point of y.
* @returns
*/
getCenterY(): number {
return (this.top + this.getHeight() / 2);
}
/**
* Determine whether it is within the rectangle.
* @param x
* @param y
* @returns
*/
isInRect(x: number, y: number): boolean {
return (x >= this.left && x <= this.right && y >= this.top && y <= this.bottom);
}
/**
* Set zoom factor.
* @param scale
*/
scale(scale: number): void {
this.left *= scale;
this.right *= scale;
this.top *= scale;
this.bottom *= scale;
}
/**
* Move by current offset.
* @param offsetX
* @param offsetY
*/
move(offsetX: number, offsetY: number): void {
this.left += offsetX;
this.right += offsetX;
this.top += offsetY;
this.bottom += offsetY;
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class RectF AST#class_body#Left { /**
* Rect left edge.
*/ AST#property_declaration#Left left : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Rect top edge.
*/ AST#property_declaration#Left top : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Rect right edge.
*/ AST#property_declaration#Left right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Rect bottom edge.
*/ AST#property_declaration#Left bottom : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Constructor.
*/ AST#constructor_declaration#Left constructor AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . left 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#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . top 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#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . right 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#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bottom 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#constructor_declaration#Right /**
* Set value.
* @param left
* @param top
* @param right
* @param bottom
*/ AST#method_declaration#Left set AST#parameter_list#Left ( AST#parameter#Left left : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left top : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left bottom : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . left AST#member_expression#Right = AST#expression#Left left 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 . top AST#member_expression#Right = AST#expression#Left top 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 . right AST#member_expression#Right = AST#expression#Left 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 . bottom AST#member_expression#Right = AST#expression#Left bottom AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* Get width.
* @returns
*/ AST#method_declaration#Left getWidth 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#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 . right AST#member_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . left AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* Get height.
* @returns
*/ AST#method_declaration#Left getHeight 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#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 . bottom AST#member_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . top AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* Get diagonal.
* @returns
*/ AST#method_declaration#Left getDiagonal AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . hypot AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getWidth 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 this AST#expression#Right . getHeight 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* Get the center point of x.
* @returns
*/ AST#method_declaration#Left getCenterX 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#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . left AST#member_expression#Right AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . getWidth AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right / AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* Get the center point of y.
* @returns
*/ AST#method_declaration#Left getCenterY 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#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . top AST#member_expression#Right AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . getHeight AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right / AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* Determine whether it is within the rectangle.
* @param x
* @param y
* @returns
*/ AST#method_declaration#Left isInRect AST#parameter_list#Left ( AST#parameter#Left x : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left y : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left x AST#expression#Right >= AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . left AST#member_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left x AST#expression#Right <= AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . right AST#member_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left y AST#expression#Right >= AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . top AST#member_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left y AST#expression#Right <= AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . bottom AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* Set zoom factor.
* @param scale
*/ AST#method_declaration#Left scale AST#parameter_list#Left ( AST#parameter#Left scale : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#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 . left AST#member_expression#Right *= AST#expression#Left scale 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 . right AST#member_expression#Right *= AST#expression#Left scale 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 . top AST#member_expression#Right *= AST#expression#Left scale 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 . bottom AST#member_expression#Right *= AST#expression#Left scale AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* Move by current offset.
* @param offsetX
* @param offsetY
*/ AST#method_declaration#Left move AST#parameter_list#Left ( AST#parameter#Left offsetX : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left offsetY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . left AST#member_expression#Right += AST#expression#Left offsetX 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 . right AST#member_expression#Right += AST#expression#Left offsetX 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 . top AST#member_expression#Right += AST#expression#Left offsetY 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 . bottom AST#member_expression#Right += AST#expression#Left offsetY AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class RectF {
left: number;
top: number;
right: number;
bottom: number;
constructor() {
this.left = 0;
this.top = 0;
this.right = 0;
this.bottom = 0;
}
set(left: number, top: number, right: number, bottom: number): void {
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}
getWidth(): number {
return (this.right - this.left);
}
getHeight(): number {
return (this.bottom - this.top);
}
getDiagonal(): number {
return Math.hypot(this.getWidth(), this.getHeight());
}
getCenterX(): number {
return (this.left + this.getWidth() / 2);
}
getCenterY(): number {
return (this.top + this.getHeight() / 2);
}
isInRect(x: number, y: number): boolean {
return (x >= this.left && x <= this.right && y >= this.top && y <= this.bottom);
}
scale(scale: number): void {
this.left *= scale;
this.right *= scale;
this.top *= scale;
this.bottom *= scale;
}
move(offsetX: number, offsetY: number): void {
this.left += offsetX;
this.right += offsetX;
this.top += offsetY;
this.bottom += offsetY;
}
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Media/ImageEdit/entry/src/main/ets/viewModel/Rect.ets#L17-L134
|
ab86c9ce3baaaead6003bccaaa2b19df9f0a0b86
|
gitee
|
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
ArkWebrenderingframework/entry/src/main/ets/pages/proxy.ets
|
arkts
|
nativeCall
|
[Start call]
|
nativeCall(channelType: string, object: string) {
let objectJson = JSON.stringify(object);
let resultJson :string= window.JSBridge && window.JSBridge.nativeMethod(channelType, objectJson);
return resultJson && JSON.parse(resultJson);
}
|
AST#method_declaration#Left nativeCall AST#parameter_list#Left ( AST#parameter#Left channelType : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left object : 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 objectJson = 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 object 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 resultJson : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . JSBridge AST#member_expression#Right AST#expression#Right && AST#expression#Left window AST#expression#Right AST#binary_expression#Right AST#expression#Right . JSBridge AST#member_expression#Right AST#expression#Right . nativeMethod AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left channelType AST#expression#Right , AST#expression#Left objectJson AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left resultJson AST#expression#Right && AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left resultJson 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
|
nativeCall(channelType: string, object: string) {
let objectJson = JSON.stringify(object);
let resultJson :string= window.JSBridge && window.JSBridge.nativeMethod(channelType, objectJson);
return resultJson && JSON.parse(resultJson);
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ArkWebrenderingframework/entry/src/main/ets/pages/proxy.ets#L103-L107
|
ca84dc1fd491e002a0371d80a5b18cbe2f1696a2
|
gitee
|
liuchao0739/arkTS_universal_starter.git
|
0ca845f5ae0e78db439dc09f712d100c0dd46ed3
|
entry/src/main/ets/utils/EncryptUtils.ets
|
arkts
|
md5
|
MD5 哈希(简化实现)
注意:实际项目中应使用更安全的哈希算法
|
static async md5(text: string): Promise<string> {
try {
// 实际实现需要使用 cryptoFramework
// 这里提供接口定义
return `md5_${text}`;
} catch (error) {
return '';
}
}
|
AST#method_declaration#Left static async md5 AST#parameter_list#Left ( AST#parameter#Left text : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#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#try_statement#Left try AST#block_statement#Left { // 实际实现需要使用 cryptoFramework // 这里提供接口定义 AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#template_literal#Left ` md5_ AST#template_substitution#Left $ { AST#expression#Left text 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#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left '' AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static async md5(text: string): Promise<string> {
try {
return `md5_${text}`;
} catch (error) {
return '';
}
}
|
https://github.com/liuchao0739/arkTS_universal_starter.git/blob/0ca845f5ae0e78db439dc09f712d100c0dd46ed3/entry/src/main/ets/utils/EncryptUtils.ets#L12-L20
|
ae25714343f55c39b0d0dab4cccf5127b9c881c8
|
github
|
openharmony/developtools_profiler
|
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
|
host/smartperf/client/client_ui/entry/src/main/ets/pages/TitleWindowPage.ets
|
arkts
|
subscribeCallBack
|
订阅公共事件回调
|
function subscribeCallBack(err, data) {
if (data.data == '') {
} else {
console.error('subscriberCurData:' + data.data);
that.tIndexInfo = JSON.parse(data.data)
globalThis.cpu0Frequency = that.tIndexInfo.cpu0Frequency
globalThis.cpu1Frequency = that.tIndexInfo.cpu1Frequency
globalThis.cpu2Frequency = that.tIndexInfo.cpu2Frequency
if (that.tIndexInfo.cpu4Frequency != undefined && that.tIndexInfo.cpu7Frequency != undefined) {
globalThis.cpu1Frequency = that.tIndexInfo.cpu4Frequency
globalThis.cpu2Frequency = that.tIndexInfo.cpu7Frequency
that.tIndexInfo.cpu1Frequency = that.tIndexInfo.cpu4Frequency
that.tIndexInfo.cpu2Frequency = that.tIndexInfo.cpu7Frequency
that.tIndexInfo.cpu1Load = that.tIndexInfo.cpu1Load
that.tIndexInfo.cpu2Load = that.tIndexInfo.cpu2Load
}
globalThis.currentNow = that.tIndexInfo.currentNow
globalThis.ddrFrequency = that.tIndexInfo.ddrFrequency
globalThis.lineFps = that.tIndexInfo.fps
globalThis.gpuFrequency = that.tIndexInfo.gpuFrequency
globalThis.pss = that.tIndexInfo.pss
globalThis.shellBackTemp = that.tIndexInfo.shellFrameTemp
}
}
|
AST#function_declaration#Left function subscribeCallBack 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . data AST#member_expression#Right AST#expression#Right == AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { } 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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'subscriberCurData:' AST#expression#Right + AST#expression#Left data AST#expression#Right AST#binary_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#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 that AST#expression#Right . tIndexInfo AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . data AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left globalThis AST#expression#Right . cpu0Frequency AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . cpu0Frequency 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 globalThis AST#expression#Right . cpu1Frequency AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . cpu1Frequency 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 globalThis AST#expression#Right . cpu2Frequency AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . cpu2Frequency AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . cpu4Frequency AST#member_expression#Right AST#expression#Right != AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left that AST#expression#Right AST#binary_expression#Right AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . cpu7Frequency AST#member_expression#Right AST#expression#Right != AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left globalThis AST#expression#Right . cpu1Frequency AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . cpu4Frequency 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 globalThis AST#expression#Right . cpu2Frequency AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . cpu7Frequency AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . cpu1Frequency AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . cpu4Frequency AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . cpu2Frequency AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . cpu7Frequency AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . cpu1Load AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . cpu1Load AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . cpu2Load AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . cpu2Load AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left globalThis AST#expression#Right . currentNow AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . currentNow 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 globalThis AST#expression#Right . ddrFrequency AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . ddrFrequency 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 globalThis AST#expression#Right . lineFps AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . fps 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 globalThis AST#expression#Right . gpuFrequency AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . gpuFrequency 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 globalThis AST#expression#Right . pss AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . pss 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 globalThis AST#expression#Right . shellBackTemp AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . tIndexInfo AST#member_expression#Right AST#expression#Right . shellFrameTemp 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#function_declaration#Right
|
function subscribeCallBack(err, data) {
if (data.data == '') {
} else {
console.error('subscriberCurData:' + data.data);
that.tIndexInfo = JSON.parse(data.data)
globalThis.cpu0Frequency = that.tIndexInfo.cpu0Frequency
globalThis.cpu1Frequency = that.tIndexInfo.cpu1Frequency
globalThis.cpu2Frequency = that.tIndexInfo.cpu2Frequency
if (that.tIndexInfo.cpu4Frequency != undefined && that.tIndexInfo.cpu7Frequency != undefined) {
globalThis.cpu1Frequency = that.tIndexInfo.cpu4Frequency
globalThis.cpu2Frequency = that.tIndexInfo.cpu7Frequency
that.tIndexInfo.cpu1Frequency = that.tIndexInfo.cpu4Frequency
that.tIndexInfo.cpu2Frequency = that.tIndexInfo.cpu7Frequency
that.tIndexInfo.cpu1Load = that.tIndexInfo.cpu1Load
that.tIndexInfo.cpu2Load = that.tIndexInfo.cpu2Load
}
globalThis.currentNow = that.tIndexInfo.currentNow
globalThis.ddrFrequency = that.tIndexInfo.ddrFrequency
globalThis.lineFps = that.tIndexInfo.fps
globalThis.gpuFrequency = that.tIndexInfo.gpuFrequency
globalThis.pss = that.tIndexInfo.pss
globalThis.shellBackTemp = that.tIndexInfo.shellFrameTemp
}
}
|
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/pages/TitleWindowPage.ets#L65-L91
|
9bce3fddd81b7a96d07602e1a4f5e3f1afe08a9d
|
gitee
|
Piagari/arkts_example.git
|
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
|
hmos_app-main/hmos_app-main/coolmall-master/entry/src/main/ets/pages/MePage.ets
|
arkts
|
OrderSection
|
订单管理
|
@Builder
OrderSection() {
Column() {
Column({ space: AppDimensions.spaceMedium }) {
// 标题行
Row() {
Row({ space: AppDimensions.spaceSmall }) {
Text('📋')
.fontSize(18)
Text('我的订单')
.fontSize(AppTypography.fontSizeLarge)
.fontWeight(AppTypography.fontWeightMedium)
.fontColor(AppColors.textPrimary)
}
Blank()
Row({ space: AppDimensions.spaceXSmall }) {
Text('查看全部')
.fontSize(AppTypography.fontSizeMedium)
.fontColor(AppColors.textSecondary)
Text('›')
.fontSize(20)
.fontColor(AppColors.textTertiary)
}
}
.width('100%')
// 订单状态图标
Row() {
this.OrderStatusItem('待付款', '💳', this.orderCount.pendingPayment)
this.OrderStatusItem('待发货', '📦', this.orderCount.pendingShipment)
this.OrderStatusItem('待收货', '🚚', this.orderCount.pendingReceive)
this.OrderStatusItem('待评价', '💬', this.orderCount.pendingReview)
this.OrderStatusItem('退款/售后', '↩️', this.orderCount.refunding + this.orderCount.refunded)
}
.width('100%')
.justifyContent(FlexAlign.SpaceAround)
}
}
.width('100%')
.backgroundColor(AppColors.surface)
.borderRadius(AppDimensions.radiusMedium)
.padding(AppDimensions.paddingLarge)
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right OrderSection AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left AST#member_expression#Left AST#expression#Left AppDimensions AST#expression#Right . spaceMedium 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 Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left AST#member_expression#Left AST#expression#Left AppDimensions AST#expression#Right . spaceSmall 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 18 AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '我的订单' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left AppTypography AST#expression#Right . fontSizeLarge AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left AppTypography AST#expression#Right . fontWeightMedium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AppColors AST#expression#Right . textPrimary 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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Blank ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left AST#member_expression#Left AST#expression#Left AppDimensions AST#expression#Right . spaceXSmall 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 AppTypography AST#expression#Right . fontSizeMedium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AppColors AST#expression#Right . textSecondary AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '›' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AppColors AST#expression#Right . textTertiary AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 订单状态图标 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . OrderStatusItem AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '待付款' AST#expression#Right , AST#expression#Left '💳' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . orderCount AST#member_expression#Right AST#expression#Right . pendingPayment AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . OrderStatusItem AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '待发货' AST#expression#Right , AST#expression#Left '📦' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . orderCount AST#member_expression#Right AST#expression#Right . pendingShipment AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . OrderStatusItem AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '待收货' AST#expression#Right , AST#expression#Left '🚚' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . orderCount AST#member_expression#Right AST#expression#Right . pendingReceive AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . OrderStatusItem AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '待评价' AST#expression#Right , AST#expression#Left '💬' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . orderCount AST#member_expression#Right AST#expression#Right . pendingReview AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . OrderStatusItem AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '退款/售后' AST#expression#Right , AST#expression#Left '↩️' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . orderCount AST#member_expression#Right AST#expression#Right . refunding AST#member_expression#Right AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . orderCount AST#member_expression#Right AST#expression#Right . refunded AST#member_expression#Right 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 . 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#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 . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AppColors AST#expression#Right . surface AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#member_expression#Left AST#expression#Left AppDimensions AST#expression#Right . radiusMedium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#member_expression#Left AST#expression#Left AppDimensions AST#expression#Right . paddingLarge AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
OrderSection() {
Column() {
Column({ space: AppDimensions.spaceMedium }) {
Row() {
Row({ space: AppDimensions.spaceSmall }) {
Text('📋')
.fontSize(18)
Text('我的订单')
.fontSize(AppTypography.fontSizeLarge)
.fontWeight(AppTypography.fontWeightMedium)
.fontColor(AppColors.textPrimary)
}
Blank()
Row({ space: AppDimensions.spaceXSmall }) {
Text('查看全部')
.fontSize(AppTypography.fontSizeMedium)
.fontColor(AppColors.textSecondary)
Text('›')
.fontSize(20)
.fontColor(AppColors.textTertiary)
}
}
.width('100%')
Row() {
this.OrderStatusItem('待付款', '💳', this.orderCount.pendingPayment)
this.OrderStatusItem('待发货', '📦', this.orderCount.pendingShipment)
this.OrderStatusItem('待收货', '🚚', this.orderCount.pendingReceive)
this.OrderStatusItem('待评价', '💬', this.orderCount.pendingReview)
this.OrderStatusItem('退款/售后', '↩️', this.orderCount.refunding + this.orderCount.refunded)
}
.width('100%')
.justifyContent(FlexAlign.SpaceAround)
}
}
.width('100%')
.backgroundColor(AppColors.surface)
.borderRadius(AppDimensions.radiusMedium)
.padding(AppDimensions.paddingLarge)
}
|
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/coolmall-master/entry/src/main/ets/pages/MePage.ets#L124-L170
|
a5dcd21b330de07fce56282e30bd8e89359931b1
|
github
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/common/utils/ZipTool.ets
|
arkts
|
ZIP 压缩解压工具类
使用 @ohos.zlib 实现沙箱目录下的文件压缩与解压
|
export class ZipTool {
// MARK: - 压缩目录
static async createOneZip(
srcPath: string,
options?: zlib.Options
): Promise<string | null> {
// 确保目标路径存在且为文件或文件夹
if (!FileUtility.isFileExistAt(srcPath)) {
return null
}
// 目标zip文件路径
const zipPath = `${FileUtility.normalizePath(srcPath)}.zip`
// 删除已存在的zip文件
FileUtility.deleteFileAt(zipPath)
if (await ZipTool.compressDir(srcPath, zipPath, options)) {
return zipPath
}else {
return null
}
}
/**
* 压缩指定目录
* @param sourceDir 源目录路径(沙箱路径)
* @param destZip 目标ZIP文件路径(沙箱路径)
* @param options 压缩选项(可选)
* @returns Promise<boolean> 操作是否成功
*/
static async compressDir(
sourceDir: string,
destZip: string,
options?: zlib.Options
): Promise<boolean> {
try {
// 1. 验证源目录是否存在
if (!fs.accessSync(sourceDir)) {
//throw new Error(`Source directory not found: ${sourceDir}`);
DebugLog.e(`Source directory not found: ${sourceDir}`)
return false
}
const srcFolderName = PathUtility.getLastComponentName(sourceDir)
const srcParentFolder = FileUtility.deleteLastPathComponent(sourceDir)
const srcWrapperDir = FileUtility.appendPathComponent(srcParentFolder, `${srcFolderName}_wrapper`)
const srcWrappedPath = FileUtility.appendPathComponent(srcWrapperDir, srcFolderName)
createFolderIfNeeds(srcWrapperDir)
await FileUtility.copyFolder(sourceDir, srcWrappedPath)
// 2. 设置默认压缩参数[1,4](@ref)
const compressOptions: zlib.Options = options || {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION,
memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT,
strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
};
// 3. 执行压缩(异步Promise方案)[1,6](@ref)
await zlib.compressFile(srcWrapperDir, destZip, compressOptions);
//删除Wrapper
FileUtility.deleteDirectoryAt(srcWrapperDir)
return true;
} catch (err) {
const error = err as BusinessError;
console.error(`压缩失败: [${error.code}] ${error.message}`);
return false;
}
}
// MARK: - 解压文件
static async unzip(zipFile: string): Promise<string|null> {
// 目标解压目录
const parentFolder = FileUtility.deleteLastPathComponent(zipFile)
const unZipFolder = FileUtility.appendPathComponent(parentFolder, "_unzip")
return ZipTool.unzipTo(zipFile, unZipFolder)
// 删除已存在的解压目录
// FileUtility.deleteFileAt(unZipFolder)
// if (await ZipTool.decompress(zipFile, unZipFolder)) {
// return unZipFolder
// }else{
// return null
// }
}
///解压文件 到指定 目录
static async unzipTo(zipFile: string, unZipFolder: string): Promise<string | null> {
// 删除已存在的解压目录
FileUtility.deleteFileAt(unZipFolder)
if (await ZipTool.decompress(zipFile, unZipFolder)) {
return unZipFolder
} else {
return null
}
}
/**
* 解压ZIP文件到指定目录
* @param zipFile ZIP文件路径(沙箱路径)
* @param destDir 目标目录路径(沙箱路径)
* @returns Promise<boolean> 操作是否成功
*/
static async decompress(
zipFile: string,
destDir: string
): Promise<boolean> {
try {
// 1. 验证ZIP文件是否存在[1](@ref)
if (!fs.accessSync(zipFile)) {
throw new Error(`ZIP file not found: ${zipFile}`);
}
// 2. 创建目标目录(如果不存在)[2](@ref)
if (!fs.accessSync(destDir)) {
fs.mkdirSync(destDir, true);
}
// 3. 执行解压(无配置参数方案)[1,7](@ref)
await zlib.decompressFile(zipFile, destDir);
return true;
} catch (err) {
const error = err as BusinessError;
console.error(`解压失败: [${error.code}] ${error.message}`);
return false;
}
}
// // MARK: - 工具方法
// /**
// * 获取应用沙箱路径(Stage模型)
// * @returns 沙箱根目录路径
// */
// static getSandboxPath(): string {
// const context = getContext() as common.UIAbilityContext;
// return context.filesDir;
// }
}
|
AST#export_declaration#Left export AST#class_declaration#Left class ZipTool AST#class_body#Left { // MARK: - 压缩目录 AST#method_declaration#Left static async createOneZip AST#parameter_list#Left ( AST#parameter#Left srcPath : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left options ? : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left zlib . Options 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#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 确保目标路径存在且为文件或文件夹 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left FileUtility AST#expression#Right AST#unary_expression#Right AST#expression#Right . isFileExistAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcPath AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 目标zip文件路径 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left zipPath = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtility AST#expression#Right . normalizePath AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcPath AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right .zip ` AST#template_literal#Right AST#expression#Right // 删除已存在的zip文件 AST#ERROR#Left FileUtility AST#ERROR#Right . deleteFileAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left zipPath AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left ZipTool AST#expression#Right AST#await_expression#Right AST#expression#Right . compressDir AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcPath AST#expression#Right , AST#expression#Left zipPath AST#expression#Right , AST#expression#Left options AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left zipPath AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 压缩指定目录
* @param sourceDir 源目录路径(沙箱路径)
* @param destZip 目标ZIP文件路径(沙箱路径)
* @param options 压缩选项(可选)
* @returns Promise<boolean> 操作是否成功
*/ AST#method_declaration#Left static async compressDir AST#parameter_list#Left ( AST#parameter#Left sourceDir : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left destZip : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left options ? : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left zlib . Options AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 1. 验证源目录是否存在 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left fs AST#expression#Right AST#unary_expression#Right AST#expression#Right . accessSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sourceDir AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { //throw new Error(`Source directory not found: ${sourceDir}`); 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 ` Source directory not found: AST#template_substitution#Left $ { AST#expression#Left sourceDir AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left srcFolderName = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PathUtility AST#expression#Right . getLastComponentName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sourceDir 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 srcParentFolder = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtility AST#expression#Right . deleteLastPathComponent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sourceDir 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 srcWrapperDir = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtility AST#expression#Right . appendPathComponent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcParentFolder AST#expression#Right , AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left srcFolderName AST#expression#Right } AST#template_substitution#Right _wrapper ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left srcWrappedPath = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtility AST#expression#Right . appendPathComponent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcWrapperDir AST#expression#Right , AST#expression#Left srcFolderName AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left createFolderIfNeeds AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left srcWrapperDir AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left FileUtility AST#expression#Right AST#await_expression#Right AST#expression#Right . copyFolder AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sourceDir AST#expression#Right , AST#expression#Left srcWrappedPath AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // 2. 设置默认压缩参数[1,4](@ref) AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left compressOptions : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left zlib . Options AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left options AST#expression#Right || AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left level AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left zlib AST#expression#Right . CompressLevel AST#member_expression#Right AST#expression#Right . COMPRESS_LEVEL_DEFAULT_COMPRESSION AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left memLevel AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left zlib AST#expression#Right . MemLevel AST#member_expression#Right AST#expression#Right . MEM_LEVEL_DEFAULT AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left strategy AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left zlib AST#expression#Right . CompressStrategy AST#member_expression#Right AST#expression#Right . COMPRESS_STRATEGY_DEFAULT_STRATEGY AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 3. 执行压缩(异步Promise方案)[1,6](@ref) 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 zlib AST#expression#Right AST#await_expression#Right AST#expression#Right . compressFile AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcWrapperDir AST#expression#Right , AST#expression#Left destZip AST#expression#Right , AST#expression#Left compressOptions AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //删除Wrapper AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtility AST#expression#Right . deleteDirectoryAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcWrapperDir AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left error = AST#expression#Left AST#as_expression#Left AST#expression#Left err AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 压缩失败: [ AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ] AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // MARK: - 解压文件 AST#method_declaration#Left static async unzip AST#parameter_list#Left ( AST#parameter#Left zipFile : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 目标解压目录 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left parentFolder = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtility AST#expression#Right . deleteLastPathComponent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left zipFile 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 unZipFolder = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtility AST#expression#Right . appendPathComponent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left parentFolder AST#expression#Right , AST#expression#Left "_unzip" 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 ZipTool AST#expression#Right . unzipTo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left zipFile AST#expression#Right , AST#expression#Left unZipFolder AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right // 删除已存在的解压目录 // FileUtility.deleteFileAt(unZipFolder) // if (await ZipTool.decompress(zipFile, unZipFolder)) { // return unZipFolder // }else{ // return null // } AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right ///解压文件 到指定 目录 AST#method_declaration#Left static async unzipTo AST#parameter_list#Left ( AST#parameter#Left zipFile : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left unZipFolder : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#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 FileUtility AST#expression#Right . deleteFileAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left unZipFolder AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left ZipTool AST#expression#Right AST#await_expression#Right AST#expression#Right . decompress AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left zipFile AST#expression#Right , AST#expression#Left unZipFolder AST#expression#Right ) AST#argument_list#Right AST#call_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 unZipFolder 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#null_literal#Left null AST#null_literal#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 /**
* 解压ZIP文件到指定目录
* @param zipFile ZIP文件路径(沙箱路径)
* @param destDir 目标目录路径(沙箱路径)
* @returns Promise<boolean> 操作是否成功
*/ AST#method_declaration#Left static async decompress AST#parameter_list#Left ( AST#parameter#Left zipFile : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left destDir : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 1. 验证ZIP文件是否存在[1](@ref) AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left fs AST#expression#Right AST#unary_expression#Right AST#expression#Right . accessSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left zipFile AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#throw_statement#Left throw AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` ZIP file not found: AST#template_substitution#Left $ { AST#expression#Left zipFile AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#throw_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 2. 创建目标目录(如果不存在)[2](@ref) AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left fs AST#expression#Right AST#unary_expression#Right AST#expression#Right . accessSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left destDir AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fs AST#expression#Right . mkdirSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left destDir AST#expression#Right , AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 3. 执行解压(无配置参数方案)[1,7](@ref) 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 zlib AST#expression#Right AST#await_expression#Right AST#expression#Right . decompressFile AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left zipFile AST#expression#Right , AST#expression#Left destDir AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left error = AST#expression#Left AST#as_expression#Left AST#expression#Left err AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 解压失败: [ AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ] AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // // MARK: - 工具方法 // /** // * 获取应用沙箱路径(Stage模型) // * @returns 沙箱根目录路径 // */ // static getSandboxPath(): string { // const context = getContext() as common.UIAbilityContext; // return context.filesDir; // } } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class ZipTool {
static async createOneZip(
srcPath: string,
options?: zlib.Options
): Promise<string | null> {
if (!FileUtility.isFileExistAt(srcPath)) {
return null
}
const zipPath = `${FileUtility.normalizePath(srcPath)}.zip`
FileUtility.deleteFileAt(zipPath)
if (await ZipTool.compressDir(srcPath, zipPath, options)) {
return zipPath
}else {
return null
}
}
static async compressDir(
sourceDir: string,
destZip: string,
options?: zlib.Options
): Promise<boolean> {
try {
if (!fs.accessSync(sourceDir)) {
DebugLog.e(`Source directory not found: ${sourceDir}`)
return false
}
const srcFolderName = PathUtility.getLastComponentName(sourceDir)
const srcParentFolder = FileUtility.deleteLastPathComponent(sourceDir)
const srcWrapperDir = FileUtility.appendPathComponent(srcParentFolder, `${srcFolderName}_wrapper`)
const srcWrappedPath = FileUtility.appendPathComponent(srcWrapperDir, srcFolderName)
createFolderIfNeeds(srcWrapperDir)
await FileUtility.copyFolder(sourceDir, srcWrappedPath)
const compressOptions: zlib.Options = options || {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION,
memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT,
strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
};
await zlib.compressFile(srcWrapperDir, destZip, compressOptions);
FileUtility.deleteDirectoryAt(srcWrapperDir)
return true;
} catch (err) {
const error = err as BusinessError;
console.error(`压缩失败: [${error.code}] ${error.message}`);
return false;
}
}
static async unzip(zipFile: string): Promise<string|null> {
const parentFolder = FileUtility.deleteLastPathComponent(zipFile)
const unZipFolder = FileUtility.appendPathComponent(parentFolder, "_unzip")
return ZipTool.unzipTo(zipFile, unZipFolder)
}
static async unzipTo(zipFile: string, unZipFolder: string): Promise<string | null> {
FileUtility.deleteFileAt(unZipFolder)
if (await ZipTool.decompress(zipFile, unZipFolder)) {
return unZipFolder
} else {
return null
}
}
static async decompress(
zipFile: string,
destDir: string
): Promise<boolean> {
try {
if (!fs.accessSync(zipFile)) {
throw new Error(`ZIP file not found: ${zipFile}`);
}
if (!fs.accessSync(destDir)) {
fs.mkdirSync(destDir, true);
}
await zlib.decompressFile(zipFile, destDir);
return true;
} catch (err) {
const error = err as BusinessError;
console.error(`解压失败: [${error.code}] ${error.message}`);
return false;
}
}
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/utils/ZipTool.ets#L18-L168
|
bb4791417528f2b015c7c38ecfc8999a35f4e991
|
github
|
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/bottomdrawerslidecase/src/main/ets/utils/dataSource.ets
|
arkts
|
唯一id
|
constructor(id: string) {
this.id = id;
}
|
AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left id : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . id AST#member_expression#Right = AST#expression#Left id AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right
|
constructor(id: string) {
this.id = id;
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/bottomdrawerslidecase/src/main/ets/utils/dataSource.ets#L5-L7
|
a1c830951f180a2f9e169c22030d0bbce1ea61b9
|
gitee
|
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
ef_crypto/src/main/ets/crypto/encryption/MD5.ets
|
arkts
|
hash
|
散列哈希算法
@param value 待处理字符
@param enCoding 编码格式hex/base64
@returns
|
static hash(value: string, enCoding?: string): string {
let md = new MD5();
if (enCoding && enCoding == 'base64') {
let md5 = md.b64_md5(value);
if (!md5.endsWith('==')) {
md5 += '==';
}
return md5;
}
return md.hex_md5(value);
}
|
AST#method_declaration#Left static hash AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left enCoding ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 md = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left MD5 AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left enCoding AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left enCoding AST#expression#Right == AST#expression#Left 'base64' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left md5 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left md AST#expression#Right . b64_md5 AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left value AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left md5 AST#expression#Right AST#unary_expression#Right AST#expression#Right . endsWith AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '==' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left md5 += AST#expression#Left '==' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left md5 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 md AST#expression#Right . hex_md5 AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left value AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static hash(value: string, enCoding?: string): string {
let md = new MD5();
if (enCoding && enCoding == 'base64') {
let md5 = md.b64_md5(value);
if (!md5.endsWith('==')) {
md5 += '==';
}
return md5;
}
return md.hex_md5(value);
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto/src/main/ets/crypto/encryption/MD5.ets#L47-L57
|
320746e8402bef89cca54e52cbac1da9398af423
|
gitee
|
sithvothykiv/dialog_hub.git
|
b676c102ef2d05f8994d170abe48dcc40cd39005
|
entry/src/main/ets/pages/Index.ets
|
arkts
|
customTextBuilder
|
自定义文本
|
@Builder
customTextBuilder(content: string) {
Column() {
Text(content)
.fontSize(16)
.padding(5)
.textShadow({
color: Color.Brown,
type: ShadowType.COLOR,
radius: 3,
offsetX: 4,
offsetY: 4,
fill: false
})
}.padding({ top: 30, bottom: 30 })
.onClick(() => {
DialogHub.closeDialog()
this.toast('点击了自定义文本')
})
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right customTextBuilder AST#parameter_list#Left ( AST#parameter#Left content : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#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 content AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left 5 AST#expression#Right ) AST#modifier_chain_expression#Left . textShadow ( 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 . Brown AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left ShadowType AST#expression#Right . COLOR AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left 3 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetX AST#property_name#Right : AST#expression#Left 4 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetY AST#property_name#Right : AST#expression#Left 4 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left fill AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 30 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 30 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . 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 DialogHub AST#expression#Right . closeDialog AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . toast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '点击了自定义文本' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
customTextBuilder(content: string) {
Column() {
Text(content)
.fontSize(16)
.padding(5)
.textShadow({
color: Color.Brown,
type: ShadowType.COLOR,
radius: 3,
offsetX: 4,
offsetY: 4,
fill: false
})
}.padding({ top: 30, bottom: 30 })
.onClick(() => {
DialogHub.closeDialog()
this.toast('点击了自定义文本')
})
}
|
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/entry/src/main/ets/pages/Index.ets#L108-L127
|
d3839d04534c06f84f8e3c8630085089a9fb5d52
|
github
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Ability/UIAbilityLifeCycle/entry/src/main/ets/common/constants/CommonConstants.ets
|
arkts
|
Copyright (c) 2023 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
export default class CommonConstants{
/**
* The text high
*/
static TEXT_HEIGHT: number = 50;
/**
* The text width
*/
static DEFAULT_MARGIN: number = 30;
/**
* Full the width.
*/
static FULL_WIDTH: string = '100%';
/**
* Full the height.
*/
static FULL_HEIGHT: string = '100%';
/**
* Default fontSize
*/
static DEFAULT_FONT_SIZE: number = 30;
/*
* Log Domain
* */
static DOMAIN: number = 0x0000;
}
|
AST#export_declaration#Left export default AST#class_declaration#Left class CommonConstants AST#class_body#Left { /**
* The text high
*/ AST#property_declaration#Left static TEXT_HEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 50 AST#expression#Right ; AST#property_declaration#Right /**
* The text width
*/ AST#property_declaration#Left static DEFAULT_MARGIN : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 30 AST#expression#Right ; AST#property_declaration#Right /**
* Full the width.
*/ AST#property_declaration#Left static FULL_WIDTH : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '100%' AST#expression#Right ; AST#property_declaration#Right /**
* Full the height.
*/ AST#property_declaration#Left static FULL_HEIGHT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '100%' AST#expression#Right ; AST#property_declaration#Right /**
* Default fontSize
*/ AST#property_declaration#Left static DEFAULT_FONT_SIZE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 30 AST#expression#Right ; AST#property_declaration#Right /*
* Log Domain
* */ AST#property_declaration#Left static DOMAIN : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0x0000 AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export default class CommonConstants{
static TEXT_HEIGHT: number = 50;
static DEFAULT_MARGIN: number = 30;
static FULL_WIDTH: string = '100%';
static FULL_HEIGHT: string = '100%';
static DEFAULT_FONT_SIZE: number = 30;
static DOMAIN: number = 0x0000;
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Ability/UIAbilityLifeCycle/entry/src/main/ets/common/constants/CommonConstants.ets#L16-L46
|
f3cf71cb75278424ccf67348dc383a0abc20bece
|
gitee
|
|
salehelper/algorithm_arkts.git
|
61af15272038646775a4745fca98a48ba89e1f4e
|
entry/src/main/ets/search/LinearSearch.ets
|
arkts
|
findLast
|
查找最后一个满足条件的元素
@param arr 数组
@param predicate 判断条件函数
@returns 最后一个满足条件的元素索引,如果不存在则返回-1
|
public static findLast(arr: number[], predicate: (value: number) => boolean): number {
if (!arr || arr.length === 0) {
return -1;
}
for (let i = arr.length - 1; i >= 0; i--) {
if (predicate(arr[i])) {
return i;
}
}
return -1;
}
|
AST#method_declaration#Left public static findLast AST#parameter_list#Left ( AST#parameter#Left arr : 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#parameter#Right , AST#parameter#Left predicate : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left arr AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left arr AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_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#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left arr 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#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right >= AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right -- AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left predicate AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left arr 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#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left i AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public static findLast(arr: number[], predicate: (value: number) => boolean): number {
if (!arr || arr.length === 0) {
return -1;
}
for (let i = arr.length - 1; i >= 0; i--) {
if (predicate(arr[i])) {
return i;
}
}
return -1;
}
|
https://github.com/salehelper/algorithm_arkts.git/blob/61af15272038646775a4745fca98a48ba89e1f4e/entry/src/main/ets/search/LinearSearch.ets#L72-L84
|
fd225061fd6f3bed8f655d5ad71346400d7ee02b
|
github
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
CommonEventAndNotification/AlarmClock/entry/src/main/ets/model/database/PreferencesHandler.ets
|
arkts
|
clear
|
Clear data in PreferencesHandler.
|
public clear() {
if (this.preferences != null) {
this.preferences.clear();
}
}
|
AST#method_declaration#Left public clear AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . preferences AST#member_expression#Right AST#expression#Right != AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#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 . preferences AST#member_expression#Right AST#expression#Right . clear AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
public clear() {
if (this.preferences != null) {
this.preferences.clear();
}
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/CommonEventAndNotification/AlarmClock/entry/src/main/ets/model/database/PreferencesHandler.ets#L90-L94
|
4313ae5cb84197dcf1f5b5da4f5997e3353f9366
|
gitee
|
euler1129/Cloud-flash-payment.git
|
dfb70c1c67b3b69447f4384661e16b60f40495de
|
entry/src/main/ets/pages/card/common/utils/methods.ets
|
arkts
|
export async function takePhoto() { //打开相机 await abilityAccessCtrl.createAtManager() .requestPermissionsFromUser(getContext(this), ['ohos.permission.CAMERA', 'ohos.permission.READ_MEDIA']) let context = getContext(this) as common.UIAbilityContext let result = await context.startAbilityForResult({ action: "ohos.want.action.imageCapture" }) // return result.want.uri console.log('照片', JSON.stringify(result.want)) const randomNum = (Math.random()*9+1)*1000000000000000000 + '' // 随机生成19位数字 return randomNum.replace(/(.{4})/g, "$1 ") }
|
export async function takePhoto() {
let context = getContext() as common.UIAbilityContext
let want = {
'uri': '',
'action': "ohos.want.action.imageCapture",
'parameters': {},
};
return context.startAbilityForResult(want)
.then((result) => {
if (result.resultCode === 0 && result.want && result.want.uri ) {
//拍照成功
console.log('拍照成功', result.want.uri)
// return result.want.uri;
// 模拟返回卡片
const randomNum = (Math.random()*9+1)*1000000000000000000 + '' // 随机生成19位数字
return randomNum.replace(/(.{4})/g, "$1 ")
}
}).catch((error) => {
console.log(this.TAG, `startAbility error , ${JSON.stringify(error)}`);
return error;
})
}
|
AST#export_declaration#Left export AST#function_declaration#Left async function takePhoto AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left context = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left want = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left 'uri' AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'action' AST#property_name#Right : AST#expression#Left "ohos.want.action.imageCapture" AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'parameters' AST#property_name#Right : AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right , } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . startAbilityForResult AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left want AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . 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#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . resultCode AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left result AST#expression#Right AST#binary_expression#Right AST#expression#Right . want AST#member_expression#Right AST#expression#Right && AST#expression#Left result AST#expression#Right AST#binary_expression#Right AST#expression#Right . want AST#member_expression#Right AST#expression#Right . uri 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 . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '拍照成功' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . want AST#member_expression#Right AST#expression#Right . uri 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 // return result.want.uri; // 模拟返回卡片 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left randomNum = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . random AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right * AST#expression#Left 9 AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left 1000000000000000000 AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right // 随机生成19位数字 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 randomNum AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#ERROR#Left / AST#ERROR#Right AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#ERROR#Left . AST#ERROR#Right AST#expression#Left AST#object_literal#Left { AST#ERROR#Left AST#property_name#Left 4 AST#property_name#Right AST#ERROR#Right } AST#object_literal#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left g AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left "$1 " 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#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error AST#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#member_expression#Left AST#expression#Left this AST#expression#Right . TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` startAbility error , AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left error AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export async function takePhoto() {
let context = getContext() as common.UIAbilityContext
let want = {
'uri': '',
'action': "ohos.want.action.imageCapture",
'parameters': {},
};
return context.startAbilityForResult(want)
.then((result) => {
if (result.resultCode === 0 && result.want && result.want.uri ) {
console.log('拍照成功', result.want.uri)
const randomNum = (Math.random()*9+1)*1000000000000000000 + ''
return randomNum.replace(/(.{4})/g, "$1 ")
}
}).catch((error) => {
console.log(this.TAG, `startAbility error , ${JSON.stringify(error)}`);
return error;
})
}
|
https://github.com/euler1129/Cloud-flash-payment.git/blob/dfb70c1c67b3b69447f4384661e16b60f40495de/entry/src/main/ets/pages/card/common/utils/methods.ets#L16-L37
|
c32ebdadfe0ab889d5d9ba673e9174e2859b2012
|
github
|
|
mayuanwei/harmonyOS_bilibili
|
8a36b68b1ddf4433e2e17ee10fee4993cce2a6c5
|
AtomicService/DxinPoetry/entry/src/main/ets/model/PoetryMenuEssence.ets
|
arkts
|
作者数据格式
|
export interface AuthorType {
id: number
name: string
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface AuthorType AST#object_type#Left { AST#type_member#Left id : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right AST#type_member#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
|
export interface AuthorType {
id: number
name: string
}
|
https://github.com/mayuanwei/harmonyOS_bilibili/blob/8a36b68b1ddf4433e2e17ee10fee4993cce2a6c5/AtomicService/DxinPoetry/entry/src/main/ets/model/PoetryMenuEssence.ets#L38-L41
|
0b5f967615c3b80387065a07dc976d46b2ea3ef2
|
gitee
|
|
salehelper/algorithm_arkts.git
|
61af15272038646775a4745fca98a48ba89e1f4e
|
entry/src/main/ets/ciphers/HillCipher.ets
|
arkts
|
numbersToText
|
将数字数组转换为文本
@param numbers 数字数组
@returns 文本
|
private static numbersToText(numbers: number[]): string {
return numbers.map(num => {
const index = (num % HillCipher.MOD);
return HillCipher.ALPHABET.charAt(index);
}).join('');
}
|
AST#method_declaration#Left private static numbersToText AST#parameter_list#Left ( AST#parameter#Left numbers : 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#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left numbers AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left num => AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left index = AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left num AST#expression#Right % AST#expression#Left HillCipher AST#expression#Right AST#binary_expression#Right AST#expression#Right . MOD AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left HillCipher AST#expression#Right . ALPHABET AST#member_expression#Right AST#expression#Right . charAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#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 . join AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private static numbersToText(numbers: number[]): string {
return numbers.map(num => {
const index = (num % HillCipher.MOD);
return HillCipher.ALPHABET.charAt(index);
}).join('');
}
|
https://github.com/salehelper/algorithm_arkts.git/blob/61af15272038646775a4745fca98a48ba89e1f4e/entry/src/main/ets/ciphers/HillCipher.ets#L74-L79
|
8c01a973931821e7a6ef909167079a293ab68f16
|
github
|
DEMON-coding/HarmonyOs-Clock-Demo.git
|
f3c71a3d5ac478d463dfed068b89582104d2f9f6
|
entry/src/main/ets/common/utils/ReminderService.ets
|
arkts
|
引入发布通知的方法
定时检查并发布通知
@param morningOn 是否开启早晨提醒
@param morningHour 早晨提醒的小时
@param morningMinute 早晨提醒的分钟
@param noonOn 是否开启中午提醒
@param noonHour 中午提醒的小时
@param noonMinute 中午提醒的分钟
@param eveningOn 是否开启晚上提醒
@param eveningHour 晚上提醒的小时
@param eveningMinute 晚上提醒的分钟
|
export function startReminderCheck(
morningOn: boolean, morningHour: number, morningMinute: number,
noonOn: boolean, noonHour: number, noonMinute: number,
eveningOn: boolean, eveningHour: number, eveningMinute: number
) {
setInterval(() => {
const currentTime = new Date();
const hour = currentTime.getHours();
const minute = currentTime.getMinutes();
if (morningOn && hour === morningHour && minute === morningMinute) {
publishSimpleNotification(Date.now(), '早晨提醒', '该吃早餐了!');
}
if (noonOn && hour === noonHour && minute === noonMinute) {
publishSimpleNotification(Date.now(), '中午提醒', '该吃午餐了!');
}
if (eveningOn && hour === eveningHour && minute === eveningMinute) {
publishSimpleNotification(Date.now(), '晚上提醒', '该吃晚餐了!');
}
}, 60000); // 每分钟检查一次
}
|
AST#export_declaration#Left export AST#function_declaration#Left function startReminderCheck AST#parameter_list#Left ( AST#parameter#Left morningOn : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left morningHour : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left morningMinute : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left noonOn : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left noonHour : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left noonMinute : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left eveningOn : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left eveningHour : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left eveningMinute : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left setInterval 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#variable_declaration#Left const AST#variable_declarator#Left currentTime = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left hour = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentTime AST#expression#Right . getHours AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left minute = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentTime AST#expression#Right . getMinutes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left morningOn AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left hour AST#expression#Right === AST#expression#Left morningHour AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left minute AST#expression#Right === AST#expression#Left morningMinute AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left publishSimpleNotification AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Date AST#expression#Right . 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#expression#Right , AST#expression#Left '该吃早餐了!' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left noonOn AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left hour AST#expression#Right === AST#expression#Left noonHour AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left minute AST#expression#Right === AST#expression#Left noonMinute AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left publishSimpleNotification AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Date AST#expression#Right . 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#expression#Right , AST#expression#Left '该吃午餐了!' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left eveningOn AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left hour AST#expression#Right === AST#expression#Left eveningHour AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left minute AST#expression#Right === AST#expression#Left eveningMinute AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left publishSimpleNotification AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Date AST#expression#Right . 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#expression#Right , AST#expression#Left '该吃晚餐了!' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right , AST#expression#Left 60000 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 startReminderCheck(
morningOn: boolean, morningHour: number, morningMinute: number,
noonOn: boolean, noonHour: number, noonMinute: number,
eveningOn: boolean, eveningHour: number, eveningMinute: number
) {
setInterval(() => {
const currentTime = new Date();
const hour = currentTime.getHours();
const minute = currentTime.getMinutes();
if (morningOn && hour === morningHour && minute === morningMinute) {
publishSimpleNotification(Date.now(), '早晨提醒', '该吃早餐了!');
}
if (noonOn && hour === noonHour && minute === noonMinute) {
publishSimpleNotification(Date.now(), '中午提醒', '该吃午餐了!');
}
if (eveningOn && hour === eveningHour && minute === eveningMinute) {
publishSimpleNotification(Date.now(), '晚上提醒', '该吃晚餐了!');
}
}, 60000);
}
|
https://github.com/DEMON-coding/HarmonyOs-Clock-Demo.git/blob/f3c71a3d5ac478d463dfed068b89582104d2f9f6/entry/src/main/ets/common/utils/ReminderService.ets#L15-L37
|
ff15ab01f46a1c3f5f998b83dcc6bd3271ca4d81
|
github
|
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
ETSUI/SwiperArkTS/entry/src/main/ets/view/common/Banner.ets
|
arkts
|
Banner
|
Carousel banner.
|
@Component
export struct Banner {
// Change the index value through a scheduled task to perform a round robin.
@State index: number = 0;
private imageArray: Array<PictureItem> = [];
private swiperController: SwiperController = new SwiperController();
aboutToAppear() {
// Data Initialization.
this.imageArray = initializePictures(PictureType.BANNER);
// Turn on scheduled task.
startPlay(this.swiperController);
}
aboutToDisappear() {
stopPlay();
}
build() {
Swiper(this.swiperController) {
ForEach(this.imageArray, (item: PictureItem) => {
Stack({ alignContent: Alignment.TopStart }) {
Image(item.image)
.objectFit(ImageFit.Fill)
.height(CommonConstants.FULL_HEIGHT)
.width(CommonConstants.FULL_WIDTH)
.borderRadius(CommonConstants.BORDER_RADIUS)
.align(Alignment.Center)
.onClick(() => {
router.pushUrl({ url: CommonConstants.PLAY_PAGE });
})
Column() {
Text($r('app.string.movie_classic'))
.textStyle($r('app.float.font_size_description'), CommonConstants.FONT_WEIGHT_LIGHT)
.opacity($r('app.float.opacity_deep'))
.margin({ bottom: CommonConstants.BOTTOM_TEXT })
Text(item.name)
.textStyle($r('app.float.font_size_title'), CommonConstants.FONT_WEIGHT_BOLD)
}
.alignItems(HorizontalAlign.Start)
.height(CommonConstants.HEIGHT_CAROUSEL_TITLE)
.margin({
top: CommonConstants.TOP_ADS,
left: CommonConstants.ADS_LEFT
})
}
.height(CommonConstants.FULL_HEIGHT)
.width(CommonConstants.FULL_WIDTH)
}, (item: PictureItem) => JSON.stringify(item))
}
.width(CommonConstants.PAGE_WIDTH)
.height(CommonConstants.HEIGHT_BANNER)
.index(this.index)
.indicatorStyle({ selectedColor: $r('app.color.start_window_background') })
.indicator(true)
.duration(CommonConstants.DURATION_ADS)
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct Banner AST#component_body#Left { // Change the index value through a scheduled task to perform a round robin. AST#property_declaration#Left AST#decorator#Left @ State 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 ; AST#property_declaration#Right AST#property_declaration#Left private imageArray : 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 PictureItem 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 AST#property_declaration#Left private swiperController : AST#type_annotation#Left AST#primary_type#Left SwiperController 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 SwiperController 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#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { // Data Initialization. AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imageArray AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left initializePictures AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left PictureType AST#expression#Right . BANNER AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right // Turn on scheduled task. AST#ui_custom_component_statement#Left startPlay ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . swiperController AST#member_expression#Right AST#expression#Right ) ; AST#ui_custom_component_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left aboutToDisappear AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_custom_component_statement#Left stopPlay ( ) ; AST#ui_custom_component_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Swiper ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . swiperController AST#member_expression#Right AST#expression#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 . imageArray 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 PictureItem 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 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 Image ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . image AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . objectFit ( AST#expression#Left AST#member_expression#Left AST#expression#Left ImageFit AST#expression#Right . Fill 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#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 . borderRadius ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . BORDER_RADIUS AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . align ( AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left router AST#expression#Right . pushUrl AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . PLAY_PAGE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.movie_classic' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . textStyle ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.font_size_description' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FONT_WEIGHT_LIGHT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.opacity_deep' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . BOTTOM_TEXT AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . name AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . textStyle ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.font_size_title' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FONT_WEIGHT_BOLD AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . HEIGHT_CAROUSEL_TITLE AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . TOP_ADS AST#member_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#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . ADS_LEFT AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . 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#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#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left PictureItem AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left 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 item AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . PAGE_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 . HEIGHT_BANNER AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . index ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . index AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . indicatorStyle ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left selectedColor AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.start_window_background' 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 . indicator ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . duration ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DURATION_ADS AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 Banner {
@State index: number = 0;
private imageArray: Array<PictureItem> = [];
private swiperController: SwiperController = new SwiperController();
aboutToAppear() {
this.imageArray = initializePictures(PictureType.BANNER);
startPlay(this.swiperController);
}
aboutToDisappear() {
stopPlay();
}
build() {
Swiper(this.swiperController) {
ForEach(this.imageArray, (item: PictureItem) => {
Stack({ alignContent: Alignment.TopStart }) {
Image(item.image)
.objectFit(ImageFit.Fill)
.height(CommonConstants.FULL_HEIGHT)
.width(CommonConstants.FULL_WIDTH)
.borderRadius(CommonConstants.BORDER_RADIUS)
.align(Alignment.Center)
.onClick(() => {
router.pushUrl({ url: CommonConstants.PLAY_PAGE });
})
Column() {
Text($r('app.string.movie_classic'))
.textStyle($r('app.float.font_size_description'), CommonConstants.FONT_WEIGHT_LIGHT)
.opacity($r('app.float.opacity_deep'))
.margin({ bottom: CommonConstants.BOTTOM_TEXT })
Text(item.name)
.textStyle($r('app.float.font_size_title'), CommonConstants.FONT_WEIGHT_BOLD)
}
.alignItems(HorizontalAlign.Start)
.height(CommonConstants.HEIGHT_CAROUSEL_TITLE)
.margin({
top: CommonConstants.TOP_ADS,
left: CommonConstants.ADS_LEFT
})
}
.height(CommonConstants.FULL_HEIGHT)
.width(CommonConstants.FULL_WIDTH)
}, (item: PictureItem) => JSON.stringify(item))
}
.width(CommonConstants.PAGE_WIDTH)
.height(CommonConstants.HEIGHT_BANNER)
.index(this.index)
.indicatorStyle({ selectedColor: $r('app.color.start_window_background') })
.indicator(true)
.duration(CommonConstants.DURATION_ADS)
}
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/ETSUI/SwiperArkTS/entry/src/main/ets/view/common/Banner.ets#L38-L95
|
f465db44a95a067e7cd5352f9a829b439d8747f4
|
gitee
|
kaina404/HarmonyStock.git
|
99233a46fb0dfb21e02294c730fd80e2fb404f9b
|
entry/src/main/ets/pages/component/PanKouComponent.ets
|
arkts
|
getCube
|
盘口头部的数据
|
getCube(): Array<Array<Array<string>>> {
var cube: Array<Array<Array<string>>> =
[
[
['高', this.stockBasicInfoBean.snap.high.toString()],
['市值', (this.stockBasicInfoBean.snap.amount / 100000 / 100).toFixed(2).toString()],
['量', (this.stockBasicInfoBean.snap.volume / 100000 / 100).toFixed(2) + "万"],
],
[
['低', this.stockBasicInfoBean.snap.low.toString()],
['流通', '488.0亿'],
['换', '3.02%'],
],
[
['开', this.stockBasicInfoBean.snap.open.toString()],
['市盈', '37.00'],
['额', '14.72亿'],
]
]
return cube
}
|
AST#method_declaration#Left getCube AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#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 var AST#variable_declarator#Left cube : 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#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#array_literal#Left [ AST#expression#Left '高' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . stockBasicInfoBean AST#member_expression#Right AST#expression#Right . snap AST#member_expression#Right AST#expression#Right . high 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#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left '市值' 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 AST#parenthesized_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#member_expression#Left AST#expression#Left this AST#expression#Right . stockBasicInfoBean AST#member_expression#Right AST#expression#Right . snap AST#member_expression#Right AST#expression#Right . amount AST#member_expression#Right AST#expression#Right / AST#expression#Left 100000 AST#expression#Right AST#binary_expression#Right AST#expression#Right / AST#expression#Left 100 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . toFixed AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left '量' AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#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#member_expression#Left AST#expression#Left this AST#expression#Right . stockBasicInfoBean AST#member_expression#Right AST#expression#Right . snap AST#member_expression#Right AST#expression#Right . volume AST#member_expression#Right AST#expression#Right / AST#expression#Left 100000 AST#expression#Right AST#binary_expression#Right AST#expression#Right / AST#expression#Left 100 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . toFixed AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left "万" AST#expression#Right AST#binary_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right , ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#array_literal#Left [ AST#expression#Left '低' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . stockBasicInfoBean AST#member_expression#Right AST#expression#Right . snap AST#member_expression#Right AST#expression#Right . low 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#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left '流通' AST#expression#Right , AST#expression#Left '488.0亿' AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left '换' AST#expression#Right , AST#expression#Left '3.02%' AST#expression#Right ] AST#array_literal#Right AST#expression#Right , ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#array_literal#Left [ AST#expression#Left '开' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . stockBasicInfoBean AST#member_expression#Right AST#expression#Right . snap AST#member_expression#Right AST#expression#Right . open 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#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left '市盈' AST#expression#Right , AST#expression#Left '37.00' AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left '额' AST#expression#Right , AST#expression#Left '14.72亿' AST#expression#Right ] AST#array_literal#Right AST#expression#Right , ] AST#array_literal#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left cube AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
getCube(): Array<Array<Array<string>>> {
var cube: Array<Array<Array<string>>> =
[
[
['高', this.stockBasicInfoBean.snap.high.toString()],
['市值', (this.stockBasicInfoBean.snap.amount / 100000 / 100).toFixed(2).toString()],
['量', (this.stockBasicInfoBean.snap.volume / 100000 / 100).toFixed(2) + "万"],
],
[
['低', this.stockBasicInfoBean.snap.low.toString()],
['流通', '488.0亿'],
['换', '3.02%'],
],
[
['开', this.stockBasicInfoBean.snap.open.toString()],
['市盈', '37.00'],
['额', '14.72亿'],
]
]
return cube
}
|
https://github.com/kaina404/HarmonyStock.git/blob/99233a46fb0dfb21e02294c730fd80e2fb404f9b/entry/src/main/ets/pages/component/PanKouComponent.ets#L56-L76
|
280d08d283700dd2327e06f403fa0c430ca9781f
|
github
|
openharmony-tpc-incubate/photo-deal-demo
|
01382ce30b1785f8fc8bc14f6b94f0a670a5b50b
|
library/src/main/ets/components/textInput/TextEditNodeController.ets
|
arkts
|
modifyTopTextColor
|
修改顶部文本颜色
@param color 颜色
|
modifyTopTextColor(color: string): void {
// 只修改最顶部处于编辑状态的颜色
let record: OperateRecord | undefined;
for (let end = this.textRecords.length - 1; end >= 0; end--) {
record = this.textRecords[end];
if (record.data instanceof TextInputData && record.data.isActivated()) {
record.data.color = color;
return;
}
}
}
|
AST#method_declaration#Left modifyTopTextColor AST#parameter_list#Left ( AST#parameter#Left color : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 只修改最顶部处于编辑状态的颜色 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left record : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left OperateRecord AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left end = 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 . textRecords 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#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#binary_expression#Left AST#expression#Left end AST#expression#Right >= AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left end 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 record = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . textRecords AST#member_expression#Right AST#expression#Right [ AST#expression#Left end AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#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#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left record AST#expression#Right . data AST#member_expression#Right AST#expression#Right instanceof AST#expression#Left TextInputData AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left record AST#expression#Right AST#binary_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right . isActivated AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left record AST#expression#Right . data AST#member_expression#Right AST#expression#Right . color AST#member_expression#Right = AST#expression#Left color AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#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#block_statement#Right AST#for_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
modifyTopTextColor(color: string): void {
let record: OperateRecord | undefined;
for (let end = this.textRecords.length - 1; end >= 0; end--) {
record = this.textRecords[end];
if (record.data instanceof TextInputData && record.data.isActivated()) {
record.data.color = color;
return;
}
}
}
|
https://github.com/openharmony-tpc-incubate/photo-deal-demo/blob/01382ce30b1785f8fc8bc14f6b94f0a670a5b50b/library/src/main/ets/components/textInput/TextEditNodeController.ets#L181-L191
|
8f04206429e31e2b8ffed07d72edcb36a9271bd0
|
gitee
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/ArkTS1.2/ComponentSample/entry/src/main/ets/pages/Example1/DataType.ets
|
arkts
|
getData
|
获取指定索引数据。
@param {number} index - 索引值。
@returns {CustomDataType} 返回指定索引数据。
|
public getData(index: double): CustomDataType {
return this.originDataArray[index];
}
|
AST#method_declaration#Left public getData AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left double AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left CustomDataType AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . originDataArray AST#member_expression#Right AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public getData(index: double): CustomDataType {
return this.originDataArray[index];
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/ArkTS1.2/ComponentSample/entry/src/main/ets/pages/Example1/DataType.ets#L77-L79
|
6a20785543c13a2f99a8ffce93c0220a7ddfb31b
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
harmonyos/src/main/ets/pages/game/VirtualShopPage.ets
|
arkts
|
buildHeader
|
构建头部
|
@Builder
buildHeader() {
Row() {
Button() {
Image($r('app.media.ic_back'))
.width(24)
.height(24)
.fillColor($r('app.color.text_primary'))
}
.type(ButtonType.Normal)
.backgroundColor(Color.Transparent)
.onClick(() => {
router.back();
})
Text('虚拟商店')
.fontSize(20)
.fontColor($r('app.color.text_primary'))
.fontWeight(FontWeight.Medium)
.layoutWeight(1)
.textAlign(TextAlign.Center)
.margin({ left: -44 })
Button() {
Image($r('app.media.ic_refresh'))
.width(24)
.height(24)
.fillColor($r('app.color.text_primary'))
}
.type(ButtonType.Normal)
.backgroundColor(Color.Transparent)
.onClick(() => {
this.refreshShop();
})
}
.width('100%')
.height(56)
.padding({ left: 16, right: 16 })
.alignItems(VerticalAlign.Center)
.backgroundColor(Color.White)
.shadow({
radius: 2,
color: Color.Black,
offsetX: 0,
offsetY: 1
})
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildHeader AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { 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 Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_back' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Left . fillColor ( 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#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 . Normal AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Transparent AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left router AST#expression#Right . back AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 20 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#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 . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#unary_expression#Left - AST#expression#Left 44 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#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 Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_refresh' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Left . fillColor ( 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#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 . Normal AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Transparent AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . refreshShop 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#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 56 AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left VerticalAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . shadow ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left 2 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Black AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetX AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetY AST#property_name#Right : AST#expression#Left 1 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
buildHeader() {
Row() {
Button() {
Image($r('app.media.ic_back'))
.width(24)
.height(24)
.fillColor($r('app.color.text_primary'))
}
.type(ButtonType.Normal)
.backgroundColor(Color.Transparent)
.onClick(() => {
router.back();
})
Text('虚拟商店')
.fontSize(20)
.fontColor($r('app.color.text_primary'))
.fontWeight(FontWeight.Medium)
.layoutWeight(1)
.textAlign(TextAlign.Center)
.margin({ left: -44 })
Button() {
Image($r('app.media.ic_refresh'))
.width(24)
.height(24)
.fillColor($r('app.color.text_primary'))
}
.type(ButtonType.Normal)
.backgroundColor(Color.Transparent)
.onClick(() => {
this.refreshShop();
})
}
.width('100%')
.height(56)
.padding({ left: 16, right: 16 })
.alignItems(VerticalAlign.Center)
.backgroundColor(Color.White)
.shadow({
radius: 2,
color: Color.Black,
offsetX: 0,
offsetY: 1
})
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/pages/game/VirtualShopPage.ets#L78-L124
|
ac97de1e8dc37f507cda5fe28bbb2fd22daf2978
|
github
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/pipwindow/src/main/ets/components/ControlPanel.ets
|
arkts
|
媒体最大音量
|
build() {
Stack() {
// 亮度调节UI
Image($r('app.media.pip_window_brightness'))
.width($r('app.integer.pip_window_control_panel_image_width'))
.aspectRatio(ASPECT_RATIO)
.visibility((this.fingerPosition !== 0 && this.fingerPosition < this.videoAreaWidth / PARTITION &&
this.controlShow) ?
Visibility.Visible : Visibility.Hidden)
Progress({
value: this.bright,
type: ProgressType.Ring,
total: CONTROLLER_MAX
})
.color($r('app.color.pip_window_progress_color'))
.width($r('app.integer.pip_window_control_panel_progress_width'))
.aspectRatio(ASPECT_RATIO)
.visibility((this.fingerPosition !== 0 && this.fingerPosition < this.videoAreaWidth / PARTITION &&
this.controlShow) ?
Visibility.Visible : Visibility.Hidden)
// 音量调节UI
Image($r('app.media.pip_window_sound'))
.width($r('app.integer.pip_window_control_panel_image_width'))
.aspectRatio(ASPECT_RATIO)
.visibility((this.fingerPosition !== 0 && this.fingerPosition > this.videoAreaWidth / PARTITION &&
this.controlShow) ?
Visibility.Visible : Visibility.Hidden)
Progress({
value: this.volume,
type: ProgressType.Ring,
total: this.maxVolume
})
.color($r('app.color.pip_window_progress_color'))
.width($r('app.integer.pip_window_control_panel_progress_width'))
.aspectRatio(ASPECT_RATIO)
.visibility((this.fingerPosition !== 0 && this.fingerPosition > this.videoAreaWidth / PARTITION &&
this.controlShow) ?
Visibility.Visible : Visibility.Hidden)
}
.width($r('app.string.pip_window_full_width'))
.height($r('app.string.pip_window_control_panel_height'))
}
|
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#container_content_body#Left { // 亮度调节UI AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.pip_window_brightness' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.pip_window_control_panel_image_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . aspectRatio ( AST#expression#Left ASPECT_RATIO AST#expression#Right ) AST#modifier_chain_expression#Left . visibility ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#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 . fingerPosition 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 . fingerPosition AST#member_expression#Right AST#expression#Right < AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . videoAreaWidth AST#member_expression#Right AST#expression#Right / AST#expression#Left PARTITION AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . controlShow AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left Visibility AST#expression#Right . Visible AST#member_expression#Right AST#expression#Right : AST#expression#Left Visibility AST#expression#Right AST#conditional_expression#Right AST#expression#Right . Hidden AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Progress ( AST#component_parameters#Left { AST#component_parameter#Left value : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bright AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left type : AST#expression#Left AST#member_expression#Left AST#expression#Left ProgressType AST#expression#Right . Ring AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left total : AST#expression#Left CONTROLLER_MAX AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . color ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.pip_window_progress_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.pip_window_control_panel_progress_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . aspectRatio ( AST#expression#Left ASPECT_RATIO AST#expression#Right ) AST#modifier_chain_expression#Left . visibility ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#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 . fingerPosition 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 . fingerPosition AST#member_expression#Right AST#expression#Right < AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . videoAreaWidth AST#member_expression#Right AST#expression#Right / AST#expression#Left PARTITION AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . controlShow AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left Visibility AST#expression#Right . Visible AST#member_expression#Right AST#expression#Right : AST#expression#Left Visibility AST#expression#Right AST#conditional_expression#Right AST#expression#Right . Hidden 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 // 音量调节UI AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.pip_window_sound' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.pip_window_control_panel_image_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . aspectRatio ( AST#expression#Left ASPECT_RATIO AST#expression#Right ) AST#modifier_chain_expression#Left . visibility ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#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 . fingerPosition 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 . fingerPosition AST#member_expression#Right AST#expression#Right > AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . videoAreaWidth AST#member_expression#Right AST#expression#Right / AST#expression#Left PARTITION AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . controlShow AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left Visibility AST#expression#Right . Visible AST#member_expression#Right AST#expression#Right : AST#expression#Left Visibility AST#expression#Right AST#conditional_expression#Right AST#expression#Right . Hidden AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Progress ( AST#component_parameters#Left { AST#component_parameter#Left value : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . volume AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left type : AST#expression#Left AST#member_expression#Left AST#expression#Left ProgressType AST#expression#Right . Ring AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left total : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . maxVolume AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . color ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.pip_window_progress_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.pip_window_control_panel_progress_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . aspectRatio ( AST#expression#Left ASPECT_RATIO AST#expression#Right ) AST#modifier_chain_expression#Left . visibility ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#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 . fingerPosition 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 . fingerPosition AST#member_expression#Right AST#expression#Right > AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . videoAreaWidth AST#member_expression#Right AST#expression#Right / AST#expression#Left PARTITION AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . controlShow AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left Visibility AST#expression#Right . Visible AST#member_expression#Right AST#expression#Right : AST#expression#Left Visibility AST#expression#Right AST#conditional_expression#Right AST#expression#Right . Hidden AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.pip_window_full_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.pip_window_control_panel_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right
|
build() {
Stack() {
Image($r('app.media.pip_window_brightness'))
.width($r('app.integer.pip_window_control_panel_image_width'))
.aspectRatio(ASPECT_RATIO)
.visibility((this.fingerPosition !== 0 && this.fingerPosition < this.videoAreaWidth / PARTITION &&
this.controlShow) ?
Visibility.Visible : Visibility.Hidden)
Progress({
value: this.bright,
type: ProgressType.Ring,
total: CONTROLLER_MAX
})
.color($r('app.color.pip_window_progress_color'))
.width($r('app.integer.pip_window_control_panel_progress_width'))
.aspectRatio(ASPECT_RATIO)
.visibility((this.fingerPosition !== 0 && this.fingerPosition < this.videoAreaWidth / PARTITION &&
this.controlShow) ?
Visibility.Visible : Visibility.Hidden)
Image($r('app.media.pip_window_sound'))
.width($r('app.integer.pip_window_control_panel_image_width'))
.aspectRatio(ASPECT_RATIO)
.visibility((this.fingerPosition !== 0 && this.fingerPosition > this.videoAreaWidth / PARTITION &&
this.controlShow) ?
Visibility.Visible : Visibility.Hidden)
Progress({
value: this.volume,
type: ProgressType.Ring,
total: this.maxVolume
})
.color($r('app.color.pip_window_progress_color'))
.width($r('app.integer.pip_window_control_panel_progress_width'))
.aspectRatio(ASPECT_RATIO)
.visibility((this.fingerPosition !== 0 && this.fingerPosition > this.videoAreaWidth / PARTITION &&
this.controlShow) ?
Visibility.Visible : Visibility.Hidden)
}
.width($r('app.string.pip_window_full_width'))
.height($r('app.string.pip_window_control_panel_height'))
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/pipwindow/src/main/ets/components/ControlPanel.ets#L47-L89
|
7ebdeb35096aaf7fc3bfae746b8c7416f564614a
|
gitee
|
|
liuchao0739/arkTS_universal_starter.git
|
0ca845f5ae0e78db439dc09f712d100c0dd46ed3
|
entry/src/main/ets/utils/ScreenUtils.ets
|
arkts
|
showKeyboard
|
显示键盘
|
static showKeyboard(): void {
// 实际实现需要使用 InputMethod 相关API
// InputMethod.showKeyboard();
}
|
AST#method_declaration#Left static showKeyboard 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 { // 实际实现需要使用 InputMethod 相关API // InputMethod.showKeyboard(); } AST#builder_function_body#Right AST#method_declaration#Right
|
static showKeyboard(): void {
}
|
https://github.com/liuchao0739/arkTS_universal_starter.git/blob/0ca845f5ae0e78db439dc09f712d100c0dd46ed3/entry/src/main/ets/utils/ScreenUtils.ets#L80-L83
|
27cea42e392861e3f9e071147df43a724c30ac3a
|
github
|
openharmony/arkui_ace_engine
|
30c7d1ee12fbedf0fabece54291d75897e2ad44f
|
frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/LazyForEach.ets
|
arkts
|
Developers need to implement this interface to provide data to LazyForEach component.
@since 7
|
export interface IDataSource<T> {
/**
* Total data count.
* @since 7
*/
totalCount(): number;
/**
* Return the data of index.
* @since 7
*/
getData(index: number): T;
/**
* Register data change listener.
* @since 7
*/
registerDataChangeListener(listener: DataChangeListener): void;
/**
* Unregister data change listener.
* @since 7
*/
unregisterDataChangeListener(listener: DataChangeListener): void;
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface IDataSource AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#object_type#Left { /**
* Total data count.
* @since 7
*/ AST#type_member#Left totalCount AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /**
* Return the data of index.
* @since 7
*/ AST#type_member#Left getData AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /**
* Register data change listener.
* @since 7
*/ AST#type_member#Left registerDataChangeListener AST#parameter_list#Left ( AST#parameter#Left listener : AST#type_annotation#Left AST#primary_type#Left DataChangeListener AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /**
* Unregister data change listener.
* @since 7
*/ AST#type_member#Left unregisterDataChangeListener AST#parameter_list#Left ( AST#parameter#Left listener : AST#type_annotation#Left AST#primary_type#Left DataChangeListener AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
|
export interface IDataSource<T> {
totalCount(): number;
getData(index: number): T;
registerDataChangeListener(listener: DataChangeListener): void;
unregisterDataChangeListener(listener: DataChangeListener): void;
}
|
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/LazyForEach.ets#L30-L51
|
d2ca8fc1a098676492eb4e1f20ac67f1e15282b4
|
gitee
|
|
openharmony-tpc/ohos_mpchart
|
4fb43a7137320ef2fee2634598f53d93975dfb4a
|
library/src/main/ets/components/data/BubbleDataSet.ets
|
arkts
|
getMaxSize
|
@Override
|
public getMaxSize(): number {
return BubbleDataSet.mMaxSize;
}
|
AST#method_declaration#Left public getMaxSize 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 BubbleDataSet AST#expression#Right . mMaxSize AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public getMaxSize(): number {
return BubbleDataSet.mMaxSize;
}
|
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/data/BubbleDataSet.ets#L71-L73
|
956f82197aa0afec56756b747ae96a1fe80e2737
|
gitee
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/Performance/PerformanceLibrary/feature/hiDumper/src/main/ets/view/VisibilityView.ets
|
arkts
|
VisibilityView
|
Copyright (c) 2023 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
@Component
export struct VisibilityView {
@State isVisible: Visibility = Visibility.Visible;
build() {
Column() {
Button($r('app.string.visible'))
.onClick(() => {
this.isVisible = Visibility.Visible;
})
.margin({ top: 10 })
Button($r('app.string.hidden'))
.onClick(() => {
this.isVisible = Visibility.Hidden;
})
.margin({ top: 10 })
Button($r('app.string.none'))
.onClick(() => {
this.isVisible = Visibility.None;
})
.margin({ top: 10 })
Row().visibility(this.isVisible)
.width(720)
.height(300)
.backgroundColor(Color.Pink)
}.width('100%')
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct VisibilityView AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right isVisible : AST#type_annotation#Left AST#primary_type#Left Visibility AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left Visibility AST#expression#Right . Visible AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.visible' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isVisible AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left Visibility AST#expression#Right . Visible 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#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.hidden' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isVisible AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left Visibility AST#expression#Right . Hidden 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#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.none' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isVisible AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left Visibility AST#expression#Right . None 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#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . visibility ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isVisible AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 720 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 300 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Pink AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct VisibilityView {
@State isVisible: Visibility = Visibility.Visible;
build() {
Column() {
Button($r('app.string.visible'))
.onClick(() => {
this.isVisible = Visibility.Visible;
})
.margin({ top: 10 })
Button($r('app.string.hidden'))
.onClick(() => {
this.isVisible = Visibility.Hidden;
})
.margin({ top: 10 })
Button($r('app.string.none'))
.onClick(() => {
this.isVisible = Visibility.None;
})
.margin({ top: 10 })
Row().visibility(this.isVisible)
.width(720)
.height(300)
.backgroundColor(Color.Pink)
}.width('100%')
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Performance/PerformanceLibrary/feature/hiDumper/src/main/ets/view/VisibilityView.ets#L16-L43
|
df4f428195eeea40cc7a35c8f1d141998083af26
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/common/utils/LunarCalendar.ets
|
arkts
|
getGanZhi
|
获取干支年
|
private static getGanZhi(year: number): string {
const gan = LunarCalendar.ganNames[(year - 4) % 10];
const zhi = LunarCalendar.zhiNames[(year - 4) % 12];
return gan + zhi;
}
|
AST#method_declaration#Left private static getGanZhi AST#parameter_list#Left ( AST#parameter#Left year : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 gan = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LunarCalendar AST#expression#Right . ganNames AST#member_expression#Right AST#expression#Right [ AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left year AST#expression#Right - AST#expression#Left 4 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right % AST#expression#Left 10 AST#expression#Right AST#binary_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left zhi = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LunarCalendar AST#expression#Right . zhiNames AST#member_expression#Right AST#expression#Right [ AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left year AST#expression#Right - AST#expression#Left 4 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right % AST#expression#Left 12 AST#expression#Right AST#binary_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left gan AST#expression#Right + AST#expression#Left zhi AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private static getGanZhi(year: number): string {
const gan = LunarCalendar.ganNames[(year - 4) % 10];
const zhi = LunarCalendar.zhiNames[(year - 4) % 12];
return gan + zhi;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/utils/LunarCalendar.ets#L329-L333
|
fee426ab5a059ca336103ee3645dac3a9f478618
|
github
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
ef_crypto_dto/src/main/ets/crypto/encryption/RSASync.ets
|
arkts
|
@Author csx
@DateTime 2024/3/18 10:48:03
@TODO RS 同步操作类
|
export class RSASync {
/**
* 生成RSA的非对称密钥
* @param resultCoding 生成RSA秘钥的字符串格式(hex/base64)-默认不传为base64格式
* @returns RSA密钥{publicKey:公钥,privateKey:私钥}
*/
static generateRSAKey(resultCoding: buffer.BufferEncoding = 'base64'): OutDTO<CryptoKey> {
return CryptoSyncUtil.generateCryptoKey('RSA1024', resultCoding);
}
/**
* 生成2048位RSA的非对称密钥
* @param resultCoding 生成RSA秘钥的字符串格式(hex/base64)-默认不传为base64格式
* @returns 2048位RSA密钥{publicKey:2048位公钥,privateKey:2048位私钥}
*/
static generate2048RSAKey(resultCoding: buffer.BufferEncoding = 'base64'): OutDTO<CryptoKey> {
return CryptoSyncUtil.generateCryptoKey('RSA2048', resultCoding);
}
/**
* 加密
* @param str 待加密的字符串
* @param pubKey RSA公钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
*/
static encodePKCS1(str: string, pubKey: string, keyCoding: buffer.BufferEncoding,
resultCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.encodeAsym(str, pubKey, 'RSA1024', 'RSA1024|PKCS1', 1024, keyCoding, resultCoding, isPem);
}
/**
* 加密-分段
* @param str 待加密的字符串
* @param pubKey RSA公钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
*/
static encodePKCS1Segment(str: string, pubKey: string, keyCoding: buffer.BufferEncoding,
resultCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.encodeAsymSegment(str, pubKey, 'RSA1024', 'RSA1024|PKCS1', 1024, keyCoding, resultCoding,
isPem);
}
/**
* 2048位加密
* @param str 待加密的字符串
* @param pubKey 2048位RSA公钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
*/
static encode2048PKCS1(str: string, pubKey: string, keyCoding: buffer.BufferEncoding,
resultCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.encodeAsym(str, pubKey, 'RSA2048', 'RSA2048|PKCS1', 2048, keyCoding, resultCoding, isPem);
}
/**
* 2048位加密-分段
* @param str 待加密的字符串
* @param pubKey 2048位RSA公钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
*/
static encode2048PKCS1Segment(str: string, pubKey: string, keyCoding: buffer.BufferEncoding,
resultCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.encodeAsymSegment(str, pubKey, 'RSA2048', 'RSA2048|PKCS1', 2048, keyCoding, resultCoding,
isPem);
}
/**
* 解密
* @param decodeStr 待解密的字符串
* @param priKey RSA私钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param dataCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
*/
static decodePKCS1(str: string, priKey: string, keyCoding: buffer.BufferEncoding,
dataCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.decodeAsym(str, priKey, 'RSA1024', 'RSA1024|PKCS1', 1024, keyCoding, dataCoding, isPem);
}
/**
* 解密-分段
* @param decodeStr 待解密的字符串
* @param priKey RSA私钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param dataCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
*/
static decodePKCS1Segment(str: string, priKey: string, keyCoding: buffer.BufferEncoding,
dataCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.decodeAsymSegment(str, priKey, 'RSA1024', 'RSA1024|PKCS1', 1024, keyCoding, dataCoding,
isPem);
}
/**
* 2048位解密
* @param decodeStr 待解密的字符串
* @param priKey 2048位RSA私钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param dataCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
*/
static decode2048PKCS1(str: string, priKey: string, keyCoding: buffer.BufferEncoding,
dataCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.decodeAsym(str, priKey, 'RSA2048', 'RSA2048|PKCS1', 2048, keyCoding, dataCoding, isPem);
}
/**
* 2048位解密-分段
* @param decodeStr 待解密的字符串
* @param priKey 2048位RSA私钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param dataCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
*/
static decode2048PKCS1Segment(str: string, priKey: string, keyCoding: buffer.BufferEncoding,
dataCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.decodeAsymSegment(str, priKey, 'RSA2048', 'RSA2048|PKCS1', 2048, keyCoding, dataCoding,
isPem);
}
/**
* 签名-PKCS1
* @param str 需要签名的字符串
* @param priKey 私钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
* @returns OutDTO<string> 签名对象
*/
static signPKCS1(str: string, priKey: string, keyCoding: buffer.BufferEncoding,
resultCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.sign(str, priKey, 'RSA1024', 'RSA1024|PKCS1|SHA256', 1024, keyCoding, resultCoding, isPem);
}
/**
* 2048位签名-PKCS1
* @param str 需要签名的字符串
* @param priKey 2048位私钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
* @returns OutDTO<string> 签名对象
*/
static sign2048PKCS1(str: string, priKey: string, keyCoding: buffer.BufferEncoding,
resultCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.sign(str, priKey, 'RSA2048', 'RSA2048|PKCS1|SHA256', 2048, keyCoding, resultCoding, isPem);
}
/**
* 2048位验签-PKCS1
* @param signStr 已签名的字符串
* @param verifyStr 需要验签的字符串
* @param pubKey 2048位RSA公钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param dataCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
* @returns 验签结果OutDTO对象,其中Msg为验签结果
*/
static verify2048PKCS1(signStr: string, verifyStr: string, pubKey: string, keyCoding: buffer.BufferEncoding,
dataCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.verify(signStr, verifyStr, pubKey, 'RSA2048', 'RSA2048|PKCS1|SHA256', 2048, keyCoding,
dataCoding, isPem);
}
/**
* 验签-PKCS1
* @param signStr 已签名的字符串
* @param verifyStr 需要验签的字符串
* @param pubKey RSA公钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param dataCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
* @returns 验签结果OutDTO对象,其中Msg为验签结果
*/
static verifyPKCS1(signStr: string, verifyStr: string, pubKey: string, keyCoding: buffer.BufferEncoding,
dataCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.verify(signStr, verifyStr, pubKey, 'RSA1024', 'RSA1024|PKCS1|SHA256', 1024, keyCoding,
dataCoding, isPem);
}
/**
* 将pem文件中的数据转换成公钥字符串支持1024/2048字节-hex格式
* @param pemData pem数据以-----BEGIN开头,以-----END结尾
* @returns
* @deprecated RSASync中的加解密方法已经支持pem格式密钥
*/
static pemToStrKey(pemData: string): string {
// 移除PEM格式的头部和尾部,获取Base64编码的数据
const base64Data = pemData.replace(/-----BEGIN .*?-----|-----END .*?-----|\s/g, '');
let options = util.Type.BASIC;
if (/\r\n/.test(base64Data)) {
options = util.Type.MIME;
}
//转码
let arr = Base64Util.decodeSync(base64Data, options);
//返回字符串
let result = StrAndUintUtil.unitArray2String(arr);
return result;
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class RSASync AST#class_body#Left { /**
* 生成RSA的非对称密钥
* @param resultCoding 生成RSA秘钥的字符串格式(hex/base64)-默认不传为base64格式
* @returns RSA密钥{publicKey:公钥,privateKey:私钥}
*/ AST#method_declaration#Left static generateRSAKey AST#parameter_list#Left ( AST#parameter#Left resultCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'base64' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left OutDTO AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left CryptoKey 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 . generateCryptoKey AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'RSA1024' 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 /**
* 生成2048位RSA的非对称密钥
* @param resultCoding 生成RSA秘钥的字符串格式(hex/base64)-默认不传为base64格式
* @returns 2048位RSA密钥{publicKey:2048位公钥,privateKey:2048位私钥}
*/ AST#method_declaration#Left static generate2048RSAKey AST#parameter_list#Left ( AST#parameter#Left resultCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'base64' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left OutDTO AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left CryptoKey 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 . generateCryptoKey AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'RSA2048' 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 /**
* 加密
* @param str 待加密的字符串
* @param pubKey RSA公钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
*/ AST#method_declaration#Left static encodePKCS1 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 pubKey : 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#Left isPem : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 . encodeAsym AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left pubKey AST#expression#Right , AST#expression#Left 'RSA1024' AST#expression#Right , AST#expression#Left 'RSA1024|PKCS1' AST#expression#Right , AST#expression#Left 1024 AST#expression#Right , AST#expression#Left keyCoding AST#expression#Right , AST#expression#Left resultCoding AST#expression#Right , AST#expression#Left isPem AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 加密-分段
* @param str 待加密的字符串
* @param pubKey RSA公钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
*/ AST#method_declaration#Left static encodePKCS1Segment 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 pubKey : 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#Left isPem : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 . encodeAsymSegment AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left pubKey AST#expression#Right , AST#expression#Left 'RSA1024' AST#expression#Right , AST#expression#Left 'RSA1024|PKCS1' AST#expression#Right , AST#expression#Left 1024 AST#expression#Right , AST#expression#Left keyCoding AST#expression#Right , AST#expression#Left resultCoding AST#expression#Right , AST#expression#Left isPem 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 /**
* 2048位加密
* @param str 待加密的字符串
* @param pubKey 2048位RSA公钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
*/ AST#method_declaration#Left static encode2048PKCS1 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 pubKey : 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#Left isPem : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 . encodeAsym AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left pubKey AST#expression#Right , AST#expression#Left 'RSA2048' AST#expression#Right , AST#expression#Left 'RSA2048|PKCS1' AST#expression#Right , AST#expression#Left 2048 AST#expression#Right , AST#expression#Left keyCoding AST#expression#Right , AST#expression#Left resultCoding AST#expression#Right , AST#expression#Left isPem 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 /**
* 2048位加密-分段
* @param str 待加密的字符串
* @param pubKey 2048位RSA公钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
*/ AST#method_declaration#Left static encode2048PKCS1Segment 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 pubKey : 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#Left isPem : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 . encodeAsymSegment AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left pubKey AST#expression#Right , AST#expression#Left 'RSA2048' AST#expression#Right , AST#expression#Left 'RSA2048|PKCS1' AST#expression#Right , AST#expression#Left 2048 AST#expression#Right , AST#expression#Left keyCoding AST#expression#Right , AST#expression#Left resultCoding AST#expression#Right , AST#expression#Left isPem AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 解密
* @param decodeStr 待解密的字符串
* @param priKey RSA私钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param dataCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
*/ AST#method_declaration#Left static decodePKCS1 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#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 dataCoding : 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#Left isPem : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 . decodeAsym AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left priKey AST#expression#Right , AST#expression#Left 'RSA1024' AST#expression#Right , AST#expression#Left 'RSA1024|PKCS1' AST#expression#Right , AST#expression#Left 1024 AST#expression#Right , AST#expression#Left keyCoding AST#expression#Right , AST#expression#Left dataCoding AST#expression#Right , AST#expression#Left isPem AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 解密-分段
* @param decodeStr 待解密的字符串
* @param priKey RSA私钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param dataCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
*/ AST#method_declaration#Left static decodePKCS1Segment AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left priKey : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#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 dataCoding : 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#Left isPem : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 . decodeAsymSegment AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left priKey AST#expression#Right , AST#expression#Left 'RSA1024' AST#expression#Right , AST#expression#Left 'RSA1024|PKCS1' AST#expression#Right , AST#expression#Left 1024 AST#expression#Right , AST#expression#Left keyCoding AST#expression#Right , AST#expression#Left dataCoding AST#expression#Right , AST#expression#Left isPem 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 /**
* 2048位解密
* @param decodeStr 待解密的字符串
* @param priKey 2048位RSA私钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param dataCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
*/ AST#method_declaration#Left static decode2048PKCS1 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#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 dataCoding : 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#Left isPem : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 . decodeAsym 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 'RSA2048' AST#expression#Right , AST#expression#Left 'RSA2048|PKCS1' AST#expression#Right , AST#expression#Left 2048 AST#expression#Right , AST#expression#Left keyCoding AST#expression#Right , AST#expression#Left dataCoding AST#expression#Right , AST#expression#Left isPem 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 /**
* 2048位解密-分段
* @param decodeStr 待解密的字符串
* @param priKey 2048位RSA私钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param dataCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
*/ AST#method_declaration#Left static decode2048PKCS1Segment 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#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 dataCoding : 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#Left isPem : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 . decodeAsymSegment AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left priKey AST#expression#Right , AST#expression#Left 'RSA2048' AST#expression#Right , AST#expression#Left 'RSA2048|PKCS1' AST#expression#Right , AST#expression#Left 2048 AST#expression#Right , AST#expression#Left keyCoding AST#expression#Right , AST#expression#Left dataCoding AST#expression#Right , AST#expression#Left isPem 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 /**
* 签名-PKCS1
* @param str 需要签名的字符串
* @param priKey 私钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
* @returns OutDTO<string> 签名对象
*/ AST#method_declaration#Left static signPKCS1 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#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#Left isPem : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 . 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 'RSA1024' AST#expression#Right , AST#expression#Left 'RSA1024|PKCS1|SHA256' AST#expression#Right , AST#expression#Left 1024 AST#expression#Right , AST#expression#Left keyCoding AST#expression#Right , AST#expression#Left resultCoding AST#expression#Right , AST#expression#Left isPem 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 /**
* 2048位签名-PKCS1
* @param str 需要签名的字符串
* @param priKey 2048位私钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
* @returns OutDTO<string> 签名对象
*/ AST#method_declaration#Left static sign2048PKCS1 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#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#Left isPem : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 . 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 'RSA2048' AST#expression#Right , AST#expression#Left 'RSA2048|PKCS1|SHA256' AST#expression#Right , AST#expression#Left 2048 AST#expression#Right , AST#expression#Left keyCoding AST#expression#Right , AST#expression#Left resultCoding AST#expression#Right , AST#expression#Left isPem 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 /**
* 2048位验签-PKCS1
* @param signStr 已签名的字符串
* @param verifyStr 需要验签的字符串
* @param pubKey 2048位RSA公钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param dataCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
* @returns 验签结果OutDTO对象,其中Msg为验签结果
*/ AST#method_declaration#Left static verify2048PKCS1 AST#parameter_list#Left ( AST#parameter#Left signStr : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left verifyStr : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left pubKey : 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 dataCoding : 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#Left isPem : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 . verify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left signStr AST#expression#Right , AST#expression#Left verifyStr AST#expression#Right , AST#expression#Left pubKey AST#expression#Right , AST#expression#Left 'RSA2048' AST#expression#Right , AST#expression#Left 'RSA2048|PKCS1|SHA256' AST#expression#Right , AST#expression#Left 2048 AST#expression#Right , AST#expression#Left keyCoding AST#expression#Right , AST#expression#Left dataCoding AST#expression#Right , AST#expression#Left isPem 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 /**
* 验签-PKCS1
* @param signStr 已签名的字符串
* @param verifyStr 需要验签的字符串
* @param pubKey RSA公钥
* @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
* @param dataCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
* @param isPem 秘钥是否为pem格式 - 默认为false
* @returns 验签结果OutDTO对象,其中Msg为验签结果
*/ AST#method_declaration#Left static verifyPKCS1 AST#parameter_list#Left ( AST#parameter#Left signStr : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left verifyStr : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left pubKey : 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 dataCoding : 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#Left isPem : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 . verify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left signStr AST#expression#Right , AST#expression#Left verifyStr AST#expression#Right , AST#expression#Left pubKey AST#expression#Right , AST#expression#Left 'RSA1024' AST#expression#Right , AST#expression#Left 'RSA1024|PKCS1|SHA256' AST#expression#Right , AST#expression#Left 1024 AST#expression#Right , AST#expression#Left keyCoding AST#expression#Right , AST#expression#Left dataCoding AST#expression#Right , AST#expression#Left isPem 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 /**
* 将pem文件中的数据转换成公钥字符串支持1024/2048字节-hex格式
* @param pemData pem数据以-----BEGIN开头,以-----END结尾
* @returns
* @deprecated RSASync中的加解密方法已经支持pem格式密钥
*/ AST#method_declaration#Left static pemToStrKey AST#parameter_list#Left ( AST#parameter#Left pemData : 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 { // 移除PEM格式的头部和尾部,获取Base64编码的数据 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left base64Data = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left pemData AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#ERROR#Left / AST#ERROR#Right AST#expression#Left AST#update_expression#Left -- AST#expression#Left AST#update_expression#Left -- AST#expression#Left AST#unary_expression#Left - AST#expression#Left BEGIN AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#update_expression#Right AST#expression#Right AST#update_expression#Right AST#expression#Right AST#ERROR#Left . * ? AST#expression#Left AST#update_expression#Left -- AST#expression#Left AST#update_expression#Left -- AST#expression#Left AST#unary_expression#Left - AST#ERROR#Left | AST#ERROR#Right AST#expression#Left AST#update_expression#Left -- AST#expression#Left AST#update_expression#Left -- AST#expression#Left AST#unary_expression#Left - AST#expression#Left END AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#update_expression#Right AST#expression#Right AST#update_expression#Right AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#update_expression#Right AST#expression#Right AST#update_expression#Right AST#expression#Right AST#ERROR#Left . * AST#ERROR#Right ? AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#update_expression#Left -- AST#expression#Left AST#update_expression#Left -- AST#expression#Left AST#unary_expression#Left - AST#expression#Left AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#update_expression#Right AST#expression#Right AST#update_expression#Right AST#expression#Right AST#ERROR#Left | \s AST#ERROR#Right / AST#expression#Left g AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#ERROR#Right , AST#expression#Left '' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left options = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left util AST#expression#Right . Type AST#member_expression#Right AST#expression#Right . BASIC 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#expression#Right AST#ERROR#Left / \r\n / AST#ERROR#Right . test AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left base64Data AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left options = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left util AST#expression#Right . Type AST#member_expression#Right AST#expression#Right . MIME AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right //转码 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left arr = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Base64Util AST#expression#Right . decodeSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left base64Data AST#expression#Right , AST#expression#Left options AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //返回字符串 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left result = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StrAndUintUtil AST#expression#Right . unitArray2String AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left arr AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class RSASync {
static generateRSAKey(resultCoding: buffer.BufferEncoding = 'base64'): OutDTO<CryptoKey> {
return CryptoSyncUtil.generateCryptoKey('RSA1024', resultCoding);
}
static generate2048RSAKey(resultCoding: buffer.BufferEncoding = 'base64'): OutDTO<CryptoKey> {
return CryptoSyncUtil.generateCryptoKey('RSA2048', resultCoding);
}
static encodePKCS1(str: string, pubKey: string, keyCoding: buffer.BufferEncoding,
resultCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.encodeAsym(str, pubKey, 'RSA1024', 'RSA1024|PKCS1', 1024, keyCoding, resultCoding, isPem);
}
static encodePKCS1Segment(str: string, pubKey: string, keyCoding: buffer.BufferEncoding,
resultCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.encodeAsymSegment(str, pubKey, 'RSA1024', 'RSA1024|PKCS1', 1024, keyCoding, resultCoding,
isPem);
}
static encode2048PKCS1(str: string, pubKey: string, keyCoding: buffer.BufferEncoding,
resultCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.encodeAsym(str, pubKey, 'RSA2048', 'RSA2048|PKCS1', 2048, keyCoding, resultCoding, isPem);
}
static encode2048PKCS1Segment(str: string, pubKey: string, keyCoding: buffer.BufferEncoding,
resultCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.encodeAsymSegment(str, pubKey, 'RSA2048', 'RSA2048|PKCS1', 2048, keyCoding, resultCoding,
isPem);
}
static decodePKCS1(str: string, priKey: string, keyCoding: buffer.BufferEncoding,
dataCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.decodeAsym(str, priKey, 'RSA1024', 'RSA1024|PKCS1', 1024, keyCoding, dataCoding, isPem);
}
static decodePKCS1Segment(str: string, priKey: string, keyCoding: buffer.BufferEncoding,
dataCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.decodeAsymSegment(str, priKey, 'RSA1024', 'RSA1024|PKCS1', 1024, keyCoding, dataCoding,
isPem);
}
static decode2048PKCS1(str: string, priKey: string, keyCoding: buffer.BufferEncoding,
dataCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.decodeAsym(str, priKey, 'RSA2048', 'RSA2048|PKCS1', 2048, keyCoding, dataCoding, isPem);
}
static decode2048PKCS1Segment(str: string, priKey: string, keyCoding: buffer.BufferEncoding,
dataCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.decodeAsymSegment(str, priKey, 'RSA2048', 'RSA2048|PKCS1', 2048, keyCoding, dataCoding,
isPem);
}
static signPKCS1(str: string, priKey: string, keyCoding: buffer.BufferEncoding,
resultCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.sign(str, priKey, 'RSA1024', 'RSA1024|PKCS1|SHA256', 1024, keyCoding, resultCoding, isPem);
}
static sign2048PKCS1(str: string, priKey: string, keyCoding: buffer.BufferEncoding,
resultCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.sign(str, priKey, 'RSA2048', 'RSA2048|PKCS1|SHA256', 2048, keyCoding, resultCoding, isPem);
}
static verify2048PKCS1(signStr: string, verifyStr: string, pubKey: string, keyCoding: buffer.BufferEncoding,
dataCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.verify(signStr, verifyStr, pubKey, 'RSA2048', 'RSA2048|PKCS1|SHA256', 2048, keyCoding,
dataCoding, isPem);
}
static verifyPKCS1(signStr: string, verifyStr: string, pubKey: string, keyCoding: buffer.BufferEncoding,
dataCoding: buffer.BufferEncoding = 'base64', isPem: boolean = false): OutDTO<string> {
return CryptoSyncUtil.verify(signStr, verifyStr, pubKey, 'RSA1024', 'RSA1024|PKCS1|SHA256', 1024, keyCoding,
dataCoding, isPem);
}
static pemToStrKey(pemData: string): string {
const base64Data = pemData.replace(/-----BEGIN .*?-----|-----END .*?-----|\s/g, '');
let options = util.Type.BASIC;
if (/\r\n/.test(base64Data)) {
options = util.Type.MIME;
}
let arr = Base64Util.decodeSync(base64Data, options);
let result = StrAndUintUtil.unitArray2String(arr);
return result;
}
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto_dto/src/main/ets/crypto/encryption/RSASync.ets#L29-L235
|
8db671026fab149a7a858c897bcb15cb18db0169
|
gitee
|
|
awa_Liny/LinysBrowser_NEXT
|
a5cd96a9aa8114cae4972937f94a8967e55d4a10
|
home/src/main/ets/utils/url_tools.ets
|
arkts
|
Determines if a url is a web page or not.
@param url The url to be checked.
@returns True if is a web page that can be displayed.
|
export function is_web_page(url: string): boolean {
// Commonly seen web extensions
const webPageExtensions = [
'.html', '.htm', '.xhtml', '.shtml',
'.php', '.php3', '.php4', '.php5', '.phtml', '.pdf',
'.asp', '.aspx',
'.jsp', '.jspx',
'.cgi',
'.pl',
'.rb', // '.r', // '.r' is what?
'.py',
'.do',
'.action',
'.cfm',
'.dhtml',
'.md',
'.markdown',
'.xml',
'.json',
'.rss',
'.atom'
];
// Remove query and hash part.
const cleanUrl = url.split('?')[0].split('#')[0];
// Check if there are any extension names.
const lastSlashIndex = cleanUrl.lastIndexOf('/');
const lastPart = cleanUrl.substring(lastSlashIndex + 1);
// No extension name, is webpage.
if (!lastPart.includes('.') || lastPart.endsWith('/')) {
return true;
}
// Get extension name
const extension = '.' + lastPart.toLowerCase().split('.').pop()!;
console.log(`[is_web_page] extension: [${extension}]`);
// Check if is in list
return webPageExtensions.includes(extension);
}
|
AST#export_declaration#Left export AST#function_declaration#Left function is_web_page AST#parameter_list#Left ( AST#parameter#Left url : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // Commonly seen web extensions AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left webPageExtensions = AST#expression#Left AST#array_literal#Left [ AST#expression#Left '.html' AST#expression#Right , AST#expression#Left '.htm' AST#expression#Right , AST#expression#Left '.xhtml' AST#expression#Right , AST#expression#Left '.shtml' AST#expression#Right , AST#expression#Left '.php' AST#expression#Right , AST#expression#Left '.php3' AST#expression#Right , AST#expression#Left '.php4' AST#expression#Right , AST#expression#Left '.php5' AST#expression#Right , AST#expression#Left '.phtml' AST#expression#Right , AST#expression#Left '.pdf' AST#expression#Right , AST#expression#Left '.asp' AST#expression#Right , AST#expression#Left '.aspx' AST#expression#Right , AST#expression#Left '.jsp' AST#expression#Right , AST#expression#Left '.jspx' AST#expression#Right , AST#expression#Left '.cgi' AST#expression#Right , AST#expression#Left '.pl' AST#expression#Right , AST#expression#Left '.rb' AST#expression#Right , // '.r', // '.r' is what? AST#expression#Left '.py' AST#expression#Right , AST#expression#Left '.do' AST#expression#Right , AST#expression#Left '.action' AST#expression#Right , AST#expression#Left '.cfm' AST#expression#Right , AST#expression#Left '.dhtml' AST#expression#Right , AST#expression#Left '.md' AST#expression#Right , AST#expression#Left '.markdown' AST#expression#Right , AST#expression#Left '.xml' AST#expression#Right , AST#expression#Left '.json' AST#expression#Right , AST#expression#Left '.rss' AST#expression#Right , AST#expression#Left '.atom' AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // Remove query and hash part. AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left cleanUrl = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left url 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#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . split AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '#' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right [ 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 // Check if there are any extension names. AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left lastSlashIndex = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cleanUrl 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left lastPart = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cleanUrl 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 lastSlashIndex AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // No extension name, is webpage. AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left lastPart AST#expression#Right AST#unary_expression#Right AST#expression#Right . includes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '.' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left lastPart AST#expression#Right AST#binary_expression#Right AST#expression#Right . endsWith AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '/' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#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 // Get extension name AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left extension = AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '.' AST#expression#Right + AST#expression#Left lastPart AST#expression#Right AST#binary_expression#Right AST#expression#Right . toLowerCase AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . 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 . pop AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [is_web_page] extension: [ AST#template_substitution#Left $ { AST#expression#Left extension 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 // Check if is in list 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 webPageExtensions AST#expression#Right . includes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left extension AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export function is_web_page(url: string): boolean {
const webPageExtensions = [
'.html', '.htm', '.xhtml', '.shtml',
'.php', '.php3', '.php4', '.php5', '.phtml', '.pdf',
'.asp', '.aspx',
'.jsp', '.jspx',
'.cgi',
'.pl',
'.rb',
'.py',
'.do',
'.action',
'.cfm',
'.dhtml',
'.md',
'.markdown',
'.xml',
'.json',
'.rss',
'.atom'
];
const cleanUrl = url.split('?')[0].split('#')[0];
const lastSlashIndex = cleanUrl.lastIndexOf('/');
const lastPart = cleanUrl.substring(lastSlashIndex + 1);
if (!lastPart.includes('.') || lastPart.endsWith('/')) {
return true;
}
const extension = '.' + lastPart.toLowerCase().split('.').pop()!;
console.log(`[is_web_page] extension: [${extension}]`);
return webPageExtensions.includes(extension);
}
|
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/utils/url_tools.ets#L403-L444
|
ae37a9628695c3b931318716599db671b71f2e4b
|
gitee
|
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
ef_rcp/src/main/ets/rcp/EfBusinessCodeInterceptor.ets
|
arkts
|
@Author csx
@DateTime 2024/8/15 19:07
@TODO EfBusinessCodeInterceptor 内置针对于业务系统内部请求自定义code拦截器
@Use 详细使用方法以及文档详见ohpm官网,地址https://ohpm.openharmony.cn/#/cn/detail/@yunkss%2Fef_rcp
|
export class EfBusinessCodeInterceptor implements rcp.Interceptor {
/**
* 编码监听
*/
private businessCodeEventListener: efRcpConfig.businessCodeEvent;
constructor(businessCodeEventListener: efRcpConfig.businessCodeEvent) {
this.businessCodeEventListener = businessCodeEventListener;
}
/**
* 拦截器
* @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);
}
}
/**
* 使用正则表达式提取 JSON 片段
* @param jsonStr 待提取的json字符串
* @param key 传入的key
* @returns
*/
extractJsonFragment(jsonStr: string, key: string): string | null {
// 构建正则表达式来匹配指定的键及其值
// 使用非贪婪匹配来处理可能的嵌套情况
const regex = new RegExp(`"${key}":\\s*"([^"]*)"`, 's');
const match = jsonStr.match(regex);
return match ? match[0] : null;
}
/**
* 解析 JSON 片段并提取值
* @param jsonFragment 提取的json片段
* @param key 待提取的key
* @returns
*/
getValueFromJsonFragment(jsonFragment: string, key: string): Object | null {
try {
// 因为 jsonFragment 可能是键值对的一部分,需要添加大括号来形成合法的 JSON
const fragmentObject: Record<string, Object> = JSON.parse(`{${jsonFragment}}`);
return fragmentObject[key];
} catch (error) {
console.error('提起json的key错误:', error);
return null;
}
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class EfBusinessCodeInterceptor AST#implements_clause#Left implements AST#implements_clause#Right AST#ERROR#Left AST#qualified_type#Left rcp . Interceptor AST#qualified_type#Right AST#ERROR#Right AST#class_body#Left { /**
* 编码监听
*/ AST#property_declaration#Left private businessCodeEventListener : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left efRcpConfig . businessCodeEvent AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left businessCodeEventListener : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left efRcpConfig . businessCodeEvent 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . businessCodeEventListener AST#member_expression#Right = AST#expression#Left businessCodeEventListener 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 /**
* 拦截器
* @param context
* @param next
* @returns
*/ 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 /**
* 使用正则表达式提取 JSON 片段
* @param jsonStr 待提取的json字符串
* @param key 传入的key
* @returns
*/ AST#method_declaration#Left extractJsonFragment AST#parameter_list#Left ( AST#parameter#Left jsonStr : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { // 构建正则表达式来匹配指定的键及其值 // 使用非贪婪匹配来处理可能的嵌套情况 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left regex = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left RegExp AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` " AST#template_substitution#Left $ { AST#expression#Left key AST#expression#Right } AST#template_substitution#Right ": \\ s*"([^"]*)" ` AST#template_literal#Right AST#expression#Right , AST#expression#Left 's' 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 match = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left jsonStr AST#expression#Right . match AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left regex AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#conditional_expression#Left AST#expression#Left match AST#expression#Right ? AST#expression#Left AST#subscript_expression#Left AST#expression#Left match AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right : AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 解析 JSON 片段并提取值
* @param jsonFragment 提取的json片段
* @param key 待提取的key
* @returns
*/ AST#method_declaration#Left getValueFromJsonFragment AST#parameter_list#Left ( AST#parameter#Left jsonFragment : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Object AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 因为 jsonFragment 可能是键值对的一部分,需要添加大括号来形成合法的 JSON AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left fragmentObject : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` { AST#template_substitution#Left $ { AST#expression#Left jsonFragment 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#subscript_expression#Left AST#expression#Left fragmentObject AST#expression#Right [ AST#expression#Left key AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '提起json的key错误:' 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#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 } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class EfBusinessCodeInterceptor implements rcp.Interceptor {
private businessCodeEventListener: efRcpConfig.businessCodeEvent;
constructor(businessCodeEventListener: efRcpConfig.businessCodeEvent) {
this.businessCodeEventListener = businessCodeEventListener;
}
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);
}
}
extractJsonFragment(jsonStr: string, key: string): string | null {
const regex = new RegExp(`"${key}":\\s*"([^"]*)"`, 's');
const match = jsonStr.match(regex);
return match ? match[0] : null;
}
getValueFromJsonFragment(jsonFragment: string, key: string): Object | null {
try {
const fragmentObject: Record<string, Object> = JSON.parse(`{${jsonFragment}}`);
return fragmentObject[key];
} catch (error) {
console.error('提起json的key错误:', error);
return null;
}
}
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_rcp/src/main/ets/rcp/EfBusinessCodeInterceptor.ets#L27-L116
|
ff5ade42c93d14361a323412aca144ed3f37af40
|
gitee
|
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/PasteboardUtil.ets
|
arkts
|
getData
|
读取系统剪贴板内容,使用Promise异步回调。
@returns
|
static async getData(): Promise<pasteboard.PasteData> {
return PasteboardUtil.getSystemPasteboard().getData();
}
|
AST#method_declaration#Left static async getData 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 pasteboard . PasteData 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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PasteboardUtil AST#expression#Right . getSystemPasteboard AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getData 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 async getData(): Promise<pasteboard.PasteData> {
return PasteboardUtil.getSystemPasteboard().getData();
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/PasteboardUtil.ets#L92-L94
|
8aabf36d3b3c46ffe63fc52b277b4e2e320ba0e1
|
gitee
|
wuyuanwuhui99/harmony-arkts-music-app-ui.git
|
fc75b993b76293666f9122f527ea3bc6caf7f75c
|
entry/src/main/ets/utils/HttpUtil.ets
|
arkts
|
post
|
@description: post请求函数
@param {string} url 请求地址
@param {Object} data 请求参数
@param {RequestConfig} OtherConfig request其他配置
@return {*}
|
public post<T>(url: string, data?: Object): Promise<MyAwesomeData<T>> {
return this.request<T>(url,{ method: http.RequestMethod.POST,extraData: data})
}
|
AST#method_declaration#Left public post AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left url : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left data ? : 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 AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left MyAwesomeData 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#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 this AST#expression#Right . request AST#member_expression#Right AST#expression#Right 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#argument_list#Left ( AST#expression#Left url AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left method AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . RequestMethod AST#member_expression#Right AST#expression#Right . POST AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left extraData AST#property_name#Right : AST#expression#Left data 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
|
public post<T>(url: string, data?: Object): Promise<MyAwesomeData<T>> {
return this.request<T>(url,{ method: http.RequestMethod.POST,extraData: data})
}
|
https://github.com/wuyuanwuhui99/harmony-arkts-music-app-ui.git/blob/fc75b993b76293666f9122f527ea3bc6caf7f75c/entry/src/main/ets/utils/HttpUtil.ets#L105-L107
|
3547c08dda74e30314a6be3c3db1a1cef7d4f6a3
|
github
|
harmonyos/samples
|
f5d967efaa7666550ee3252d118c3c73a77686f5
|
ETSUI/CategorySample/entry/src/main/ets/common/bean/IndexListItem.ets
|
arkts
|
Item info of the index list(vertical list on the left).
|
export class IndexListItem {
/**
* List item title.
*/
title: Resource;
}
|
AST#export_declaration#Left export AST#class_declaration#Left class IndexListItem AST#class_body#Left { /**
* List item title.
*/ AST#property_declaration#Left title : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class IndexListItem {
title: Resource;
}
|
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/ETSUI/CategorySample/entry/src/main/ets/common/bean/IndexListItem.ets#L4-L9
|
dbed60115aa7ef0f2fa611e213aa2662d7d41d60
|
gitee
|
|
zqaini002/YaoYaoLingXian.git
|
5095b12cbeea524a87c42d0824b1702978843d39
|
YaoYaoLingXian/entry/src/main/ets/pages/community/CommunityPage.ets
|
arkts
|
handleLike
|
处理点赞
|
async handleLike(post: Post) {
try {
if (post.isLiked) {
await ApiService.unlikePost(post.id);
post.likeCount = Math.max(0, post.likeCount - 1);
} else {
await ApiService.likePost(post.id);
post.likeCount++;
}
post.isLiked = !post.isLiked;
} catch (error) {
console.error(`点赞操作失败: ${error instanceof Error ? error.message : String(error)}`);
// 创建提示配置对象
interface ToastOptions {
message: string;
duration: number;
}
const toastOptions: ToastOptions = {
message: `操作失败: ${error instanceof Error ? error.message : String(error)}`,
duration: 2000
};
promptAction.showToast(toastOptions);
}
|
AST#method_declaration#Left async handleLike AST#parameter_list#Left ( AST#parameter#Left post : AST#type_annotation#Left AST#primary_type#Left Post AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . isLiked 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#await_expression#Left await AST#expression#Left ApiService AST#expression#Right AST#await_expression#Right AST#expression#Right . unlikePost AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . likeCount AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . max AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . likeCount AST#member_expression#Right AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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#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 . likePost AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#update_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . likeCount AST#member_expression#Right AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . isLiked AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left post AST#expression#Right AST#unary_expression#Right AST#expression#Right . isLiked 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#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 点赞操作失败: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left error AST#expression#Right instanceof AST#expression#Left Error AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right : AST#expression#Left String AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 创建提示配置对象 AST#statement#Left AST#expression_statement#Left AST#expression#Left interface AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left ToastOptions AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left string AST#expression#Right AST#property_assignment#Right AST#object_literal#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left duration 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_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left toastOptions : 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#call_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left error AST#expression#Right instanceof AST#expression#Left Error AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right : AST#expression#Left String AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#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 toastOptions 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
|
async handleLike(post: Post) {
try {
if (post.isLiked) {
await ApiService.unlikePost(post.id);
post.likeCount = Math.max(0, post.likeCount - 1);
} else {
await ApiService.likePost(post.id);
post.likeCount++;
}
post.isLiked = !post.isLiked;
} catch (error) {
console.error(`点赞操作失败: ${error instanceof Error ? error.message : String(error)}`);
interface ToastOptions {
message: string;
duration: number;
}
const toastOptions: ToastOptions = {
message: `操作失败: ${error instanceof Error ? error.message : String(error)}`,
duration: 2000
};
promptAction.showToast(toastOptions);
}
|
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/pages/community/CommunityPage.ets#L101-L125
|
1333f3064e856cc649eccbb0d7ef0fc403742322
|
github
|
awa_Liny/LinysBrowser_NEXT
|
a5cd96a9aa8114cae4972937f94a8967e55d4a10
|
home/src/main/ets/hosts/bunch_of_tabs.ets
|
arkts
|
update_backward_forward_access
|
Data and Statuses
Updates the current_accessBackward and current_accessForward statuses.
|
update_backward_forward_access() {
if (this.workingMainTab()) {
try {
this.current_accessBackward = this.workingMainTab().controller?.accessBackward() || false;
this.current_accessForward = this.workingMainTab().controller?.accessForward() || false;
} catch (e) {
console.error('[bunch_of_tabs][update_backward_forward_access] Error: ' + e);
}
}
}
|
AST#method_declaration#Left update_backward_forward_access AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . workingMainTab AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . current_accessBackward 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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . workingMainTab AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . controller AST#member_expression#Right AST#expression#Right ?. accessBackward 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#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#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 . current_accessForward 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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . workingMainTab AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . controller AST#member_expression#Right AST#expression#Right ?. accessForward 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#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( e ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left '[bunch_of_tabs][update_backward_forward_access] Error: ' AST#expression#Right + AST#expression#Left e AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
update_backward_forward_access() {
if (this.workingMainTab()) {
try {
this.current_accessBackward = this.workingMainTab().controller?.accessBackward() || false;
this.current_accessForward = this.workingMainTab().controller?.accessForward() || false;
} catch (e) {
console.error('[bunch_of_tabs][update_backward_forward_access] Error: ' + e);
}
}
}
|
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/hosts/bunch_of_tabs.ets#L203-L212
|
5287e4871609adcbb99f164dbb87026bde0a1d01
|
gitee
|
openharmony-tpc/ohos_mpchart
|
4fb43a7137320ef2fee2634598f53d93975dfb4a
|
library/src/main/ets/components/components/AxisBase.ets
|
arkts
|
setAxisMinLabels
|
The minimum number of labels on the axis
|
public setAxisMinLabels(labels: number): void {
if (labels > 0)
this.mAxisMinLabels = labels;
}
|
AST#method_declaration#Left public setAxisMinLabels AST#parameter_list#Left ( AST#parameter#Left labels : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left labels AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#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 . mAxisMinLabels AST#member_expression#Right = AST#expression#Left labels AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public setAxisMinLabels(labels: number): void {
if (labels > 0)
this.mAxisMinLabels = labels;
}
|
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/components/AxisBase.ets#L157-L160
|
a4019d294ba856b218208430914308fa8d2dc96d
|
gitee
|
openharmony-tpc/ohos_mpchart
|
4fb43a7137320ef2fee2634598f53d93975dfb4a
|
library/src/main/ets/components/components/YAxis.ets
|
arkts
|
removeYAxisCustomLabel
|
Delete Y-axis custom labels
@param numbers labels
|
public removeYAxisCustomLabel(numbers: number[]): void {
let YAxisLabels: number[] = [];
if (numbers != null && numbers != undefined) {
let flag: boolean = false;
for (let i: number = 0; i < this.customYAxisLabels.length; i ++){
flag = false;
for (let index: number = 0; index < numbers.length; index ++){
if (this.customYAxisLabels[i] == numbers[index]) {
flag = true;
break;
}
}
if (!flag) {
YAxisLabels.push(this.customYAxisLabels[i]);
}
}
this.customYAxisLabels = YAxisLabels;
}
}
|
AST#method_declaration#Left public removeYAxisCustomLabel AST#parameter_list#Left ( AST#parameter#Left numbers : 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#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 YAxisLabels : 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left numbers AST#expression#Right != AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left numbers AST#expression#Right != AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left flag : 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#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#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . customYAxisLabels 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left flag = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left 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 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 index AST#expression#Right < AST#expression#Left numbers 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 index AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . customYAxisLabels AST#member_expression#Right AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right == AST#expression#Left AST#subscript_expression#Left AST#expression#Left numbers AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_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 flag = 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#break_statement#Left break ; AST#break_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left flag 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 YAxisLabels AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . customYAxisLabels AST#member_expression#Right AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . customYAxisLabels AST#member_expression#Right = AST#expression#Left YAxisLabels AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public removeYAxisCustomLabel(numbers: number[]): void {
let YAxisLabels: number[] = [];
if (numbers != null && numbers != undefined) {
let flag: boolean = false;
for (let i: number = 0; i < this.customYAxisLabels.length; i ++){
flag = false;
for (let index: number = 0; index < numbers.length; index ++){
if (this.customYAxisLabels[i] == numbers[index]) {
flag = true;
break;
}
}
if (!flag) {
YAxisLabels.push(this.customYAxisLabels[i]);
}
}
this.customYAxisLabels = YAxisLabels;
}
}
|
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/components/YAxis.ets#L151-L169
|
85d78379a8a6ea80e85e67e6fdd654b101c81cbb
|
gitee
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/VPNControl_Case/entry/src/main/ets/notification/NotificationManagementUtil.ets
|
arkts
|
setBadgeNumber
|
Display badge
|
async setBadgeNumber(num: number) {
await notificationManager.setBadgeNumber(num).then(() => {
this.badgeNum = num;
Logger.info('displayBadge success');
});
}
|
AST#method_declaration#Left async setBadgeNumber 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#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left notificationManager AST#expression#Right AST#await_expression#Right AST#expression#Right . setBadgeNumber AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left num AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . badgeNum AST#member_expression#Right = AST#expression#Left num 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 Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'displayBadge 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#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 setBadgeNumber(num: number) {
await notificationManager.setBadgeNumber(num).then(() => {
this.badgeNum = num;
Logger.info('displayBadge success');
});
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/VPNControl_Case/entry/src/main/ets/notification/NotificationManagementUtil.ets#L61-L66
|
1d4ed1573f9be1e27f169ba6f7ead67f9d0d2cfd
|
gitee
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/variablewatch/src/main/ets/model/GoodsModel.ets
|
arkts
|
SecondGoodsItemList
|
TODO: 知识点:使用@Observed装饰器,为了做到类的嵌套也可以被观察到属性的变化
|
@Observed
/**
* 表示商品列表的类型,是嵌套类的第二层
* @class
*/
export class SecondGoodsItemList {
itemList: Array<ThirdGoodsItem>;
constructor(imgSrc: Array<ThirdGoodsItem>) {
this.itemList = imgSrc;
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Observed AST#decorator#Right /**
* 表示商品列表的类型,是嵌套类的第二层
* @class
*/ export class SecondGoodsItemList AST#class_body#Left { AST#property_declaration#Left itemList : 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 ThirdGoodsItem AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left imgSrc : 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 ThirdGoodsItem AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . itemList AST#member_expression#Right = AST#expression#Left imgSrc 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#decorated_export_declaration#Right
|
@Observed
export class SecondGoodsItemList {
itemList: Array<ThirdGoodsItem>;
constructor(imgSrc: Array<ThirdGoodsItem>) {
this.itemList = imgSrc;
}
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/variablewatch/src/main/ets/model/GoodsModel.ets#L33-L44
|
6e9bffbbb78aa9bb13c0dfab497a32acbd37005a
|
gitee
|
ThePivotPoint/ArkTS-LSP-Server-Plugin.git
|
6231773905435f000d00d94b26504433082ba40b
|
packages/declarations/ets/api/@ohos.arkui.advanced.Chip.d.ets
|
arkts
|
Defines label margin.
@interface LabelMarginOptions
@syscap SystemCapability.ArkUI.ArkUI.Full
@crossplatform
@since 11
Defines label margin.
@interface LabelMarginOptions
@syscap SystemCapability.ArkUI.ArkUI.Full
@crossplatform
@atomicservice
@since 12
|
export interface LabelMarginOptions {
/**
* Left label margin length.
*
* @type { ?Dimension }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/
/**
* Left label margin length.
*
* @type { ?Dimension }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
left?: Dimension;
/**
* Right label margin length.
*
* @type { ?Dimension }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/
/**
* Right label margin length.
*
* @type { ?Dimension }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
right?: Dimension;
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface LabelMarginOptions AST#object_type#Left { /**
* Left label margin length.
*
* @type { ?Dimension }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/ /**
* Left label margin length.
*
* @type { ?Dimension }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/ AST#type_member#Left left ? : AST#type_annotation#Left AST#primary_type#Left Dimension AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /**
* Right label margin length.
*
* @type { ?Dimension }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/ /**
* Right label margin length.
*
* @type { ?Dimension }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/ AST#type_member#Left right ? : AST#type_annotation#Left AST#primary_type#Left Dimension 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 LabelMarginOptions {
left?: Dimension;
right?: Dimension;
}
|
https://github.com/ThePivotPoint/ArkTS-LSP-Server-Plugin.git/blob/6231773905435f000d00d94b26504433082ba40b/packages/declarations/ets/api/@ohos.arkui.advanced.Chip.d.ets#L262-L299
|
53819719124bee3619481f44806d070b0058da80
|
github
|
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/ai/ModelConfigService.ets
|
arkts
|
saveModelConfig
|
保存模型配置
|
public saveModelConfig(config: ModelConfig): void {
this.currentConfig = config;
// 存储到内存映射中
ModelConfigService.configStore.set('current', config);
this.storeConfig();
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP,
`[ModelConfigService] Model config saved and stored: ${config.provider}/${config.modelId}`);
}
|
AST#method_declaration#Left public saveModelConfig AST#parameter_list#Left ( AST#parameter#Left config : AST#type_annotation#Left AST#primary_type#Left ModelConfig 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 . currentConfig AST#member_expression#Right = AST#expression#Left config AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right // 存储到内存映射中 AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ModelConfigService AST#expression#Right . configStore AST#member_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'current' AST#expression#Right , AST#expression#Left config 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 . storeConfig AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 ` [ModelConfigService] Model config saved and stored: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . provider AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right / AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . modelId AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
public saveModelConfig(config: ModelConfig): void {
this.currentConfig = config;
ModelConfigService.configStore.set('current', config);
this.storeConfig();
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP,
`[ModelConfigService] Model config saved and stored: ${config.provider}/${config.modelId}`);
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/ai/ModelConfigService.ets#L336-L345
|
bd87d5c8b807ab7f3dd0a065a9f6252adebdf506
|
github
|
qwerguai/ArkTSComponents.git
|
58ac77d9686670d79ba7421d71e68f31870aacd5
|
entry/src/main/ets/common/constants/CommonConstants.ets
|
arkts
|
Common constants for all features.
|
export default class CommonConstants {
/**
* Input length of the account.
*/
static readonly INPUT_ACCOUNT_LENGTH = 11;
/**
* Input length of the password.
*/
static readonly INPUT_PASSWORD_LENGTH = 8;
/**
* Left padding of the input box
*/
static readonly INPUT_PADDING_LEFT = 0;
/**
* Delay time of simulated login
*/
static readonly LOGIN_DELAY_TIME = 2000;
/**
* Common Spacing of Components
*/
static readonly COMMON_SPACE = 12;
/**
* Title text of the home page
*/
static readonly HOME_TITLE = '主页';
/**
* Title text of the setting page
*/
static readonly MINE_TITLE = '我的';
/**
* Spacing of other login methods
*/
static readonly LOGIN_METHODS_SPACE = 44;
/**
* The width or height of the component is spread across the parent component.
*/
static readonly FULL_PARENT = '100%';
/**
* The width of button
*/
static readonly BUTTON_WIDTH = '90%';
/**
* The width of setting list
*/
static readonly SET_LIST_WIDTH = '42%';
/**
* Home tab index
*/
static readonly HOME_TAB_INDEX = 0;
/**
* Mine tab index
*/
static readonly MINE_TAB_INDEX = 1;
}
|
AST#export_declaration#Left export default AST#class_declaration#Left class CommonConstants AST#class_body#Left { /**
* Input length of the account.
*/ AST#property_declaration#Left static readonly INPUT_ACCOUNT_LENGTH = AST#expression#Left 11 AST#expression#Right ; AST#property_declaration#Right /**
* Input length of the password.
*/ AST#property_declaration#Left static readonly INPUT_PASSWORD_LENGTH = AST#expression#Left 8 AST#expression#Right ; AST#property_declaration#Right /**
* Left padding of the input box
*/ AST#property_declaration#Left static readonly INPUT_PADDING_LEFT = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right /**
* Delay time of simulated login
*/ AST#property_declaration#Left static readonly LOGIN_DELAY_TIME = AST#expression#Left 2000 AST#expression#Right ; AST#property_declaration#Right /**
* Common Spacing of Components
*/ AST#property_declaration#Left static readonly COMMON_SPACE = AST#expression#Left 12 AST#expression#Right ; AST#property_declaration#Right /**
* Title text of the home page
*/ AST#property_declaration#Left static readonly HOME_TITLE = AST#expression#Left '主页' AST#expression#Right ; AST#property_declaration#Right /**
* Title text of the setting page
*/ AST#property_declaration#Left static readonly MINE_TITLE = AST#expression#Left '我的' AST#expression#Right ; AST#property_declaration#Right /**
* Spacing of other login methods
*/ AST#property_declaration#Left static readonly LOGIN_METHODS_SPACE = AST#expression#Left 44 AST#expression#Right ; AST#property_declaration#Right /**
* The width or height of the component is spread across the parent component.
*/ AST#property_declaration#Left static readonly FULL_PARENT = AST#expression#Left '100%' AST#expression#Right ; AST#property_declaration#Right /**
* The width of button
*/ AST#property_declaration#Left static readonly BUTTON_WIDTH = AST#expression#Left '90%' AST#expression#Right ; AST#property_declaration#Right /**
* The width of setting list
*/ AST#property_declaration#Left static readonly SET_LIST_WIDTH = AST#expression#Left '42%' AST#expression#Right ; AST#property_declaration#Right /**
* Home tab index
*/ AST#property_declaration#Left static readonly HOME_TAB_INDEX = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right /**
* Mine tab index
*/ AST#property_declaration#Left static readonly MINE_TAB_INDEX = AST#expression#Left 1 AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export default class CommonConstants {
static readonly INPUT_ACCOUNT_LENGTH = 11;
static readonly INPUT_PASSWORD_LENGTH = 8;
static readonly INPUT_PADDING_LEFT = 0;
static readonly LOGIN_DELAY_TIME = 2000;
static readonly COMMON_SPACE = 12;
static readonly HOME_TITLE = '主页';
static readonly MINE_TITLE = '我的';
static readonly LOGIN_METHODS_SPACE = 44;
static readonly FULL_PARENT = '100%';
static readonly BUTTON_WIDTH = '90%';
static readonly SET_LIST_WIDTH = '42%';
static readonly HOME_TAB_INDEX = 0;
static readonly MINE_TAB_INDEX = 1;
}
|
https://github.com/qwerguai/ArkTSComponents.git/blob/58ac77d9686670d79ba7421d71e68f31870aacd5/entry/src/main/ets/common/constants/CommonConstants.ets#L19-L84
|
2badcfd6a50bb4f6f4d661e7401acc58613d40d0
|
github
|
|
Joker-x-dev/HarmonyKit.git
|
f97197ce157df7f303244fba42e34918306dfb08
|
entry/src/main/ets/navigation/NavigationHost.ets
|
arkts
|
PagesMap
|
导航目标构建器
@param name 路由名称
@returns 路由构建器
|
@Builder
PagesMap(name: string) {
if (RouteBuild.getBuilder(name) !== undefined) {
(RouteBuild.getBuilder(name) as WrappedBuilder<[]>).builder();
}
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right PagesMap AST#parameter_list#Left ( AST#parameter#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left RouteBuild AST#expression#Right . getBuilder AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left name AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right !== AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left RouteBuild AST#expression#Right . getBuilder AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left name AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as 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#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#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . builder AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
PagesMap(name: string) {
if (RouteBuild.getBuilder(name) !== undefined) {
(RouteBuild.getBuilder(name) as WrappedBuilder<[]>).builder();
}
}
|
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/entry/src/main/ets/navigation/NavigationHost.ets#L25-L30
|
f58b74b032d13ab2ffe0b5daf8a839df3a8ac06f
|
github
|
openharmony/arkui_ace_engine
|
30c7d1ee12fbedf0fabece54291d75897e2ad44f
|
examples/Overlay/entry/src/main/ets/pages/components/base/MyComponent.ets
|
arkts
|
MyComponent
|
Copyright (c) 2025 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
@Preview
@Component
export struct MyComponent {
title: string = 'test'
func: () => void = () => {}
@Styles pressedStyle(){
.backgroundColor(0x238E23)
}
@Styles normalStyles() {
.backgroundColor(0x0000ff)
}
build() {
Text(this.title)
.key(this.title)
.fontSize(20)
.backgroundColor(0x0000ff)
.fontColor(0xffffff)
.padding(5)
.onClick(this.func)
.stateStyles({pressed: this.pressedStyle, normal: this.normalStyles})
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Preview AST#decorator#Right AST#decorator#Left @ Component AST#decorator#Right export struct MyComponent AST#component_body#Left { AST#property_declaration#Left title : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left = AST#expression#Left AST#call_expression#Left AST#expression#Left 'test' AST#expression#Right AST#ERROR#Left func : AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right => void AST#ERROR#Right = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right AST#property_declaration#Right AST#method_declaration#Left AST#decorator#Left @ Styles AST#decorator#Right pressedStyle AST#parameter_list#Left ( ) AST#parameter_list#Right AST#extend_function_body#Left { AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0x238E23 AST#expression#Right ) AST#modifier_chain_expression#Right } AST#extend_function_body#Right AST#method_declaration#Right AST#method_declaration#Left AST#decorator#Left @ Styles AST#decorator#Right normalStyles AST#parameter_list#Left ( ) AST#parameter_list#Right AST#extend_function_body#Left { AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0x0000ff AST#expression#Right ) AST#modifier_chain_expression#Right } AST#extend_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 Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . title AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . key ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . title AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0x0000ff AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left 0xffffff AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left 5 AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . func AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . stateStyles ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left pressed AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . pressedStyle AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left normal AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . normalStyles 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#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Preview
@Component
export struct MyComponent {
title: string = 'test'
func: () => void = () => {}
@Styles pressedStyle(){
.backgroundColor(0x238E23)
}
@Styles normalStyles() {
.backgroundColor(0x0000ff)
}
build() {
Text(this.title)
.key(this.title)
.fontSize(20)
.backgroundColor(0x0000ff)
.fontColor(0xffffff)
.padding(5)
.onClick(this.func)
.stateStyles({pressed: this.pressedStyle, normal: this.normalStyles})
}
}
|
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/examples/Overlay/entry/src/main/ets/pages/components/base/MyComponent.ets#L16-L40
|
40f872a72b63ffdebec4c86e2c1a16a862c1d2a2
|
gitee
|
open9527/OpenHarmony
|
fdea69ed722d426bf04e817ec05bff4002e81a4e
|
entry/src/main/ets/pages/example/debug/network/NetworkPanelViews.ets
|
arkts
|
@author open_9527
@date 2025/11/3
@desc NetworkPanelViews
|
export enum NetworkPanelMode {
Name = 'Name',
Method = 'Method',
Status = 'Status',
Time = 'Time'
}
|
AST#export_declaration#Left export AST#enum_declaration#Left enum NetworkPanelMode AST#enum_body#Left { AST#enum_member#Left Name = AST#expression#Left 'Name' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left Method = AST#expression#Left 'Method' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left Status = AST#expression#Left 'Status' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left Time = AST#expression#Left 'Time' AST#expression#Right AST#enum_member#Right } AST#enum_body#Right AST#enum_declaration#Right AST#export_declaration#Right
|
export enum NetworkPanelMode {
Name = 'Name',
Method = 'Method',
Status = 'Status',
Time = 'Time'
}
|
https://github.com/open9527/OpenHarmony/blob/fdea69ed722d426bf04e817ec05bff4002e81a4e/entry/src/main/ets/pages/example/debug/network/NetworkPanelViews.ets#L10-L15
|
3c13d0b2bdf1e8e7a1d43a73b3eb674c401552ad
|
gitee
|
|
wangjinyuan/JS-TS-ArkTS-database.git
|
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
|
npm/alprazolamdiv/11.5.1/package/src/client/websocket/packets/handlers/PresenceUpdate.ets
|
arkts
|
Emitted whenever a member becomes available
@event Client#guildMemberAvailable
@param member The member that became available
应用规则60:使用export代替module.exports
|
export default PresenceUpdateHandler;
|
AST#export_declaration#Left export default AST#expression#Left PresenceUpdateHandler AST#expression#Right ; AST#export_declaration#Right
|
export default PresenceUpdateHandler;
|
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/client/websocket/packets/handlers/PresenceUpdate.ets#L102-L102
|
bd11e23ae7c374b7f88d652b8a74792fbbc180d1
|
github
|
|
harmonyos/samples
|
f5d967efaa7666550ee3252d118c3c73a77686f5
|
ETSUI/TransitionAnimation/entry/src/main/ets/pages/page/CustomTransition2.ets
|
arkts
|
pageTransition
|
页面转场通过全局transition方法进行配置转场参数
|
pageTransition() {
// 页面入场组件: 进场过程中会逐帧触发onEnter回调,入参为动效的归一化进度(0% -- 100%)
PageTransitionEnter({ duration: 800, curve: Curve.Smooth })
.onEnter((type?: RouteType, progress?: number) => {
if (progress !== undefined) {
this.myProgress = progress // 页面入场时myProgress从0变化到1
}
})
// 页面退场组件: 进场过程中会逐帧触发onExit回调,入参为动效的归一化进度(0% -- 100%)
PageTransitionExit({ duration: 1000, curve: Curve.Smooth })
.onExit((type?: RouteType, progress?: number) => {
if (progress !== undefined) {
this.myProgress = 1 - progress // 页面退场式myProgress从1变化到0
}
})
}
|
AST#method_declaration#Left pageTransition AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { // 页面入场组件: 进场过程中会逐帧触发onEnter回调,入参为动效的归一化进度(0% -- 100%) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left PageTransitionEnter ( AST#component_parameters#Left { AST#component_parameter#Left duration : AST#expression#Left 800 AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left curve : AST#expression#Left AST#member_expression#Left AST#expression#Left Curve AST#expression#Right . Smooth AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . onEnter ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left type ? : AST#type_annotation#Left AST#primary_type#Left RouteType AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left progress ? : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left progress AST#expression#Right !== AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . myProgress AST#member_expression#Right = AST#expression#Left progress AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // 页面入场时myProgress从0变化到1 } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 页面退场组件: 进场过程中会逐帧触发onExit回调,入参为动效的归一化进度(0% -- 100%) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left PageTransitionExit ( AST#component_parameters#Left { AST#component_parameter#Left duration : AST#expression#Left 1000 AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left curve : AST#expression#Left AST#member_expression#Left AST#expression#Left Curve AST#expression#Right . Smooth AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . onExit ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left type ? : AST#type_annotation#Left AST#primary_type#Left RouteType AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left progress ? : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left progress AST#expression#Right !== AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . myProgress AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left 1 AST#expression#Right - AST#expression#Left progress AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // 页面退场式myProgress从1变化到0 } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
pageTransition() {
PageTransitionEnter({ duration: 800, curve: Curve.Smooth })
.onEnter((type?: RouteType, progress?: number) => {
if (progress !== undefined) {
this.myProgress = progress
}
})
PageTransitionExit({ duration: 1000, curve: Curve.Smooth })
.onExit((type?: RouteType, progress?: number) => {
if (progress !== undefined) {
this.myProgress = 1 - progress
}
})
}
|
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/ETSUI/TransitionAnimation/entry/src/main/ets/pages/page/CustomTransition2.ets#L38-L54
|
fc02d6731614fdef6b49a3c0254713956084001c
|
gitee
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Distributed/DistributeDraw/entry/src/main/ets/common/utils/RemoteDeviceUtil.ets
|
arkts
|
getTrustedDeviceList
|
Obtain the list of trusted devices.
|
getTrustedDeviceList(): void {
if (this.myDeviceManager === undefined) {
Logger.error('RemoteDeviceModel', 'getTrustedDeviceList deviceManager has not initialized');
return;
}
try {
this.trustedDeviceList = this.myDeviceManager.getTrustedDeviceListSync();
} catch (error) {
Logger.error('RemoteDeviceModel',
`getTrustedDeviceList failed error=${JSON.stringify(error)}`);
}
}
|
AST#method_declaration#Left getTrustedDeviceList AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . myDeviceManager AST#member_expression#Right AST#expression#Right === AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#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 'RemoteDeviceModel' AST#expression#Right , AST#expression#Left 'getTrustedDeviceList deviceManager has 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . trustedDeviceList 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 . myDeviceManager AST#member_expression#Right AST#expression#Right . getTrustedDeviceListSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'RemoteDeviceModel' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` getTrustedDeviceList failed error= AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
getTrustedDeviceList(): void {
if (this.myDeviceManager === undefined) {
Logger.error('RemoteDeviceModel', 'getTrustedDeviceList deviceManager has not initialized');
return;
}
try {
this.trustedDeviceList = this.myDeviceManager.getTrustedDeviceListSync();
} catch (error) {
Logger.error('RemoteDeviceModel',
`getTrustedDeviceList failed error=${JSON.stringify(error)}`);
}
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Distributed/DistributeDraw/entry/src/main/ets/common/utils/RemoteDeviceUtil.ets#L105-L117
|
a8feec3810b1e3a9f111cb7c93b5e12d2892a172
|
gitee
|
IceYuanyyy/OxHornCampus.git
|
bb5686f77fa36db89687502e35898cda218d601f
|
entry/src/main/ets/view/AiAssistantComponent.ets
|
arkts
|
scrollToBottom
|
滚动到底部
|
scrollToBottom() {
setTimeout(() => {
this.scroller.scrollEdge(Edge.Bottom);
}, 100);
}
|
AST#method_declaration#Left scrollToBottom AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_custom_component_statement#Left setTimeout ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scroller AST#member_expression#Right AST#expression#Right . scrollEdge AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Edge 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#block_statement#Right AST#arrow_function#Right AST#expression#Right , AST#expression#Left 100 AST#expression#Right ) ; AST#ui_custom_component_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
scrollToBottom() {
setTimeout(() => {
this.scroller.scrollEdge(Edge.Bottom);
}, 100);
}
|
https://github.com/IceYuanyyy/OxHornCampus.git/blob/bb5686f77fa36db89687502e35898cda218d601f/entry/src/main/ets/view/AiAssistantComponent.ets#L130-L134
|
903dcd52771e13a730e4d2c1004ea2234940ded4
|
github
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/SystemFeature/Media/VoiceCallDemo/entry/src/main/ets/controller/IndexController.ets
|
arkts
|
isSpeakerActive
|
扬声器是否激活
|
async isSpeakerActive(): Promise<boolean> {
return await AudioManagerModel.isSpeakerActive();
}
|
AST#method_declaration#Left async isSpeakerActive AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left AudioManagerModel AST#expression#Right AST#await_expression#Right AST#expression#Right . isSpeakerActive 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
|
async isSpeakerActive(): Promise<boolean> {
return await AudioManagerModel.isSpeakerActive();
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/Media/VoiceCallDemo/entry/src/main/ets/controller/IndexController.ets#L166-L168
|
c5a55f4da850a7a166ffb36a118d2201febbd4a6
|
gitee
|
BohanSu/LumosAgent-HarmonyOS.git
|
9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76
|
entry/src/main/ets/model/MoodEntry.ets
|
arkts
|
getEmotionColor
|
Get emotion color (unified with Constants)
|
getEmotionColor(): string {
switch (this.emotion) {
case 'happy':
return Constants.EMOTION_HAPPY;
case 'excited':
return Constants.EMOTION_EXCITED;
case 'sad':
return Constants.EMOTION_SAD;
case 'calm':
return Constants.EMOTION_CALM;
case 'angry':
return Constants.EMOTION_ANGRY;
case 'surprised':
return Constants.EMOTION_SURPRISED;
default:
return Constants.EMOTION_NEUTRAL;
}
|
AST#method_declaration#Left getEmotionColor AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left switch AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . emotion AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left 'happy' AST#expression#Right AST#expression_statement#Right : AST#ERROR#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . EMOTION_HAPPY AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left 'excited' AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left : AST#ERROR#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . EMOTION_EXCITED AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left 'sad' AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left : AST#ERROR#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . EMOTION_SAD AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left 'calm' AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left : AST#ERROR#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . EMOTION_CALM AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left 'angry' AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left : AST#ERROR#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . EMOTION_ANGRY AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left 'surprised' AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left : AST#ERROR#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . EMOTION_SURPRISED AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left default AST#expression#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left return AST#ERROR#Left Constants AST#ERROR#Right . EMOTION_NEUTRAL AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
getEmotionColor(): string {
switch (this.emotion) {
case 'happy':
return Constants.EMOTION_HAPPY;
case 'excited':
return Constants.EMOTION_EXCITED;
case 'sad':
return Constants.EMOTION_SAD;
case 'calm':
return Constants.EMOTION_CALM;
case 'angry':
return Constants.EMOTION_ANGRY;
case 'surprised':
return Constants.EMOTION_SURPRISED;
default:
return Constants.EMOTION_NEUTRAL;
}
|
https://github.com/BohanSu/LumosAgent-HarmonyOS.git/blob/9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76/entry/src/main/ets/model/MoodEntry.ets#L96-L112
|
0e954075432b28d55bba6ba8a0f3627ba67ab36d
|
github
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/common/utils/DateUtils.ets
|
arkts
|
toGMTDate
|
解析GMT格式日期字符串
@param dateStr GMT格式日期字符串
@returns 解析成功的Date对象,失败返回null
|
static toGMTDate(dateStr: string): Date | null {
return DateUtils.toDate(dateStr, "EEE, dd MMM yyyy HH:mm:ss 'GMT'");
}
|
AST#method_declaration#Left static toGMTDate AST#parameter_list#Left ( AST#parameter#Left dateStr : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Date AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateUtils AST#expression#Right . toDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left dateStr AST#expression#Right , AST#expression#Left "EEE, dd MMM yyyy HH:mm:ss 'GMT'" 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 toGMTDate(dateStr: string): Date | null {
return DateUtils.toDate(dateStr, "EEE, dd MMM yyyy HH:mm:ss 'GMT'");
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/utils/DateUtils.ets#L226-L228
|
5a4989dacbdf2a666ee8cb2ac66f3a10e56e35b6
|
github
|
Joker-x-dev/HarmonyKit.git
|
f97197ce157df7f303244fba42e34918306dfb08
|
core/database/Index.ets
|
arkts
|
IBestORMInit
|
@file database 模块统一导出
@author Joker.X
|
export { IBestORMInit } from "@ibestservices/ibest-orm";
|
AST#export_declaration#Left export { IBestORMInit } from "@ibestservices/ibest-orm" ; AST#export_declaration#Right
|
export { IBestORMInit } from "@ibestservices/ibest-orm";
|
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/database/Index.ets#L6-L6
|
923ff8ce221ad036c07ca6d261c7b7f4a6e7cc0e
|
github
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/todo/TodoService.ets
|
arkts
|
getTodo
|
获取代办事项
|
async getTodo(id: string): Promise<Todo | null> {
return this.todos.find(todo => todo.id === id) || null;
}
|
AST#method_declaration#Left async getTodo 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#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 Todo AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . todos AST#member_expression#Right AST#expression#Right . find AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left todo => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left todo AST#expression#Right . id AST#member_expression#Right AST#expression#Right === AST#expression#Left id AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async getTodo(id: string): Promise<Todo | null> {
return this.todos.find(todo => todo.id === id) || null;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/todo/TodoService.ets#L321-L323
|
0dd3e427b05290c8b5c2d35d871e2d4109f85eb8
|
github
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/common/router/AppRouter.ets
|
arkts
|
clearAndPush
|
清空栈并跳转到指定页面
@param path 目标页面路径
@param options 跳转选项
|
async clearAndPush(path: string, options?: RouteOptions): Promise<void> {
try {
await router.clear();
await this.push(path, options);
// 重置导航栈
this.navigationStack = [path];
hilog.info(0x0001, 'BirthdayReminder', `Cleared stack and navigated to: ${path}`);
} catch (error) {
const businessError = error as BusinessError;
hilog.error(0x0001, 'BirthdayReminder',
`Failed to clear and navigate to ${path}: ${businessError.message}`);
throw new Error(`Failed to clear and navigate to ${path}: ${businessError.message}`);
}
}
|
AST#method_declaration#Left async clearAndPush AST#parameter_list#Left ( AST#parameter#Left path : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left options ? : AST#type_annotation#Left AST#primary_type#Left RouteOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left router AST#expression#Right AST#await_expression#Right AST#expression#Right . clear AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left path 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#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . navigationStack AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left path AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#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 0x0001 AST#expression#Right , AST#expression#Left 'BirthdayReminder' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Cleared stack and navigated to: AST#template_substitution#Left $ { AST#expression#Left path AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left businessError = AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0001 AST#expression#Right , AST#expression#Left 'BirthdayReminder' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to clear and navigate to AST#template_substitution#Left $ { AST#expression#Left path AST#expression#Right } AST#template_substitution#Right : AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left businessError 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#throw_statement#Left throw AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` Failed to clear and navigate to AST#template_substitution#Left $ { AST#expression#Left path AST#expression#Right } AST#template_substitution#Right : AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left businessError 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#throw_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async clearAndPush(path: string, options?: RouteOptions): Promise<void> {
try {
await router.clear();
await this.push(path, options);
this.navigationStack = [path];
hilog.info(0x0001, 'BirthdayReminder', `Cleared stack and navigated to: ${path}`);
} catch (error) {
const businessError = error as BusinessError;
hilog.error(0x0001, 'BirthdayReminder',
`Failed to clear and navigate to ${path}: ${businessError.message}`);
throw new Error(`Failed to clear and navigate to ${path}: ${businessError.message}`);
}
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/router/AppRouter.ets#L165-L180
|
fdc44d2f0dc6be6ba3e3d1dc3f5e1bdd4e09f730
|
github
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/BasicFeature/DeviceManagement/ScreenDetector/entry/src/main/ets/common/Warn.ets
|
arkts
|
Warn
|
Copyright (c) 2022 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
@CustomDialog
export struct Warn {
private errMsg?: Resource
private limit?: string
private dialogController?: CustomDialogController
@Builder infoText(msg: Resource, limit: string) {
Row() {
Text(msg)
.margin({ left: 5 })
.fontSize(18)
Text(limit)
.fontSize(18)
}
.margin(5)
}
build() {
Column() {
Text($r('app.string.warning'))
.margin(10)
.fontSize(20)
Column() {
this.infoText(this.errMsg, this.limit)
}
.padding(5)
.width('100%')
.borderRadius(10)
.alignItems(HorizontalAlign.Start)
}
.padding(5)
.width('100%')
.borderRadius(10)
.alignItems(HorizontalAlign.Start)
.onClick(() => {
this.dialogController.close()
})
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ CustomDialog AST#decorator#Right export struct Warn AST#component_body#Left { AST#property_declaration#Left private errMsg ? : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#property_declaration#Left private limit ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#property_declaration#Left private dialogController ? : AST#type_annotation#Left AST#primary_type#Left CustomDialogController AST#primary_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right infoText AST#parameter_list#Left ( AST#parameter#Left msg : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left limit : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left msg AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left 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#Left . fontSize ( AST#expression#Left 18 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left limit AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 18 AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . margin ( AST#expression#Left 5 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 AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.warning' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . margin ( AST#expression#Left 10 AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . infoText 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 . errMsg AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . limit AST#member_expression#Right 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 . padding ( AST#expression#Left 5 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 10 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#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 5 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 10 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#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 . dialogController AST#member_expression#Right AST#expression#Right . close AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@CustomDialog
export struct Warn {
private errMsg?: Resource
private limit?: string
private dialogController?: CustomDialogController
@Builder infoText(msg: Resource, limit: string) {
Row() {
Text(msg)
.margin({ left: 5 })
.fontSize(18)
Text(limit)
.fontSize(18)
}
.margin(5)
}
build() {
Column() {
Text($r('app.string.warning'))
.margin(10)
.fontSize(20)
Column() {
this.infoText(this.errMsg, this.limit)
}
.padding(5)
.width('100%')
.borderRadius(10)
.alignItems(HorizontalAlign.Start)
}
.padding(5)
.width('100%')
.borderRadius(10)
.alignItems(HorizontalAlign.Start)
.onClick(() => {
this.dialogController.close()
})
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/BasicFeature/DeviceManagement/ScreenDetector/entry/src/main/ets/common/Warn.ets#L16-L55
|
311e1439ffe890c01ecf1d1eb0f8c6b9ebffa997
|
gitee
|
ccccjiemo/egl.git
|
d18849c3da975ccf9373fd09874aa5637ccbe6bd
|
Index.d.ets
|
arkts
|
setAttribute
|
eglSurfaceAttrib
@param attribute EGL_MIPMAP_LEVEL / EGL_MULTISAMPLE_RESOLVE / EGL_SWAP_BEHAVIOR
|
setAttribute(dpy: EGLDisplay, attribute: number, value: number): boolean;
|
AST#method_declaration#Left setAttribute AST#parameter_list#Left ( AST#parameter#Left dpy : AST#type_annotation#Left AST#primary_type#Left EGLDisplay AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left attribute : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right
|
setAttribute(dpy: EGLDisplay, attribute: number, value: number): boolean;
|
https://github.com/ccccjiemo/egl.git/blob/d18849c3da975ccf9373fd09874aa5637ccbe6bd/Index.d.ets#L56-L56
|
8dff8a71ac0faf702027660c6904318e79045861
|
github
|
weiwei0928/Eyepetizer-harmony.git
|
fd5947c6f616c22d42256f36ba752093b782a910
|
entry/src/main/ets/entryability/EntryAbility.ets
|
arkts
|
import { ImageKnife } from '@ohos/imageknife'
|
export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
hilog.info(0x0000, 'testTag', '%{public}s', 'EntryAbility onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? ''); }
onDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage) {
// Main window is created, set main page for this ability
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
// 1.获取应用主窗口。
windowStage.getMainWindow((err, data) => {
if (err.code) {
console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
return;
}
let windowClass = data;
console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
// 设置窗口的布局是否为全屏显示状态
windowClass.setWindowLayoutFullScreen(true);
// 获取导航条高度 参考API 9
// 这个方法为返回的是PX像素,需要使用px2vp方法转换一下 参考API 9
let navHeight: number = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_CUTOUT).topRect.height
// 存储高度信息 参考API 9
PersistentStorage.PersistProp('systemBarHeight', navHeight)
// 实现沉浸式效果:设置导航栏、状态栏不显示。
// let names = ["status"];
// windowClass.setWindowSystemBarEnable(names, (err) => {
// if (err.code) {
// console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
// return;
// }
// console.info('Succeeded in setting the system bar to be visible.');
// });
// windowClass.setWindowLayoutFullScreen(true)
})
windowStage.loadContent('pages/SplashPage', (err, data) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
});
// ImageKnife.with(this.context);
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}
onForeground() {
// Ability has brought to foreground
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
}
onBackground() {
// Ability has back to background
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
}
}
|
AST#export_declaration#Left export default AST#class_declaration#Left class EntryAbility extends AST#type_annotation#Left AST#primary_type#Left UIAbility AST#primary_type#Right AST#type_annotation#Right AST#class_body#Left { AST#method_declaration#Left onCreate AST#parameter_list#Left ( AST#parameter#Left want : AST#type_annotation#Left AST#primary_type#Left Want AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left launchParam : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left AbilityConstant . LaunchParam AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left 'EntryAbility onCreate' 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 hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left 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 'want param:' 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 want AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ?? AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#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 hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left 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 'launchParam:' 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 launchParam AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ?? AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left onDestroy AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left 'Ability onDestroy' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left 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#builder_function_body#Left { // Main window is created, set main page for this ability AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left 'Ability onWindowStageCreate' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right // 1.获取应用主窗口。 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 . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#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#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 'Failed to obtain the main window. Cause: ' 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 err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left windowClass = AST#expression#Left data 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'Succeeded in obtaining the main window. Data: ' 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 data AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 设置窗口的布局是否为全屏显示状态 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . setWindowLayoutFullScreen AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 获取导航条高度 参考API 9 // 这个方法为返回的是PX像素,需要使用px2vp方法转换一下 参考API 9 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left navHeight : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . getWindowAvoidArea AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . AvoidAreaType AST#member_expression#Right AST#expression#Right . TYPE_CUTOUT AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . topRect AST#member_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right // 存储高度信息 参考API 9 AST#ERROR#Left PersistentStorage AST#ERROR#Right . PersistProp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'systemBarHeight' AST#expression#Right , AST#expression#Left navHeight AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right // 实现沉浸式效果:设置导航栏、状态栏不显示。 // let names = ["status"]; // windowClass.setWindowSystemBarEnable(names, (err) => { // if (err.code) { // console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); // return; // } // console.info('Succeeded in setting the system bar to be visible.'); // }); // windowClass.setWindowLayoutFullScreen(true) AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right 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/SplashPage' 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#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 'testTag' AST#expression#Right , AST#expression#Left 'Failed to load the content. Cause: %{public}s' AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ?? AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left 'Succeeded in loading the content. Data: %{public}s' AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ?? AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right // ImageKnife.with(this.context); } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left onWindowStageDestroy AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { // Main window is destroyed, release UI related resources AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left 'Ability onWindowStageDestroy' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left onForeground AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { // Ability has brought to foreground AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left 'Ability onForeground' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left onBackground AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { // Ability has back to background AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left 'Ability onBackground' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
hilog.info(0x0000, 'testTag', '%{public}s', 'EntryAbility onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? ''); }
onDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage) {
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
windowStage.getMainWindow((err, data) => {
if (err.code) {
console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
return;
}
let windowClass = data;
console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
windowClass.setWindowLayoutFullScreen(true);
let navHeight: number = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_CUTOUT).topRect.height
PersistentStorage.PersistProp('systemBarHeight', navHeight)
})
windowStage.loadContent('pages/SplashPage', (err, data) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}
onForeground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
}
onBackground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
}
}
|
https://github.com/weiwei0928/Eyepetizer-harmony.git/blob/fd5947c6f616c22d42256f36ba752093b782a910/entry/src/main/ets/entryability/EntryAbility.ets#L9-L79
|
1523a495817b7883bc11a2c8913df2c20cd963f0
|
github
|
|
open9527/OpenHarmony
|
fdea69ed722d426bf04e817ec05bff4002e81a4e
|
libs/core/src/main/ets/utils/AbilityUtils.ets
|
arkts
|
toNetworkSetting
|
跳转移动网络设置页面
|
static toNetworkSetting(): Promise<void> {
return AbilityUtils.toAppSetting(AbilityUtils.uri_network)
}
|
AST#method_declaration#Left static toNetworkSetting AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AbilityUtils AST#expression#Right . toAppSetting AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AbilityUtils AST#expression#Right . uri_network AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static toNetworkSetting(): Promise<void> {
return AbilityUtils.toAppSetting(AbilityUtils.uri_network)
}
|
https://github.com/open9527/OpenHarmony/blob/fdea69ed722d426bf04e817ec05bff4002e81a4e/libs/core/src/main/ets/utils/AbilityUtils.ets#L38-L40
|
b721d7e1d9629c31c1e1d5f4f15365ea685a727e
|
gitee
|
openharmony-tpc/ohos_mpchart
|
4fb43a7137320ef2fee2634598f53d93975dfb4a
|
library/src/main/ets/components/utils/ViewPortHandler.ets
|
arkts
|
getSmallestContentExtension
|
Returns the smallest extension of the content rect (width or height).
@return
|
public getSmallestContentExtension(): number {
return Math.min(this.mContentRect.width(), this.mContentRect.height());
}
|
AST#method_declaration#Left public getSmallestContentExtension AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . min AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mContentRect AST#member_expression#Right AST#expression#Right . width 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . mContentRect AST#member_expression#Right AST#expression#Right . height 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public getSmallestContentExtension(): number {
return Math.min(this.mContentRect.width(), this.mContentRect.height());
}
|
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/utils/ViewPortHandler.ets#L177-L179
|
d48dbf3a127cb64d985ba66b25b2b88c2ea3d17b
|
gitee
|
qwerguai/ArkTSComponents.git
|
58ac77d9686670d79ba7421d71e68f31870aacd5
|
entry/src/main/ets/viewmodel/MainViewModel.ets
|
arkts
|
getFirstGridData
|
Get data of the first grid.
@return {Array<PageResource>} firstGridData.
|
getFirstGridData(): Array<ItemData> {
let firstGridData: ItemData[] = [
new ItemData($r('app.string.my_love'), $r('app.media.shoucang')),
new ItemData($r('app.string.history_record'), $r('app.media.lishi')),
new ItemData($r('app.string.message'), $r('app.media.kefu')),
new ItemData($r('app.string.my_goal'), $r('app.media.dingdan')),
new ItemData($r('app.string.group'), $r('app.media.dizhi')),
];
return firstGridData;
}
|
AST#method_declaration#Left getFirstGridData AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left ItemData AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left firstGridData : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ItemData [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ItemData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.my_love' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.shoucang' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ItemData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.history_record' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.lishi' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ItemData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.message' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.kefu' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ItemData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.my_goal' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.dingdan' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ItemData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.group' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.dizhi' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left firstGridData AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
getFirstGridData(): Array<ItemData> {
let firstGridData: ItemData[] = [
new ItemData($r('app.string.my_love'), $r('app.media.shoucang')),
new ItemData($r('app.string.history_record'), $r('app.media.lishi')),
new ItemData($r('app.string.message'), $r('app.media.kefu')),
new ItemData($r('app.string.my_goal'), $r('app.media.dingdan')),
new ItemData($r('app.string.group'), $r('app.media.dizhi')),
];
return firstGridData;
}
|
https://github.com/qwerguai/ArkTSComponents.git/blob/58ac77d9686670d79ba7421d71e68f31870aacd5/entry/src/main/ets/viewmodel/MainViewModel.ets#L43-L55
|
d90861878a33a978d9aa57c631dba5bd0d7c661d
|
github
|
openharmony/base_location
|
724370a03f6f23ddc07c8eb9f49dfc61ab716bdb
|
services/location_ui/entry/src/main/ets/common/PermissionUtils.ets
|
arkts
|
checkBluetoothShareCallerSceneboardPermission
|
校验蓝牙分享UI ability调用方权限:大桌面应用允许作为调用方拉起
|
checkBluetoothShareCallerSceneboardPermission(want: Want): boolean {
const callerBundleName = want?.parameters?.[this.WANT_PARA_KEY_CALLER_BUNDLE_NAME] as string;
const callerUid = want?.parameters?.[this.WANT_PARA_KEY_CALLER_UID] as number;
console.info(TAG, `checkSceneboardPermission callerUid ` + callerUid + ` BundleName ` + callerBundleName);
let ret: boolean = false;
if (!callerBundleName) {
console.info(TAG, `without bundleName sceneboard app check fail.`);
return ret;
}
let systemCallerAppInfo: bundleManager.ApplicationInfo;
try {
systemCallerAppInfo = bundleManager.getApplicationInfoSync(callerBundleName,
bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT);
} catch (error) {
console.info(TAG, `Get app info error by ${callerBundleName}, cause: ${(error as BusinessError).message}`);
return ret;
}
if (!systemCallerAppInfo) {
console.info(TAG, `Get app info error by ${callerBundleName}, cause: systemCallerAppInfo is undefined`);
return ret;
}
const callerAccessTokenId = want?.parameters?.[this.WANT_PARA_KEY_CALLER_TOKEN] as number;
//系统应用sceneboard可以调用.
ret = callerBundleName == this.SCENEBOARD_BUNDLE_NAME && systemCallerAppInfo.systemApp &&
systemCallerAppInfo.accessTokenId == callerAccessTokenId && systemCallerAppInfo.uid == callerUid;
if (!ret) {
console.info(TAG, `sceneboard app check fail.`);
}
return ret;
}
|
AST#method_declaration#Left checkBluetoothShareCallerSceneboardPermission AST#parameter_list#Left ( AST#parameter#Left want : AST#type_annotation#Left AST#primary_type#Left Want AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left callerBundleName = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left want AST#expression#Right ?. parameters AST#member_expression#Right AST#expression#Right ?. [ AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . WANT_PARA_KEY_CALLER_BUNDLE_NAME AST#member_expression#Right AST#expression#Right ] AST#subscript_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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left callerUid = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left want AST#expression#Right ?. parameters AST#member_expression#Right AST#expression#Right ?. [ AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . WANT_PARA_KEY_CALLER_UID AST#member_expression#Right AST#expression#Right ] AST#subscript_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#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 TAG AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#template_literal#Left ` checkSceneboardPermission callerUid ` AST#template_literal#Right AST#expression#Right + AST#expression#Left callerUid AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left AST#template_literal#Left ` BundleName ` AST#template_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left callerBundleName AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left ret : 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#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 callerBundleName 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 . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` without bundleName sceneboard app check fail. ` 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 ret AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left systemCallerAppInfo : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left bundleManager . ApplicationInfo 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#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left systemCallerAppInfo = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left bundleManager AST#expression#Right . getApplicationInfoSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left callerBundleName AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left bundleManager AST#expression#Right . ApplicationFlag AST#member_expression#Right AST#expression#Right . GET_APPLICATION_INFO_DEFAULT AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#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 . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Get app info error by AST#template_substitution#Left $ { AST#expression#Left callerBundleName AST#expression#Right } AST#template_substitution#Right , cause: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left ret 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#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left systemCallerAppInfo 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 . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Get app info error by AST#template_substitution#Left $ { AST#expression#Left callerBundleName AST#expression#Right } AST#template_substitution#Right , cause: systemCallerAppInfo is undefined ` 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 ret AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left callerAccessTokenId = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left want AST#expression#Right ?. parameters AST#member_expression#Right AST#expression#Right ?. [ AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . WANT_PARA_KEY_CALLER_TOKEN AST#member_expression#Right AST#expression#Right ] AST#subscript_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 //系统应用sceneboard可以调用. AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left ret = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#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 callerBundleName AST#expression#Right == AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . SCENEBOARD_BUNDLE_NAME AST#member_expression#Right AST#expression#Right && AST#expression#Left systemCallerAppInfo AST#expression#Right AST#binary_expression#Right AST#expression#Right . systemApp AST#member_expression#Right AST#expression#Right && AST#expression#Left systemCallerAppInfo AST#expression#Right AST#binary_expression#Right AST#expression#Right . accessTokenId AST#member_expression#Right AST#expression#Right == AST#expression#Left callerAccessTokenId AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left systemCallerAppInfo AST#expression#Right AST#binary_expression#Right AST#expression#Right . uid AST#member_expression#Right AST#expression#Right == AST#expression#Left callerUid 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#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left ret 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 . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` sceneboard app check fail. ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left ret AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
checkBluetoothShareCallerSceneboardPermission(want: Want): boolean {
const callerBundleName = want?.parameters?.[this.WANT_PARA_KEY_CALLER_BUNDLE_NAME] as string;
const callerUid = want?.parameters?.[this.WANT_PARA_KEY_CALLER_UID] as number;
console.info(TAG, `checkSceneboardPermission callerUid ` + callerUid + ` BundleName ` + callerBundleName);
let ret: boolean = false;
if (!callerBundleName) {
console.info(TAG, `without bundleName sceneboard app check fail.`);
return ret;
}
let systemCallerAppInfo: bundleManager.ApplicationInfo;
try {
systemCallerAppInfo = bundleManager.getApplicationInfoSync(callerBundleName,
bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT);
} catch (error) {
console.info(TAG, `Get app info error by ${callerBundleName}, cause: ${(error as BusinessError).message}`);
return ret;
}
if (!systemCallerAppInfo) {
console.info(TAG, `Get app info error by ${callerBundleName}, cause: systemCallerAppInfo is undefined`);
return ret;
}
const callerAccessTokenId = want?.parameters?.[this.WANT_PARA_KEY_CALLER_TOKEN] as number;
ret = callerBundleName == this.SCENEBOARD_BUNDLE_NAME && systemCallerAppInfo.systemApp &&
systemCallerAppInfo.accessTokenId == callerAccessTokenId && systemCallerAppInfo.uid == callerUid;
if (!ret) {
console.info(TAG, `sceneboard app check fail.`);
}
return ret;
}
|
https://github.com/openharmony/base_location/blob/724370a03f6f23ddc07c8eb9f49dfc61ab716bdb/services/location_ui/entry/src/main/ets/common/PermissionUtils.ets#L48-L81
|
8c176d89c5dc406d6a374aa510808fb09fa99d78
|
gitee
|
openharmony/arkui_ace_engine
|
30c7d1ee12fbedf0fabece54291d75897e2ad44f
|
advanced_ui_component/foldsplitcontainer/source/foldsplitcontainer.ets
|
arkts
|
The layout options for the container when the foldable screen is folded.
@interface FoldedRegionLayoutOptions
@syscap SystemCapability.ArkUI.ArkUI.Full
@crossplatform
@atomicservice
@since 12
|
export interface FoldedRegionLayoutOptions {
/**
* The ratio of the heights of two areas in the vertical direction.
*
* @type { ?number }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
verticalSplitRatio?: number;
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface FoldedRegionLayoutOptions AST#object_type#Left { /**
* The ratio of the heights of two areas in the vertical direction.
*
* @type { ?number }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/ AST#type_member#Left verticalSplitRatio ? : 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 FoldedRegionLayoutOptions {
verticalSplitRatio?: number;
}
|
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/advanced_ui_component/foldsplitcontainer/source/foldsplitcontainer.ets#L174-L185
|
189c498b41cdb22f61b9d8da889e0b769bf5fa61
|
gitee
|
|
liuchao0739/arkTS_universal_starter.git
|
0ca845f5ae0e78db439dc09f712d100c0dd46ed3
|
entry/src/main/ets/utils/ScreenUtils.ets
|
arkts
|
dp2px
|
DP转像素
|
static dp2px(dp: number): number {
return dp * (ScreenUtils.getDensity() / 160);
}
|
AST#method_declaration#Left static dp2px AST#parameter_list#Left ( AST#parameter#Left dp : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left dp AST#expression#Right * AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ScreenUtils AST#expression#Right . getDensity 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 160 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static dp2px(dp: number): number {
return dp * (ScreenUtils.getDensity() / 160);
}
|
https://github.com/liuchao0739/arkTS_universal_starter.git/blob/0ca845f5ae0e78db439dc09f712d100c0dd46ed3/entry/src/main/ets/utils/ScreenUtils.ets#L52-L54
|
d56f3a4d944166a0e41449959d7cd632041fa536
|
github
|
Joker-x-dev/HarmonyKit.git
|
f97197ce157df7f303244fba42e34918306dfb08
|
core/designsystem/src/main/ets/component/Spacer.ets
|
arkts
|
SpaceHorizontalLarge
|
创建一个大水平间距(16vp)
@returns {void} 无返回值
|
@Builder
export function SpaceHorizontalLarge(): void {
Blank().width($r("app.float.space_horizontal_large"));
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function SpaceHorizontalLarge AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Blank ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.float.space_horizontal_large" 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#builder_function_body#Right AST#decorated_export_declaration#Right
|
@Builder
export function SpaceHorizontalLarge(): void {
Blank().width($r("app.float.space_horizontal_large"));
}
|
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/designsystem/src/main/ets/component/Spacer.ets#L82-L85
|
888e63b5ebaad862d680329dd5ba048f8bb1025a
|
github
|
Piagari/arkts_example.git
|
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
|
hmos_app-main/hmos_app-main/legado-Harmony-master/entry/src/main/ets/database/types/BooksType.ets
|
arkts
|
@author 2008
@datetime 2024/7/23 11:02
@className: BooksType
|
export interface BooksTypeSearchParams {
// 搜索关键词书源名称/书籍名称/author
searchKey?: string,
// 源类型 0 小说;1 漫画;2 有声书;
type?: number,
//分组
bookGroup?: number,
//排序方式
order?: string
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface BooksTypeSearchParams AST#object_type#Left { // 搜索关键词书源名称/书籍名称/author AST#type_member#Left searchKey ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right , // 源类型 0 小说;1 漫画;2 有声书; AST#type_member#Left type ? : 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 bookGroup ? : 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 order ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
|
export interface BooksTypeSearchParams {
searchKey?: string,
type?: number,
bookGroup?: number,
order?: string
}
|
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/legado-Harmony-master/entry/src/main/ets/database/types/BooksType.ets#L6-L15
|
63276af43905b3be06e85f338e534debffe8fa85
|
github
|
|
openharmony/developtools_profiler
|
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
|
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/components/YAxis.ets
|
arkts
|
getSpaceTop
|
Returns the top axis space in percent of the full range. Default 10f
@return
|
public getSpaceTop(): number {
return this.mSpacePercentTop;
}
|
AST#method_declaration#Left public getSpaceTop 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 . mSpacePercentTop AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public getSpaceTop(): number {
return this.mSpacePercentTop;
}
|
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/components/YAxis.ets#L281-L283
|
4bd7070f7a1799e26cacea4642281436cdcaae0d
|
gitee
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/models/managers/member/EncourageManager.ets
|
arkts
|
encourage
|
============================================================ 对外公开方法 ============================================================
发放奖品(对应Swift的encourage方法)
@param type 激励类型
@param rewardCount 奖品数量,如果为空则使用默认奖励数量
@param limitOncePerDay 每日是否只奖励一次
@returns 是否奖励成功
|
public encourage(type: EncourageType, rewardCount?: number, limitOncePerDay: boolean = false): boolean {
const count = rewardCount ?? EncourageTypeHelper.getRewardCount(type);
const prefs = this.getPrefs();
const key = EncourageTypeHelper.getKeyWithToday(type);
// 检查是否已存在今日记录
const currentValue = prefs.getSync(key, 0) as number;
// 如果每日只奖励一次且已存在记录,则返回失败
if (limitOncePerDay && currentValue > 0) {
return false;
}
// 更新奖励数量
const newValue = currentValue + count;
prefs.putSync(key, newValue);
prefs.flushSync();
return true;
}
|
AST#method_declaration#Left public encourage AST#parameter_list#Left ( AST#parameter#Left type : AST#type_annotation#Left AST#primary_type#Left EncourageType AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left rewardCount ? : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left limitOncePerDay : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left count = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left rewardCount AST#expression#Right ?? AST#expression#Left EncourageTypeHelper AST#expression#Right AST#binary_expression#Right AST#expression#Right . getRewardCount 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left prefs = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getPrefs AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left key = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left EncourageTypeHelper AST#expression#Right . getKeyWithToday 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 检查是否已存在今日记录 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left currentValue = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left prefs AST#expression#Right . getSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right , AST#expression#Left 0 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 limitOncePerDay AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left currentValue AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 更新奖励数量 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left newValue = AST#expression#Left AST#binary_expression#Left AST#expression#Left currentValue AST#expression#Right + AST#expression#Left count AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left prefs AST#expression#Right . putSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right , AST#expression#Left newValue 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 prefs AST#expression#Right . flushSync 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#method_declaration#Right
|
public encourage(type: EncourageType, rewardCount?: number, limitOncePerDay: boolean = false): boolean {
const count = rewardCount ?? EncourageTypeHelper.getRewardCount(type);
const prefs = this.getPrefs();
const key = EncourageTypeHelper.getKeyWithToday(type);
const currentValue = prefs.getSync(key, 0) as number;
if (limitOncePerDay && currentValue > 0) {
return false;
}
const newValue = currentValue + count;
prefs.putSync(key, newValue);
prefs.flushSync();
return true;
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/managers/member/EncourageManager.ets#L161-L180
|
cf8c38f42fc1f0d21a44d2484ab9587c1ac7569b
|
github
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/game/GameificationService.ets
|
arkts
|
dailyCheckIn
|
每日签到
|
async dailyCheckIn(userId: string = 'default'): Promise<PointsRecord> {
try {
const now = new Date();
const today = now.toDateString();
if (!this.userGameData) {
throw new Error('User game data not initialized');
}
// 检查是否已经签到
if (this.userGameData.lastCheckIn === today) {
throw new Error('Already checked in today');
}
// 计算连续签到天数
const yesterday = new Date(now.getTime() - 24 * 60 * 60 * 1000).toDateString();
const isConsecutive = this.userGameData.lastCheckIn === yesterday;
const streakData = this.userGameData.streaks.get('check_in') || {
type: 'check_in',
current: 0,
best: 0,
lastActionDate: '',
isActive: false
};
if (isConsecutive) {
streakData.current++;
} else {
streakData.current = 1;
}
streakData.best = Math.max(streakData.best, streakData.current);
streakData.lastActionDate = today;
streakData.isActive = true;
this.userGameData.streaks.set('check_in', streakData);
this.userGameData.lastCheckIn = today;
// 记录签到积分
const checkInRecord = await this.recordAction(GameAction.DAILY_CHECK_IN, {
streak: streakData.current,
isConsecutive
});
// 连续签到额外奖励
if (streakData.current > 1) {
await this.recordAction(GameAction.CONTINUOUS_DAYS, {
days: streakData.current
});
}
return checkInRecord;
} catch (error) {
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP,
`Failed to check in: ${error}`);
throw error;
}
}
|
AST#method_declaration#Left async dailyCheckIn AST#parameter_list#Left ( AST#parameter#Left userId : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'default' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left PointsRecord 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 now = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left today = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left now AST#expression#Right . toDateString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . userGameData AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#throw_statement#Left throw AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'User game data not initialized' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#throw_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 检查是否已经签到 AST#statement#Left AST#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 . userGameData AST#member_expression#Right AST#expression#Right . lastCheckIn AST#member_expression#Right AST#expression#Right === AST#expression#Left today AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#throw_statement#Left throw AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Already checked in today' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#throw_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 计算连续签到天数 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left yesterday = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left now AST#expression#Right . getTime AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right - AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 24 AST#expression#Right * AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right * AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right * AST#expression#Left 1000 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . toDateString 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 isConsecutive = 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 . userGameData AST#member_expression#Right AST#expression#Right . lastCheckIn AST#member_expression#Right AST#expression#Right === AST#expression#Left yesterday AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left streakData = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . userGameData AST#member_expression#Right AST#expression#Right . streaks AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'check_in' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left 'check_in' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left current AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left best AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left lastActionDate AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left isActive AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left isConsecutive AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#update_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left streakData AST#expression#Right . current AST#member_expression#Right AST#expression#Right ++ AST#update_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 streakData AST#expression#Right . current AST#member_expression#Right = AST#expression#Left 1 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#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 streakData AST#expression#Right . best AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . max AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left streakData AST#expression#Right . best AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left streakData AST#expression#Right . current AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left streakData AST#expression#Right . lastActionDate AST#member_expression#Right = AST#expression#Left today 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 streakData AST#expression#Right . isActive AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . userGameData AST#member_expression#Right AST#expression#Right . streaks AST#member_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'check_in' AST#expression#Right , AST#expression#Left streakData 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . userGameData AST#member_expression#Right AST#expression#Right . lastCheckIn AST#member_expression#Right = AST#expression#Left today AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 记录签到积分 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left checkInRecord = 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 . recordAction AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left GameAction AST#expression#Right . DAILY_CHECK_IN AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left streak AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left streakData AST#expression#Right . current AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left isConsecutive AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 连续签到额外奖励 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left streakData AST#expression#Right . current AST#member_expression#Right AST#expression#Right > AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . recordAction AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left GameAction AST#expression#Right . CONTINUOUS_DAYS AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left days AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left streakData AST#expression#Right . current AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left checkInRecord AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to check in: AST#template_substitution#Left $ { AST#expression#Left error AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#throw_statement#Left throw AST#expression#Left error AST#expression#Right ; AST#throw_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async dailyCheckIn(userId: string = 'default'): Promise<PointsRecord> {
try {
const now = new Date();
const today = now.toDateString();
if (!this.userGameData) {
throw new Error('User game data not initialized');
}
if (this.userGameData.lastCheckIn === today) {
throw new Error('Already checked in today');
}
const yesterday = new Date(now.getTime() - 24 * 60 * 60 * 1000).toDateString();
const isConsecutive = this.userGameData.lastCheckIn === yesterday;
const streakData = this.userGameData.streaks.get('check_in') || {
type: 'check_in',
current: 0,
best: 0,
lastActionDate: '',
isActive: false
};
if (isConsecutive) {
streakData.current++;
} else {
streakData.current = 1;
}
streakData.best = Math.max(streakData.best, streakData.current);
streakData.lastActionDate = today;
streakData.isActive = true;
this.userGameData.streaks.set('check_in', streakData);
this.userGameData.lastCheckIn = today;
const checkInRecord = await this.recordAction(GameAction.DAILY_CHECK_IN, {
streak: streakData.current,
isConsecutive
});
if (streakData.current > 1) {
await this.recordAction(GameAction.CONTINUOUS_DAYS, {
days: streakData.current
});
}
return checkInRecord;
} catch (error) {
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP,
`Failed to check in: ${error}`);
throw error;
}
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/game/GameificationService.ets#L370-L428
|
bc97955813ca56f7fa8befd903011c32871e6147
|
github
|
liuchao0739/arkTS_universal_starter.git
|
0ca845f5ae0e78db439dc09f712d100c0dd46ed3
|
entry/src/main/ets/core/update/UpdateManager.ets
|
arkts
|
downloadUpdate
|
下载更新包
|
async downloadUpdate(updateInfo: UpdateInfo, onProgress?: (progress: DownloadProgress) => void): Promise<boolean> {
try {
Logger.info('UpdateManager', `Downloading update: ${updateInfo.updateUrl}`);
this.onProgressCallback = onProgress || null;
// Mock 下载(实际项目中需要使用真实的下载API)
// HarmonyOS 下载需要使用 @ohos.request 或 @ohos.file.download
// 这里提供接口定义,实际实现需要根据 HarmonyOS API 文档
// 模拟下载进度
if (this.onProgressCallback) {
const simulateProgress = () => {
let received = 0;
const total = updateInfo.updateSize;
const interval = setInterval(() => {
received += total / 20;
if (received >= total) {
received = total;
clearInterval(interval);
}
this.onProgressCallback?.({
received,
total,
percent: Math.round((received / total) * 100)
});
}, 200);
};
simulateProgress();
}
// 实际下载逻辑需要实现
// 1. 使用 @ohos.request 下载文件
// 2. 保存到应用目录
// 3. 返回下载文件路径
Logger.info('UpdateManager', 'Download completed');
return true;
} catch (error) {
Logger.error('UpdateManager', `Failed to download update: ${String(error)}`);
return false;
}
}
|
AST#method_declaration#Left async downloadUpdate AST#parameter_list#Left ( AST#parameter#Left updateInfo : AST#type_annotation#Left AST#primary_type#Left UpdateInfo AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left onProgress ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left progress : AST#type_annotation#Left AST#primary_type#Left DownloadProgress AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'UpdateManager' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Downloading update: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left updateInfo AST#expression#Right . updateUrl AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onProgressCallback AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left onProgress 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#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // Mock 下载(实际项目中需要使用真实的下载API) // HarmonyOS 下载需要使用 @ohos.request 或 @ohos.file.download // 这里提供接口定义,实际实现需要根据 HarmonyOS API 文档 // 模拟下载进度 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onProgressCallback AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left simulateProgress = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left received = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left total = AST#expression#Left AST#member_expression#Left AST#expression#Left updateInfo AST#expression#Right . updateSize AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left interval = AST#expression#Left AST#call_expression#Left AST#expression#Left setInterval AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left received += AST#expression#Left AST#binary_expression#Left AST#expression#Left total AST#expression#Right / AST#expression#Left 20 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left received AST#expression#Right >= AST#expression#Left total AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left received = AST#expression#Left total 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 clearInterval AST#expression#Right AST#argument_list#Left ( AST#expression#Left interval AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onProgressCallback AST#member_expression#Right AST#expression#Right ?. AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left received AST#property_assignment#Right , AST#property_assignment#Left total AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left percent AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . round AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left received AST#expression#Right / AST#expression#Left total AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left 100 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#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right , AST#expression#Left 200 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#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 simulateProgress AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 实际下载逻辑需要实现 // 1. 使用 @ohos.request 下载文件 // 2. 保存到应用目录 // 3. 返回下载文件路径 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 'UpdateManager' AST#expression#Right , AST#expression#Left 'Download completed' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'UpdateManager' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to download update: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left String AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async downloadUpdate(updateInfo: UpdateInfo, onProgress?: (progress: DownloadProgress) => void): Promise<boolean> {
try {
Logger.info('UpdateManager', `Downloading update: ${updateInfo.updateUrl}`);
this.onProgressCallback = onProgress || null;
if (this.onProgressCallback) {
const simulateProgress = () => {
let received = 0;
const total = updateInfo.updateSize;
const interval = setInterval(() => {
received += total / 20;
if (received >= total) {
received = total;
clearInterval(interval);
}
this.onProgressCallback?.({
received,
total,
percent: Math.round((received / total) * 100)
});
}, 200);
};
simulateProgress();
}
Logger.info('UpdateManager', 'Download completed');
return true;
} catch (error) {
Logger.error('UpdateManager', `Failed to download update: ${String(error)}`);
return false;
}
}
|
https://github.com/liuchao0739/arkTS_universal_starter.git/blob/0ca845f5ae0e78db439dc09f712d100c0dd46ed3/entry/src/main/ets/core/update/UpdateManager.ets#L129-L171
|
e9978e0dabfb7092f4fe13f282477d2bb44c4711
|
github
|
openharmony/interface_sdk-js
|
c349adc73e2ec1f61f6fca489b5af059e3ed6999
|
api/@ohos.util.d.ets
|
arkts
|
isUint16Array
|
Check whether the entered value is the uint16array array array type.
@param { Object } value - A Uint16Array value
@returns { boolean } Returns true if the value is a built-in Uint16Array instance.
@syscap SystemCapability.Utils.Lang
@crossplatform
@atomicservice
@since 20
|
isUint16Array(value: Object): boolean;
|
AST#method_declaration#Left isUint16Array AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right
|
isUint16Array(value: Object): boolean;
|
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.util.d.ets#L1378-L1378
|
997d672581a4bd619c74838d74f9bbe4ffa1e292
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/ai/ModelConfigService.ets
|
arkts
|
getAllModels
|
获取所有预定义模型
|
public getAllModels(): ModelInfo[] {
const allModels: ModelInfo[] = [];
Object.values(this.predefinedModels).forEach(models => {
allModels.push(...models);
});
return allModels;
}
|
AST#method_declaration#Left public getAllModels AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ModelInfo [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left allModels : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ModelInfo [ ] 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Object AST#expression#Right . values 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 . predefinedModels AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left models => 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 allModels AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#spread_element#Left ... AST#expression#Left models 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#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left allModels AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public getAllModels(): ModelInfo[] {
const allModels: ModelInfo[] = [];
Object.values(this.predefinedModels).forEach(models => {
allModels.push(...models);
});
return allModels;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/ai/ModelConfigService.ets#L318-L324
|
4bf650505591724a6c312c0a2fb318a22676afaa
|
github
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Ability/StageAbilityDemo/entry/src/main/ets/common/constants/Constants.ets
|
arkts
|
The text margin of 18.
|
export const Text_Margin = 18;
|
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left Text_Margin = AST#expression#Left 18 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
|
export const Text_Margin = 18;
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Ability/StageAbilityDemo/entry/src/main/ets/common/constants/Constants.ets#L55-L55
|
bb55e59900e86bfc2308c13cae2a9dba1a9bbd96
|
gitee
|
|
FantasyWind/fwrouter
|
eea785a7bf728862de1f88de487ef3857dee3364
|
router/src/main/ets/RouterManagerForNavigation.ets
|
arkts
|
canOpen
|
是否可以打开
|
canOpen(path: string): boolean {
return this.builderMap.has(path)
}
|
AST#method_declaration#Left canOpen AST#parameter_list#Left ( AST#parameter#Left path : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . builderMap AST#member_expression#Right AST#expression#Right . has AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left path AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
canOpen(path: string): boolean {
return this.builderMap.has(path)
}
|
https://github.com/FantasyWind/fwrouter/blob/eea785a7bf728862de1f88de487ef3857dee3364/router/src/main/ets/RouterManagerForNavigation.ets#L88-L90
|
89e97f4a21fe6438c66d710aca11222a041af782
|
gitee
|
openharmony/interface_sdk-js
|
c349adc73e2ec1f61f6fca489b5af059e3ed6999
|
api/@ohos.deviceInfo.d.ets
|
arkts
|
get
|
Obtains the application binary interface (Abi) list represented by a string.
@syscap SystemCapability.Startup.SystemInfo
@crossplatform
@since 20
@arkts 1.2
|
static get abiList(): string;
|
AST#method_declaration#Left static get AST#ERROR#Left abi List AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right
|
static get abiList(): string;
|
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.deviceInfo.d.ets#L175-L175
|
e151259543f8493680b633dc8ba7fbbf91819a56
|
gitee
|
openharmony/arkui_ace_engine
|
30c7d1ee12fbedf0fabece54291d75897e2ad44f
|
frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/ArkStructBase.ets
|
arkts
|
base class for user's structs
|
export class ArkStructBase<T, T_Options> extends ArkCustomComponentImpl {
private isEntry:boolean
constructor
|
AST#export_declaration#Left export AST#ERROR#Left class ArkStructBase AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right , AST#type_parameter#Left T_Options AST#type_parameter#Right > AST#type_parameters#Right extends AST#type_annotation#Left AST#primary_type#Left ArkCustomComponentImpl AST#primary_type#Right AST#type_annotation#Right { private isEntry : boolean 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 ArkStructBase<T, T_Options> extends ArkCustomComponentImpl {
private isEntry:boolean
constructor
|
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/ArkStructBase.ets#L24-L26
|
54e0450c1235dc378a16e7635817c1d79fe9be8a
|
gitee
|
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
OptimizationAppDelay/entry/src/main/ets/pages/CameraOptPage.ets
|
arkts
|
onPageHide
|
[Start camera_release_after] The camera page is triggered once every time it is hidden.
|
onPageHide() {
setTimeout(this.releaseCamera, 200);
}
|
AST#method_declaration#Left onPageHide AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_custom_component_statement#Left setTimeout ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . releaseCamera AST#member_expression#Right AST#expression#Right , AST#expression#Left 200 AST#expression#Right ) ; AST#ui_custom_component_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
onPageHide() {
setTimeout(this.releaseCamera, 200);
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/OptimizationAppDelay/entry/src/main/ets/pages/CameraOptPage.ets#L37-L39
|
2f2b309b08fd21e70bc2c8c45eef38045111b093
|
gitee
|
Joker-x-dev/HarmonyKit.git
|
f97197ce157df7f303244fba42e34918306dfb08
|
core/designsystem/src/main/ets/component/Scroll.ets
|
arkts
|
构建带中等内边距的垂直滚动布局
@returns {void} 无返回值
|
build(): void {
VerticalScroll({
scroller: this.scroller,
fillMaxSize: this.fillMaxSize,
fillMaxWidth: this.fillMaxWidth,
widthValue: this.widthValue,
heightValue: this.heightValue,
scrollBarState: this.scrollBarState,
paddingValue: $r("app.float.space_padding_medium"),
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 VerticalScroll ( AST#component_parameters#Left { AST#component_parameter#Left scroller : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scroller 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 fillMaxWidth : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . fillMaxWidth 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 scrollBarState : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scrollBarState AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left paddingValue : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.float.space_padding_medium" AST#expression#Right ) AST#resource_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 {
VerticalScroll({
scroller: this.scroller,
fillMaxSize: this.fillMaxSize,
fillMaxWidth: this.fillMaxWidth,
widthValue: this.widthValue,
heightValue: this.heightValue,
scrollBarState: this.scrollBarState,
paddingValue: $r("app.float.space_padding_medium"),
content: this.content
});
}
|
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/designsystem/src/main/ets/component/Scroll.ets#L216-L227
|
c51d17fc180a072664ae0503c60546afb4ce1d64
|
github
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.