nwo
stringclasses 304
values | sha
stringclasses 304
values | path
stringlengths 9
214
| language
stringclasses 1
value | identifier
stringlengths 0
49
| docstring
stringlengths 1
34.2k
| function
stringlengths 8
59.4k
| ast_function
stringlengths 71
497k
| obf_function
stringlengths 8
39.4k
| url
stringlengths 102
324
| function_sha
stringlengths 40
40
| source
stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/lunar/LunarService.ets
|
arkts
|
getMonthName
|
获取月份名称
|
private getMonthName(month: number, isLeapMonth: boolean): string {
return LunarUtils.getMonthName(month, isLeapMonth);
}
|
AST#method_declaration#Left private getMonthName AST#parameter_list#Left ( AST#parameter#Left month : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left isLeapMonth : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LunarUtils AST#expression#Right . getMonthName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left month AST#expression#Right , AST#expression#Left isLeapMonth 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 getMonthName(month: number, isLeapMonth: boolean): string {
return LunarUtils.getMonthName(month, isLeapMonth);
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/lunar/LunarService.ets#L644-L646
|
6c5f649a1303008f1643072e948a8bf210b668e1
|
github
|
Piagari/arkts_example.git
|
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
|
hmos_app-main/hmos_app-main/legado-Harmony-master/entry/src/main/ets/pages/view/myCenter/readStatistics.ets
|
arkts
|
deleteList
|
删除列表
|
deleteList(){
this.clearInfoDel?.open()
}
|
AST#method_declaration#Left deleteList AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . clearInfoDel AST#member_expression#Right AST#expression#Right ?. open AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
deleteList(){
this.clearInfoDel?.open()
}
|
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/legado-Harmony-master/entry/src/main/ets/pages/view/myCenter/readStatistics.ets#L124-L126
|
57d80756017fe2503ef5a470dd1446e1583eb9d7
|
github
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
ef_ui/src/main/ets/ui/base/LocationUtil.ets
|
arkts
|
getCountryCode
|
获取当前的国家码-无需申请定位权限
@returns 返回当前位置中文描述
|
static async getCountryCode(): Promise<string> {
//获取当前的国家码
let result = await geoLocationManager.getCountryCode();
if (result.country) {
return result.country;
}
return '未获取到获取当前国家码信息~';
}
|
AST#method_declaration#Left static async getCountryCode AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { //获取当前的国家码 AST#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 AST#await_expression#Left await AST#expression#Left geoLocationManager AST#expression#Right AST#await_expression#Right AST#expression#Right . getCountryCode 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 result AST#expression#Right . country AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . country AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left '未获取到获取当前国家码信息~' AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static async getCountryCode(): Promise<string> {
let result = await geoLocationManager.getCountryCode();
if (result.country) {
return result.country;
}
return '未获取到获取当前国家码信息~';
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_ui/src/main/ets/ui/base/LocationUtil.ets#L127-L134
|
d7af0e68947fd703819948085dbe99e6fb14395d
|
gitee
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/app/constants/ResPath.ets
|
arkts
|
封面图片资源定义类
对应 Kotlin object Img
|
export class ResImg {
// 洪恩
/**
* 获取所有封面图片资源
*/
static get allImages(): ResPath[] {
return [
]
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class ResImg AST#class_body#Left { // 洪恩 /**
* 获取所有封面图片资源
*/ AST#method_declaration#Left static get AST#ERROR#Left all Image s AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ResPath [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class ResImg {
static get allImages(): ResPath[] {
return [
]
}
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/app/constants/ResPath.ets#L83-L95
|
11987d6e3f7414e7734a0d19dfc1d705a1630f36
|
github
|
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/models/dbUtils/ResultSetTool.ets
|
arkts
|
getDate
|
/获得日期
|
static getDate(rs: relationalStore.ResultSet, colName: string): Date | null {
return new Date(rs.getString(rs.getColumnIndex(colName)));
}
|
AST#method_declaration#Left static getDate AST#parameter_list#Left ( AST#parameter#Left rs : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left relationalStore . ResultSet AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left colName : 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#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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left rs AST#expression#Right . getString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left rs AST#expression#Right . getColumnIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left colName AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static getDate(rs: relationalStore.ResultSet, colName: string): Date | null {
return new Date(rs.getString(rs.getColumnIndex(colName)));
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/dbUtils/ResultSetTool.ets#L17-L19
|
6abc3bf8e2863a76443b0d0b3f6118b1095fd745
|
github
|
sithvothykiv/dialog_hub.git
|
b676c102ef2d05f8994d170abe48dcc40cd39005
|
custom_dialog/src/main/ets/model/style/ILinearGradient.ets
|
arkts
|
【系统】渐变参数定义
@author pll
@create 2025-06-04 14:25
|
export interface ILinearGradient {
angle?: number | string;
direction?: GradientDirection;
colors: Array<[
ResourceColor,
number
]>;
repeating?: boolean;
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface ILinearGradient AST#object_type#Left { AST#type_member#Left angle ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left string AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left direction ? : AST#type_annotation#Left AST#primary_type#Left GradientDirection AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left colors : 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#tuple_type#Left [ AST#type_annotation#Left AST#primary_type#Left ResourceColor AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ] AST#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#type_member#Right ; AST#type_member#Left repeating ? : AST#type_annotation#Left AST#primary_type#Left boolean 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 ILinearGradient {
angle?: number | string;
direction?: GradientDirection;
colors: Array<[
ResourceColor,
number
]>;
repeating?: boolean;
}
|
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/model/style/ILinearGradient.ets#L6-L14
|
da639bcc8e854432995159f91d260ab15f595833
|
github
|
|
XiangRui_FuZi/harmony-oscourse
|
da885f9a777a1eace7a07e1cd81137746687974b
|
class1/entry/src/main/ets/model/MainViewModel.ets
|
arkts
|
Binds data to components and provides interfaces.
|
export class MainViewModel {
/**
* Get data of the first grid.
*
* @return {Array<PageResource>} firstGridData.
*/
firstGridData: ItemData[] = [
new ItemData(0, $r('app.string.my_love'), $r('app.media.love')),
new ItemData(2, $r('app.string.message'), $r('app.media.message')),
new ItemData(3, $r('app.string.shopping_cart'), $r('app.media.shopping')),
new ItemData(5, $r('app.string.group'), $r('app.media.circle')),
];
}
|
AST#export_declaration#Left export AST#class_declaration#Left class MainViewModel AST#class_body#Left { /**
* Get data of the first grid.
*
* @return {Array<PageResource>} firstGridData.
*/ AST#property_declaration#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 0 AST#expression#Right , 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.love' 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 2 AST#expression#Right , 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.message' 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 3 AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.shopping_cart' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.shopping' 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 5 AST#expression#Right , 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.circle' 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#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class MainViewModel {
firstGridData: ItemData[] = [
new ItemData(0, $r('app.string.my_love'), $r('app.media.love')),
new ItemData(2, $r('app.string.message'), $r('app.media.message')),
new ItemData(3, $r('app.string.shopping_cart'), $r('app.media.shopping')),
new ItemData(5, $r('app.string.group'), $r('app.media.circle')),
];
}
|
https://github.com/XiangRui_FuZi/harmony-oscourse/blob/da885f9a777a1eace7a07e1cd81137746687974b/class1/entry/src/main/ets/model/MainViewModel.ets#L8-L22
|
00f4dad9a42d6d71ae75e9f55452838fb51b540b
|
gitee
|
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/pendingitems/src/main/ets/model/ConstData.ets
|
arkts
|
Copyright (c) 2024 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
export const STYLE_CONFIG: Record<string, number> = {
'IMAGE_MARGIN': 4,
'ICON_GUTTER': 4,
'OPERATION_BUTTON_PADDING': 4,
'MENU_IMAGE_SIZE': 24,
'MENU_HEIGHT': 56,
'TEXT_MARGIN_LEFT': 40,
'IMAGE_MARGIN_RIGHT': 30,
'LIST_ITEM_GUTTER': 12,
'BORDER_WIDTH': 3,
'TODO_ITEM_HEIGHT': 80,
'TODO_ITEM_PADDING_VERTICAL': 4,
'IMAGE_ICON_OK_SIZE': 15,
'ANIMATION_DURATION': 600,
'CUSTOM_CHECKBOX_SIZE': 20,
'IMAGE_SIZE': 32,
'FONT_SIZE_MAX': 18,
'FONT_SIZE_MIN': 14
}
|
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left STYLE_CONFIG : 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 number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left 'IMAGE_MARGIN' AST#property_name#Right : AST#expression#Left 4 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'ICON_GUTTER' AST#property_name#Right : AST#expression#Left 4 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'OPERATION_BUTTON_PADDING' AST#property_name#Right : AST#expression#Left 4 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'MENU_IMAGE_SIZE' AST#property_name#Right : AST#expression#Left 24 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'MENU_HEIGHT' AST#property_name#Right : AST#expression#Left 56 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TEXT_MARGIN_LEFT' AST#property_name#Right : AST#expression#Left 40 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'IMAGE_MARGIN_RIGHT' AST#property_name#Right : AST#expression#Left 30 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'LIST_ITEM_GUTTER' AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'BORDER_WIDTH' AST#property_name#Right : AST#expression#Left 3 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TODO_ITEM_HEIGHT' AST#property_name#Right : AST#expression#Left 80 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TODO_ITEM_PADDING_VERTICAL' AST#property_name#Right : AST#expression#Left 4 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'IMAGE_ICON_OK_SIZE' AST#property_name#Right : AST#expression#Left 15 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'ANIMATION_DURATION' AST#property_name#Right : AST#expression#Left 600 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'CUSTOM_CHECKBOX_SIZE' AST#property_name#Right : AST#expression#Left 20 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'IMAGE_SIZE' AST#property_name#Right : AST#expression#Left 32 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'FONT_SIZE_MAX' AST#property_name#Right : AST#expression#Left 18 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'FONT_SIZE_MIN' AST#property_name#Right : AST#expression#Left 14 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#export_declaration#Right
|
export const STYLE_CONFIG: Record<string, number> = {
'IMAGE_MARGIN': 4,
'ICON_GUTTER': 4,
'OPERATION_BUTTON_PADDING': 4,
'MENU_IMAGE_SIZE': 24,
'MENU_HEIGHT': 56,
'TEXT_MARGIN_LEFT': 40,
'IMAGE_MARGIN_RIGHT': 30,
'LIST_ITEM_GUTTER': 12,
'BORDER_WIDTH': 3,
'TODO_ITEM_HEIGHT': 80,
'TODO_ITEM_PADDING_VERTICAL': 4,
'IMAGE_ICON_OK_SIZE': 15,
'ANIMATION_DURATION': 600,
'CUSTOM_CHECKBOX_SIZE': 20,
'IMAGE_SIZE': 32,
'FONT_SIZE_MAX': 18,
'FONT_SIZE_MIN': 14
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/pendingitems/src/main/ets/model/ConstData.ets#L16-L34
|
e679086ce45bdc5bef44bd516a4bfa01aa66f54d
|
gitee
|
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
entry/src/main/ets/component/LottieView.ets
|
arkts
|
LottieBuilder
|
Lottie加载动画
|
@Builder
export function LottieBuilder(options: LoadOptions) {
LottieView({ options: options })
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function LottieBuilder AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left LoadOptions 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 LottieView ( 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_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 LottieBuilder(options: LoadOptions) {
LottieView({ options: options })
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/entry/src/main/ets/component/LottieView.ets#L7-L10
|
c93b03f81a3a693902f6b825c6bfdfbf5dc00407
|
gitee
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/videolistautoplay/src/main/ets/model/NewsItemModel.ets
|
arkts
|
视频信息,包括标题、视频地址、首帧图片、视频详情
|
export class NewsItem {
newsName: string; // 标题
newsVideoSrc: string; // 视频地址
newsImage: ResourceStr; // 首帧图片
newsDetails: ResourceStr; // 详情
constructor(newsName: string, newsVideoSrc: string, newsImage: ResourceStr, newsDetails: ResourceStr) {
this.newsName = newsName;
this.newsVideoSrc = newsVideoSrc;
this.newsImage = newsImage;
this.newsDetails = newsDetails;
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class NewsItem AST#class_body#Left { AST#property_declaration#Left newsName : 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 newsVideoSrc : 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 newsImage : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 首帧图片 AST#property_declaration#Left newsDetails : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 详情 AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left newsName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left newsVideoSrc : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left newsImage : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left newsDetails : AST#type_annotation#Left AST#primary_type#Left ResourceStr 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 . newsName AST#member_expression#Right = AST#expression#Left newsName 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 . newsVideoSrc AST#member_expression#Right = AST#expression#Left newsVideoSrc 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 . newsImage AST#member_expression#Right = AST#expression#Left newsImage 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 . newsDetails AST#member_expression#Right = AST#expression#Left newsDetails AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class NewsItem {
newsName: string;
newsVideoSrc: string;
newsImage: ResourceStr;
newsDetails: ResourceStr;
constructor(newsName: string, newsVideoSrc: string, newsImage: ResourceStr, newsDetails: ResourceStr) {
this.newsName = newsName;
this.newsVideoSrc = newsVideoSrc;
this.newsImage = newsImage;
this.newsDetails = newsDetails;
}
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/videolistautoplay/src/main/ets/model/NewsItemModel.ets#L19-L31
|
ea3749ea538911eeab3adc88d2a705c5d05b8e38
|
gitee
|
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/views/main/sub/report/RadarView.ets
|
arkts
|
buildLegend
|
========== 图例区域构建器 ==========
|
@Builder
buildLegend() {
Column({ space: 8 }) {
ForEach(this.parts, (part: ChartPart, index?: number) => {
Row({ space: 8 }) {
// 颜色标识
Rect()
.width(12)
.height(12)
.backgroundColor(part.color)
.borderRadius(2)
// 文本信息
Column({ space: 2 }) {
Text(part.partName)
.fontSize(15)
.fontColor(Color.Black)
.textAlign(TextAlign.Start)
Text(`${part.curCount}/${part.allCount} (${(part.ratio * 100).toFixed(1)}%)`)
.fontSize(15)
.fontColor(Color.Black)
}
.layoutWeight(1)
}
.width('100%')
.padding(4)
.onClick(() => {
if (this.onPartClick) {
this.onPartClick(part.partName, part.clone());
}
})
}, (part: ChartPart) => part.partName)
}
.width(140)
.padding(8)
.backgroundColor('#FFFFFF')
.borderRadius(8)
//.shadow({ radius: 2, color: '#1A000000', offsetX: 1, offsetY: 1 })
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildLegend AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 8 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 . parts AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left part : AST#type_annotation#Left AST#primary_type#Left ChartPart 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 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 Rect ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left part AST#expression#Right . color AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 2 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 文本信息 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 2 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left part AST#expression#Right . partName AST#member_expression#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 . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Black AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 part AST#expression#Right . curCount 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 part AST#expression#Right . allCount AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ( AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left part AST#expression#Right . ratio AST#member_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 1 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#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 15 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Black AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#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 4 AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onPartClick AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onPartClick AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left part AST#expression#Right . partName AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left part AST#expression#Right . clone AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#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 part : AST#type_annotation#Left AST#primary_type#Left ChartPart AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#member_expression#Left AST#expression#Left part AST#expression#Right . partName AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 140 AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left 8 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#FFFFFF' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 8 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right //.shadow({ radius: 2, color: '#1A000000', offsetX: 1, offsetY: 1 }) } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
buildLegend() {
Column({ space: 8 }) {
ForEach(this.parts, (part: ChartPart, index?: number) => {
Row({ space: 8 }) {
Rect()
.width(12)
.height(12)
.backgroundColor(part.color)
.borderRadius(2)
Column({ space: 2 }) {
Text(part.partName)
.fontSize(15)
.fontColor(Color.Black)
.textAlign(TextAlign.Start)
Text(`${part.curCount}/${part.allCount} (${(part.ratio * 100).toFixed(1)}%)`)
.fontSize(15)
.fontColor(Color.Black)
}
.layoutWeight(1)
}
.width('100%')
.padding(4)
.onClick(() => {
if (this.onPartClick) {
this.onPartClick(part.partName, part.clone());
}
})
}, (part: ChartPart) => part.partName)
}
.width(140)
.padding(8)
.backgroundColor('#FFFFFF')
.borderRadius(8)
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/views/main/sub/report/RadarView.ets#L76-L116
|
3deacadc4ae9f9934a5c59dca6c33fdc667b7239
|
github
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/DocsSample/ArkUISample/EventProject/entry/src/main/ets/pages/focus/FocusController.ets
|
arkts
|
FocusControl
|
[Start dynamic_focus_control_demo]
|
@Entry
@Component
export struct FocusControl {
@State btColor: string = '#ff2787d9';
@State btColor2: string = '#ff2787d9';
build() {
NavDestination() {
Column({ space: 12 }) {
Column({ space: 20 }) {
Column({ space: 5 }) {
Button('Button')
.width(200)
.height(70)
.fontColor(Color.White)
.focusOnTouch(true)
.backgroundColor(this.btColor)
.onFocus(() => {
this.btColor = '#ffd5d5d5';
})
.onBlur(() => {
this.btColor = '#ff2787d9';
})
.id('testButton')
Button('Button')
.width(200)
.height(70)
.fontColor(Color.White)
.focusOnTouch(true)
.backgroundColor(this.btColor2)
.onFocus(() => {
this.btColor2 = '#ffd5d5d5';
})
.onBlur(() => {
this.btColor2 = '#ff2787d9';
})
.id('testButton2')
Divider()
.vertical(false)
.width('80%')
.backgroundColor('#ff707070')
.height(10)
Button('FocusController.requestFocus')
.width(200).height(70).fontColor(Color.White)
.onClick(() => {
this.getUIContext().getFocusController().requestFocus('testButton');
})
.backgroundColor('#ff2787d9')
Button('focusControl.requestFocus')
.width(200).height(70).fontColor(Color.White)
.onClick(() => {
focusControl.requestFocus('testButton2');
})
.backgroundColor('#ff2787d9')
Button('clearFocus')
.width(200).height(70).fontColor(Color.White)
.onClick(() => {
this.getUIContext().getFocusController().clearFocus();
})
.backgroundColor('#ff2787d9')
}
}
.width('100%')
.height('100%')
}
.width('100%')
.height('100%')
.padding({ left: 12, right: 12 })
}
.backgroundColor('#f1f2f3')
.title($r('app.string.Focus_FocusController_title'))
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Entry AST#decorator#Right AST#decorator#Left @ Component AST#decorator#Right export struct FocusControl AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right btColor : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '#ff2787d9' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right btColor2 : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '#ff2787d9' AST#expression#Right ; AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left NavDestination ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 12 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 20 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 5 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left 'Button' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 200 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 70 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 . focusOnTouch ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . btColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onFocus ( 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 . btColor AST#member_expression#Right = AST#expression#Left '#ffd5d5d5' 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 . onBlur ( 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 . btColor AST#member_expression#Right = AST#expression#Left '#ff2787d9' 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 . id ( AST#expression#Left 'testButton' 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 'Button' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 200 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 70 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 . focusOnTouch ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . btColor2 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onFocus ( 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 . btColor2 AST#member_expression#Right = AST#expression#Left '#ffd5d5d5' 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 . onBlur ( 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 . btColor2 AST#member_expression#Right = AST#expression#Left '#ff2787d9' 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 . id ( AST#expression#Left 'testButton2' 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 Divider ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . vertical ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '80%' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#ff707070' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 10 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 Button ( AST#expression#Left 'FocusController.requestFocus' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 200 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 70 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 . 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getUIContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getFocusController AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . requestFocus AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'testButton' 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#Left . backgroundColor ( AST#expression#Left '#ff2787d9' 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 Button ( AST#expression#Left 'focusControl.requestFocus' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 200 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 70 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 . 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 focusControl AST#expression#Right . requestFocus AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'testButton2' 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#Left . backgroundColor ( AST#expression#Left '#ff2787d9' 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 Button ( AST#expression#Left 'clearFocus' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 200 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 70 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 . 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getUIContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getFocusController AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . clearFocus AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#ff2787d9' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . 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#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#f1f2f3' AST#expression#Right ) AST#modifier_chain_expression#Left . title ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.Focus_FocusController_title' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Entry
@Component
export struct FocusControl {
@State btColor: string = '#ff2787d9';
@State btColor2: string = '#ff2787d9';
build() {
NavDestination() {
Column({ space: 12 }) {
Column({ space: 20 }) {
Column({ space: 5 }) {
Button('Button')
.width(200)
.height(70)
.fontColor(Color.White)
.focusOnTouch(true)
.backgroundColor(this.btColor)
.onFocus(() => {
this.btColor = '#ffd5d5d5';
})
.onBlur(() => {
this.btColor = '#ff2787d9';
})
.id('testButton')
Button('Button')
.width(200)
.height(70)
.fontColor(Color.White)
.focusOnTouch(true)
.backgroundColor(this.btColor2)
.onFocus(() => {
this.btColor2 = '#ffd5d5d5';
})
.onBlur(() => {
this.btColor2 = '#ff2787d9';
})
.id('testButton2')
Divider()
.vertical(false)
.width('80%')
.backgroundColor('#ff707070')
.height(10)
Button('FocusController.requestFocus')
.width(200).height(70).fontColor(Color.White)
.onClick(() => {
this.getUIContext().getFocusController().requestFocus('testButton');
})
.backgroundColor('#ff2787d9')
Button('focusControl.requestFocus')
.width(200).height(70).fontColor(Color.White)
.onClick(() => {
focusControl.requestFocus('testButton2');
})
.backgroundColor('#ff2787d9')
Button('clearFocus')
.width(200).height(70).fontColor(Color.White)
.onClick(() => {
this.getUIContext().getFocusController().clearFocus();
})
.backgroundColor('#ff2787d9')
}
}
.width('100%')
.height('100%')
}
.width('100%')
.height('100%')
.padding({ left: 12, right: 12 })
}
.backgroundColor('#f1f2f3')
.title($r('app.string.Focus_FocusController_title'))
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ArkUISample/EventProject/entry/src/main/ets/pages/focus/FocusController.ets#L20-L99
|
88c8000837353fe92a5636c2bd961ad785138dd9
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/common/i18n/LanguageDetector.ets
|
arkts
|
语言使用记录接口
|
export interface LanguageUsageRecord {
language: SupportedLanguage;
timestamp: string;
duration: number; // 使用时长(分钟)
source: DetectionSource;
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface LanguageUsageRecord AST#object_type#Left { AST#type_member#Left language : AST#type_annotation#Left AST#primary_type#Left SupportedLanguage AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left timestamp : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left duration : 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 source : AST#type_annotation#Left AST#primary_type#Left DetectionSource 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 LanguageUsageRecord {
language: SupportedLanguage;
timestamp: string;
duration: number;
source: DetectionSource;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/i18n/LanguageDetector.ets#L47-L52
|
4fe7eee46b0292aca00ea3db138e31d93a11672a
|
github
|
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/videocache/src/main/ets/model/GlobalProxyServer.ets
|
arkts
|
getContext
|
获取上下文信息
@returns
|
getContext(): common.UIAbilityContext {
return this.objects.get(CONTEXT_STR) as common.UIAbilityContext;
}
|
AST#method_declaration#Left getContext AST#parameter_list#Left ( ) AST#parameter_list#Right : 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#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . objects AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left CONTEXT_STR AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
getContext(): common.UIAbilityContext {
return this.objects.get(CONTEXT_STR) as common.UIAbilityContext;
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/videocache/src/main/ets/model/GlobalProxyServer.ets#L37-L39
|
f24338914cfbd8ec5c3655818a1844e5512fcdbb
|
gitee
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/DeviceUtil.ets
|
arkts
|
getOsReleaseType
|
获取系统的发布类型,取值为:Canary、Beta、Release
|
static getOsReleaseType(): string {
return deviceInfo.osReleaseType;
}
|
AST#method_declaration#Left static getOsReleaseType AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left deviceInfo AST#expression#Right . osReleaseType AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static getOsReleaseType(): string {
return deviceInfo.osReleaseType;
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/DeviceUtil.ets#L238-L240
|
cfccddd064274773b72193defd996c34bd53c375
|
gitee
|
Piagari/arkts_example.git
|
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
|
hmos_app-main/hmos_app-main/legado-Harmony-master/readerLibrary/src/main/ets/common/constants/Constants.ets
|
arkts
|
Background color array.
|
export const BG_COLOR_ARRAY: string[] = ['#FFFFFF', '#FDEAD3', '#DFF7E5', '#DFF1FA'];
|
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left BG_COLOR_ARRAY : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left '#FFFFFF' AST#expression#Right , AST#expression#Left '#FDEAD3' AST#expression#Right , AST#expression#Left '#DFF7E5' AST#expression#Right , AST#expression#Left '#DFF1FA' AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
|
export const BG_COLOR_ARRAY: string[] = ['#FFFFFF', '#FDEAD3', '#DFF7E5', '#DFF1FA'];
|
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/legado-Harmony-master/readerLibrary/src/main/ets/common/constants/Constants.ets#L191-L191
|
0930ffef6f8e44a437b35424a3e8ce7a12b07b08
|
github
|
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/common/utils/DateUtils.ets
|
arkts
|
addHours
|
增加小时
@param date 基准日期
@param hoursToAdd 增加的小时数
@returns 新日期对象
|
static addHours(date: Date, hoursToAdd: number): Date {
return new Date(date.getTime() + hoursToAdd * 3600000); // 60 * 60 * 1000
}
|
AST#method_declaration#Left static addHours AST#parameter_list#Left ( AST#parameter#Left date : AST#type_annotation#Left AST#primary_type#Left Date AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left hoursToAdd : 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 Date AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . 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 hoursToAdd AST#expression#Right * AST#expression#Left 3600000 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 ; AST#return_statement#Right AST#statement#Right // 60 * 60 * 1000 } AST#block_statement#Right AST#method_declaration#Right
|
static addHours(date: Date, hoursToAdd: number): Date {
return new Date(date.getTime() + hoursToAdd * 3600000);
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/utils/DateUtils.ets#L82-L84
|
72351956026a106a361893fbcf3109f50c2a826c
|
github
|
L1rics06/arkTS-.git
|
991fd131bfdb11e2933152133c97453d86092ac0
|
entry/src/main/ets/pages/NetworkUtil.ets
|
arkts
|
清空未读请求参数
|
export interface ClearUnreadParams {
myId: string;
friendId: string;
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface ClearUnreadParams AST#object_type#Left { AST#type_member#Left myId : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left friendId : 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 ClearUnreadParams {
myId: string;
friendId: string;
}
|
https://github.com/L1rics06/arkTS-.git/blob/991fd131bfdb11e2933152133c97453d86092ac0/entry/src/main/ets/pages/NetworkUtil.ets#L200-L203
|
c7a78063decc94a92482e3221938dbec784de744
|
github
|
|
Joker-x-dev/HarmonyKit.git
|
f97197ce157df7f303244fba42e34918306dfb08
|
core/model/src/main/ets/network/NetworkPageMeta.ets
|
arkts
|
@file 分页元数据模型
@author Joker.X
|
export class NetworkPageMeta {
/**
* 总条数
*/
total: number | null;
/**
* 每页显示条数
*/
size: number | null;
/**
* 当前页码
*/
page: number | null;
/**
* 构造函数,对接口返回做空值兜底
* @param {Partial<NetworkPageMeta>} payload - 接口返回的分页数据
*/
constructor(payload?: Partial<NetworkPageMeta>) {
this.total = payload?.total ?? null;
this.size = payload?.size ?? null;
this.page = payload?.page ?? null;
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class NetworkPageMeta AST#class_body#Left { /**
* 总条数
*/ AST#property_declaration#Left total : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* 每页显示条数
*/ AST#property_declaration#Left size : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* 当前页码
*/ AST#property_declaration#Left page : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* 构造函数,对接口返回做空值兜底
* @param {Partial<NetworkPageMeta>} payload - 接口返回的分页数据
*/ AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left payload ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Partial AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left NetworkPageMeta 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 . total AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left payload AST#expression#Right ?. total 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#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . size AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left payload AST#expression#Right ?. size 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#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . page AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left payload AST#expression#Right ?. page 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#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class NetworkPageMeta {
total: number | null;
size: number | null;
page: number | null;
constructor(payload?: Partial<NetworkPageMeta>) {
this.total = payload?.total ?? null;
this.size = payload?.size ?? null;
this.page = payload?.page ?? null;
}
}
|
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/model/src/main/ets/network/NetworkPageMeta.ets#L5-L28
|
c6c7959146dedbacc6953fc906d1f74d7a06cb81
|
github
|
|
openharmony-tpc/ohos_mpchart
|
4fb43a7137320ef2fee2634598f53d93975dfb4a
|
library/src/main/ets/components/highlight/BarHighlighter.ets
|
arkts
|
getDistance
|
/** * Splits up the stack-values of the given bar-entry into Range objects. * * @param entry * @return protected Range[] getRanges(BarEntry entry) { float[] values = entry.getYVals(); if (values == null || values.length == 0) return new Range[0]; Range[] ranges = new Range[values.length]; float negRemain = -entry.getNegativeSum(); float posRemain = 0f; for (int i = 0; i < ranges.length; i++) { float value = values[i]; if (value < 0) { ranges[i] = new Range(negRemain, negRemain + Math.abs(value)); negRemain += Math.abs(value); } else { ranges[i] = new Range(posRemain, posRemain + value); posRemain += value; } } return ranges; }
|
protected getDistance(x1: number, y1: number, x2: number, y2: number): number {
return Math.abs(x1 - x2);
}
|
AST#method_declaration#Left protected getDistance AST#parameter_list#Left ( AST#parameter#Left x1 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left y1 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left x2 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left y2 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . abs AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left x1 AST#expression#Right - AST#expression#Left x2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
protected getDistance(x1: number, y1: number, x2: number, y2: number): number {
return Math.abs(x1 - x2);
}
|
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/highlight/BarHighlighter.ets#L169-L171
|
30612a0a4e8932b72372da06345adbd070da355a
|
gitee
|
Joker-x-dev/CoolMallArkTS.git
|
9f3fabf89fb277692cb82daf734c220c7282919c
|
core/ui/src/main/ets/component/card/Card.ets
|
arkts
|
构建卡片视图
@returns {void} 无返回值
|
build(): void {
Column() {
if (this.content) {
this.content();
}
}
.width(this.widthValue)
.height(this.heightValue)
.padding(this.paddingValue)
.backgroundColor(this.bgColor)
.borderRadius(this.radiusValue)
.onClick((): void => this.onTap());
}
|
AST#build_method#Left build ( ) : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left 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 . content AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . content 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#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . widthValue AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . heightValue AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . paddingValue AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bgColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . radiusValue 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#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onTap 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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#build_body#Right AST#build_method#Right
|
build(): void {
Column() {
if (this.content) {
this.content();
}
}
.width(this.widthValue)
.height(this.heightValue)
.padding(this.paddingValue)
.backgroundColor(this.bgColor)
.borderRadius(this.radiusValue)
.onClick((): void => this.onTap());
}
|
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/ui/src/main/ets/component/card/Card.ets#L51-L63
|
0c093469dca79b75f022c51f1c38fc58801d1035
|
github
|
|
charon2pluto/MoodDiary-HarmonyOS.git
|
0ec7ee6861e150bc9b4571062dbf302d1b106b8c
|
entry/src/main/ets/pages/MoodHistory.ets
|
arkts
|
applyFilter
|
★ 核心逻辑:执行筛选
|
applyFilter() {
if (this.searchText.trim() === '') {
this.filteredList = this.historyList;
} else {
const keyword = this.searchText.toLowerCase();
this.filteredList = this.historyList.filter(item =>
// 搜索范围:原因文字 或 日记正文
item.reason.toLowerCase().includes(keyword) ||
item.diaryContent.toLowerCase().includes(keyword)
);
}
}
|
AST#method_declaration#Left applyFilter 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . searchText AST#member_expression#Right AST#expression#Right . trim AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right === AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . filteredList AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . historyList AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } else { AST#expression_statement#Left AST#expression#Left const AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left keyword = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . searchText AST#member_expression#Right AST#expression#Right . toLowerCase AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 . filteredList 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 . historyList AST#member_expression#Right AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left item => // 搜索范围:原因文字 或 日记正文 AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . reason AST#member_expression#Right AST#expression#Right . toLowerCase AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . includes AST#member_expression#Right 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#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . diaryContent AST#member_expression#Right AST#expression#Right . toLowerCase AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . includes AST#member_expression#Right 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#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
applyFilter() {
if (this.searchText.trim() === '') {
this.filteredList = this.historyList;
} else {
const keyword = this.searchText.toLowerCase();
this.filteredList = this.historyList.filter(item =>
item.reason.toLowerCase().includes(keyword) ||
item.diaryContent.toLowerCase().includes(keyword)
);
}
}
|
https://github.com/charon2pluto/MoodDiary-HarmonyOS.git/blob/0ec7ee6861e150bc9b4571062dbf302d1b106b8c/entry/src/main/ets/pages/MoodHistory.ets#L40-L51
|
9817d97abbc41357d124b8dbc677984bbac71283
|
github
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
LowPowerOfForegroundTask/entry/src/main/ets/entryability/EntryAbility.ets
|
arkts
|
[Start power_entry_ability]
|
export default class EntryAbility extends UIAbility {
// [StartExclude power_entry_ability]
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
try {
this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
} catch (error) {
hilog.info(DOMAIN, 'testTag', '%{public}s', 'setColorMode fail');
}
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
}
onDestroy(): void {
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy');
}
// [EndExclude power_entry_ability]
onWindowStageCreate(windowStage: window.WindowStage): void {
// [StartExclude power_entry_ability]
// Main window is created, set main page for this ability
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
windowStage.loadContent('pages/Index', (err) => {
if (err.code) {
hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
return;
}
hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
});
// [EndExclude power_entry_ability]
// Determine whether it is currently in dark mode.
if (this.context?.config?.colorMode == ConfigurationConstant.ColorMode.COLOR_MODE_DARK) {
try {
let windowClass = windowStage.getMainWindowSync();
// Set the brightness of the current application window
windowClass.setWindowBrightness(0.2, (err) => {
if (err.code) {
console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting the brightness.');
});
} catch (exception) {
console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception));
}
}
}
// [StartExclude power_entry_ability]
onWindowStageDestroy(): void {
// Main window is destroyed, release UI related resources
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}
onForeground(): void {
// Ability has brought to foreground
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground');
}
onBackground(): void {
// Ability has back to background
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground');
}
// [EndExclude power_entry_ability]
}
|
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 { // [StartExclude power_entry_ability] 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#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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right AST#expression#Right . getApplicationContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . setColorMode 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 ConfigurationConstant AST#expression#Right . ColorMode AST#member_expression#Right AST#expression#Right . COLOR_MODE_NOT_SET AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left 'setColorMode fail' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left 'Ability onCreate' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left onDestroy 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 hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left '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 // [EndExclude power_entry_ability] AST#method_declaration#Left onWindowStageCreate AST#parameter_list#Left ( AST#parameter#Left windowStage : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . WindowStage AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // [StartExclude power_entry_ability] // Main window is created, set main page for this ability 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 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 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 windowStage AST#expression#Right . loadContent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'pages/Index' AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right ) AST#parameter_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 DOMAIN 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#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 AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left 'Succeeded in loading the content.' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // [EndExclude power_entry_ability] // Determine whether it is currently in dark mode. AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right AST#expression#Right ?. config AST#member_expression#Right AST#expression#Right ?. colorMode AST#member_expression#Right AST#expression#Right == AST#expression#Left ConfigurationConstant AST#expression#Right AST#binary_expression#Right AST#expression#Right . ColorMode AST#member_expression#Right AST#expression#Right . COLOR_MODE_DARK AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#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 windowStage AST#expression#Right . getMainWindowSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // Set the brightness of the current application window 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 . setWindowBrightness AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0.2 AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err 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 set the brightness. 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#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 'Succeeded in setting the brightness.' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( exception ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'Failed to set the brightness. 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 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#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // [StartExclude power_entry_ability] AST#method_declaration#Left onWindowStageDestroy 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 { // 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 DOMAIN 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#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#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 DOMAIN 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#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#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 DOMAIN 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 // [EndExclude power_entry_ability] } 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 {
try {
this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
} catch (error) {
hilog.info(DOMAIN, 'testTag', '%{public}s', 'setColorMode fail');
}
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
}
onDestroy(): void {
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage): void {
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
windowStage.loadContent('pages/Index', (err) => {
if (err.code) {
hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
return;
}
hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
});
if (this.context?.config?.colorMode == ConfigurationConstant.ColorMode.COLOR_MODE_DARK) {
try {
let windowClass = windowStage.getMainWindowSync();
windowClass.setWindowBrightness(0.2, (err) => {
if (err.code) {
console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting the brightness.');
});
} catch (exception) {
console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception));
}
}
}
onWindowStageDestroy(): void {
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}
onForeground(): void {
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground');
}
onBackground(): void {
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground');
}
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/LowPowerOfForegroundTask/entry/src/main/ets/entryability/EntryAbility.ets#L8-L69
|
9f3358208c78dd4a99d4a89376230b612058789c
|
gitee
|
|
kico0909/crazy_miner.git
|
13eae3ac4d8ca11ecf2c97b375f82f24ab7919b9
|
entry/src/main/ets/common/game/types/player.ets
|
arkts
|
玩家类型声明
|
export interface TAchiveItem {
name: string
count: number
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface TAchiveItem AST#object_type#Left { AST#type_member#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right AST#type_member#Left count : 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 TAchiveItem {
name: string
count: number
}
|
https://github.com/kico0909/crazy_miner.git/blob/13eae3ac4d8ca11ecf2c97b375f82f24ab7919b9/entry/src/main/ets/common/game/types/player.ets#L4-L7
|
0bfcecb2f26885fe870681b86a700b221336b42d
|
github
|
|
LumenVestige/HarmonyHelloWorldApp.git
|
84189de8d36a9869b353e62f71cec95c5420e763
|
commons/utils/src/main/ets/common/CommonConstants.ets
|
arkts
|
Common constants for common component.
|
export class CommonConstants {
// font family
static readonly HARMONY_HEI_TI_FONT_FAMILY = 'HarmonyHeiTi';
static readonly HARMONY_HEITI_MEDIUM_FONT_FAMILY = 'HarmonyHeiTi-Medium';
static readonly HARMONY_HEITI_BOLD_FONT_FAMILY = 'HarmonyHeiTi-Bold';
// font weight
static readonly DIALOG_TITLE_FONT_WEIGHT: number = 700;
static readonly DIALOG_BUTTON_FONT_WEIGHT: number = 500;
static readonly NORMAL_FONT_WEIGHT: number = 400;
// opacity
static readonly FIRST_LEVEL_OPACITY: number = 0.9;
static readonly SECOND_LEVEL_OPACITY: number = 0.6;
static readonly HALF_OPACITY: number = 0.5;
static readonly THIRD_LEVEL_OPACITY: number = 0.3;
static readonly Divider_OPACITY: number = 0.05;
// blur
static readonly REGULAR_BLUR: number = 250;
// space
static readonly SPACE_4: number = 4;
static readonly SPACE_8: number = 8;
static readonly SPACE_12: number = 12;
static readonly SPACE_16: number = 16;
// maxLines
static readonly MAX_LINE_ONE: number = 1;
static readonly MAX_LINE_TWO: number = 2;
// column count
static readonly SM_COLUMN_COUNT: number = 1;
static readonly MD_COLUMN_COUNT: number = 2;
static readonly LG_COLUMN_COUNT: number = 3;
// swiper duration
static readonly SWIPER_DURATION: number = 1000;
// percent
static readonly FULL_PERCENT: string = '100%';
static readonly HALF_PERCENT: string = '50%';
static readonly NAVI_BAR_WIDTH: string = '40%';
// skeleton animation config
static readonly SKELETON_ANIMATION: AnimateParam = {
duration: 400,
tempo: 0.6,
curve: Curve.EaseInOut,
delay: 200,
iterations: -1,
playMode: PlayMode.Alternate
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class CommonConstants AST#class_body#Left { // font family AST#property_declaration#Left static readonly HARMONY_HEI_TI_FONT_FAMILY = AST#expression#Left 'HarmonyHeiTi' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly HARMONY_HEITI_MEDIUM_FONT_FAMILY = AST#expression#Left 'HarmonyHeiTi-Medium' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly HARMONY_HEITI_BOLD_FONT_FAMILY = AST#expression#Left 'HarmonyHeiTi-Bold' AST#expression#Right ; AST#property_declaration#Right // font weight AST#property_declaration#Left static readonly DIALOG_TITLE_FONT_WEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 700 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly DIALOG_BUTTON_FONT_WEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 500 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly NORMAL_FONT_WEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 400 AST#expression#Right ; AST#property_declaration#Right // opacity AST#property_declaration#Left static readonly FIRST_LEVEL_OPACITY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0.9 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly SECOND_LEVEL_OPACITY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0.6 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly HALF_OPACITY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0.5 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly THIRD_LEVEL_OPACITY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0.3 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly Divider_OPACITY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0.05 AST#expression#Right ; AST#property_declaration#Right // blur AST#property_declaration#Left static readonly REGULAR_BLUR : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 250 AST#expression#Right ; AST#property_declaration#Right // space AST#property_declaration#Left static readonly SPACE_4 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 4 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly SPACE_8 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 8 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly SPACE_12 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 12 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly SPACE_16 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 16 AST#expression#Right ; AST#property_declaration#Right // maxLines AST#property_declaration#Left static readonly MAX_LINE_ONE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly MAX_LINE_TWO : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 2 AST#expression#Right ; AST#property_declaration#Right // column count AST#property_declaration#Left static readonly SM_COLUMN_COUNT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly MD_COLUMN_COUNT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 2 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly LG_COLUMN_COUNT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 3 AST#expression#Right ; AST#property_declaration#Right // swiper duration AST#property_declaration#Left static readonly SWIPER_DURATION : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1000 AST#expression#Right ; AST#property_declaration#Right // percent AST#property_declaration#Left static readonly FULL_PERCENT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '100%' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly HALF_PERCENT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '50%' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly NAVI_BAR_WIDTH : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '40%' AST#expression#Right ; AST#property_declaration#Right // skeleton animation config AST#property_declaration#Left static readonly SKELETON_ANIMATION : AST#type_annotation#Left AST#primary_type#Left AnimateParam AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left 400 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left tempo AST#property_name#Right : AST#expression#Left 0.6 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#property_assignment#Left AST#property_name#Left delay AST#property_name#Right : AST#expression#Left 200 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left iterations AST#property_name#Right : AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left playMode AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left PlayMode AST#expression#Right . Alternate AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class CommonConstants {
static readonly HARMONY_HEI_TI_FONT_FAMILY = 'HarmonyHeiTi';
static readonly HARMONY_HEITI_MEDIUM_FONT_FAMILY = 'HarmonyHeiTi-Medium';
static readonly HARMONY_HEITI_BOLD_FONT_FAMILY = 'HarmonyHeiTi-Bold';
static readonly DIALOG_TITLE_FONT_WEIGHT: number = 700;
static readonly DIALOG_BUTTON_FONT_WEIGHT: number = 500;
static readonly NORMAL_FONT_WEIGHT: number = 400;
static readonly FIRST_LEVEL_OPACITY: number = 0.9;
static readonly SECOND_LEVEL_OPACITY: number = 0.6;
static readonly HALF_OPACITY: number = 0.5;
static readonly THIRD_LEVEL_OPACITY: number = 0.3;
static readonly Divider_OPACITY: number = 0.05;
static readonly REGULAR_BLUR: number = 250;
static readonly SPACE_4: number = 4;
static readonly SPACE_8: number = 8;
static readonly SPACE_12: number = 12;
static readonly SPACE_16: number = 16;
static readonly MAX_LINE_ONE: number = 1;
static readonly MAX_LINE_TWO: number = 2;
static readonly SM_COLUMN_COUNT: number = 1;
static readonly MD_COLUMN_COUNT: number = 2;
static readonly LG_COLUMN_COUNT: number = 3;
static readonly SWIPER_DURATION: number = 1000;
static readonly FULL_PERCENT: string = '100%';
static readonly HALF_PERCENT: string = '50%';
static readonly NAVI_BAR_WIDTH: string = '40%';
static readonly SKELETON_ANIMATION: AnimateParam = {
duration: 400,
tempo: 0.6,
curve: Curve.EaseInOut,
delay: 200,
iterations: -1,
playMode: PlayMode.Alternate
}
}
|
https://github.com/LumenVestige/HarmonyHelloWorldApp.git/blob/84189de8d36a9869b353e62f71cec95c5420e763/commons/utils/src/main/ets/common/CommonConstants.ets#L19-L66
|
532c0277f6fe5938b739d7cbfad31bd0c592eb5b
|
github
|
|
Joker-x-dev/CoolMallArkTS.git
|
9f3fabf89fb277692cb82daf734c220c7282919c
|
feature/main/src/main/ets/viewmodel/CategoryViewModel.ets
|
arkts
|
aboutToDisappear
|
页面隐藏时清理计时器
@returns {void} 无返回值
|
aboutToDisappear(): void {
this.clearSideBarUnlockTimer();
}
|
AST#method_declaration#Left aboutToDisappear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . clearSideBarUnlockTimer AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
aboutToDisappear(): void {
this.clearSideBarUnlockTimer();
}
|
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/main/src/main/ets/viewmodel/CategoryViewModel.ets#L180-L182
|
a20e190a82ea6dca97df403df12a104235ea54b6
|
github
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/media/VoiceService.ets
|
arkts
|
speakText
|
语音合成播放文本
|
async speakText(text: string, config?: Partial<TTSConfig>): Promise<void> {
if (!this.ttsEngine) {
throw new Error('TTS引擎未初始化');
}
try {
if (this.isSpeaking) {
await this.stopSpeaking();
}
const ttsConfig = { ...this.defaultTTSConfig, ...config };
// 设置TTS参数
await this.ttsEngine.setRate(ttsConfig.rate);
await this.ttsEngine.setPitch(ttsConfig.pitch);
await this.ttsEngine.setVolume(ttsConfig.volume);
// 开始合成和播放
await this.ttsEngine.speak(text);
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Speaking text: ${text}`);
} catch (error) {
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to speak text: ${error}`);
throw error;
}
}
|
AST#method_declaration#Left async speakText 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#Left config ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Partial AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left TTSConfig AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . ttsEngine 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 'TTS引擎未初始化' 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#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 this AST#expression#Right . isSpeaking 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 this AST#expression#Right AST#await_expression#Right AST#expression#Right . stopSpeaking AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left ttsConfig = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left ... AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . defaultTTSConfig AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left ... AST#expression#Left config 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 // 设置TTS参数 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 . ttsEngine AST#member_expression#Right AST#expression#Right . setRate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left ttsConfig AST#expression#Right . rate AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . ttsEngine AST#member_expression#Right AST#expression#Right . setPitch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left ttsConfig AST#expression#Right . pitch AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . ttsEngine AST#member_expression#Right AST#expression#Right . setVolume AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left ttsConfig AST#expression#Right . volume AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 开始合成和播放 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . ttsEngine AST#member_expression#Right AST#expression#Right . speak AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left text AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Speaking text: AST#template_substitution#Left $ { AST#expression#Left text AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 speak text: 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 speakText(text: string, config?: Partial<TTSConfig>): Promise<void> {
if (!this.ttsEngine) {
throw new Error('TTS引擎未初始化');
}
try {
if (this.isSpeaking) {
await this.stopSpeaking();
}
const ttsConfig = { ...this.defaultTTSConfig, ...config };
await this.ttsEngine.setRate(ttsConfig.rate);
await this.ttsEngine.setPitch(ttsConfig.pitch);
await this.ttsEngine.setVolume(ttsConfig.volume);
await this.ttsEngine.speak(text);
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Speaking text: ${text}`);
} catch (error) {
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to speak text: ${error}`);
throw error;
}
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/media/VoiceService.ets#L172-L197
|
38b0ac7f8c24e3023ab86b5cfc11a9903e0cff8d
|
github
|
supermanaaaa/HarmonyOS-Next-Knowledge-Base.git
|
a818e59f200ebf4cae00bc634a6c04b9486b8a8f
|
HarmonyOSNextKnowledgeLearning/DevEco Studio/Design and Implementation of Active Image Caching Based on HarmonyOS 5 Ability Image Component/ImageReloadComponent.ets
|
arkts
|
downloadImageToCache
|
下载网络图片到缓存中,返回最终的本地文件路径(带 file:// 前缀)
|
public abstract downloadImageToCache(
urlLink: string,
onStartDownload?: () => void,
onEndDownload?: () => void
): Promise<string>;
|
AST#method_declaration#Left public abstract downloadImageToCache AST#parameter_list#Left ( AST#parameter#Left urlLink : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left onStartDownload ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left onEndDownload ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#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#method_declaration#Right
|
public abstract downloadImageToCache(
urlLink: string,
onStartDownload?: () => void,
onEndDownload?: () => void
): Promise<string>;
|
https://github.com/supermanaaaa/HarmonyOS-Next-Knowledge-Base.git/blob/a818e59f200ebf4cae00bc634a6c04b9486b8a8f/HarmonyOSNextKnowledgeLearning/DevEco Studio/Design and Implementation of Active Image Caching Based on HarmonyOS 5 Ability Image Component/ImageReloadComponent.ets#L93-L97
|
8912d50cc857c380b5b14c3097ea83083549206c
|
github
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/statusbaranimation/src/main/ets/view/StatusBarAnimation.ets
|
arkts
|
articleTitleBuilder
|
搜索框提示字
|
@Builder
articleTitleBuilder() {
Text($r('app.string.status_bar_animation_beautiful_text'))
.fontWeight(FontWeight.Bold)
.fontFamily(Constants.HARMONY_HEI_TI_BOLD_FONT_FAMILY)
.fontSize($r('app.integer.status_bar_animation_beautiful_text_font'))
.width(Constants.FULL_PERCENT)
.height($r('app.integer.status_bar_animation_beautiful_text_height'))
.padding({
left: $r('app.integer.status_bar_animation_beautiful_padding_left'),
top: $r('app.integer.status_bar_animation_beautiful_padding_top')
})
.backgroundColor($r('app.color.status_bar_animation_beautiful_background_color'))
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right articleTitleBuilder AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.status_bar_animation_beautiful_text' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#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 AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . HARMONY_HEI_TI_BOLD_FONT_FAMILY AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.status_bar_animation_beautiful_text_font' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . FULL_PERCENT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.status_bar_animation_beautiful_text_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.status_bar_animation_beautiful_padding_left' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.status_bar_animation_beautiful_padding_top' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.status_bar_animation_beautiful_background_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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
articleTitleBuilder() {
Text($r('app.string.status_bar_animation_beautiful_text'))
.fontWeight(FontWeight.Bold)
.fontFamily(Constants.HARMONY_HEI_TI_BOLD_FONT_FAMILY)
.fontSize($r('app.integer.status_bar_animation_beautiful_text_font'))
.width(Constants.FULL_PERCENT)
.height($r('app.integer.status_bar_animation_beautiful_text_height'))
.padding({
left: $r('app.integer.status_bar_animation_beautiful_padding_left'),
top: $r('app.integer.status_bar_animation_beautiful_padding_top')
})
.backgroundColor($r('app.color.status_bar_animation_beautiful_background_color'))
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/statusbaranimation/src/main/ets/view/StatusBarAnimation.ets#L86-L99
|
da4f71fee20fe077da72c7b5621c445fd31d70d1
|
gitee
|
YShelter/Accouting_ArkTS.git
|
8c663c85f2c11738d4eabf269c23dc1ec84eb013
|
entry/src/main/ets/Viewmodel/HomeViewModel.ets
|
arkts
|
setSelectedShowDate
|
初始化数据 public initData() { let dateStr:string = dateToStr(new Date(this.showDate)); let filteredItems = this.dateArr.filter(item => item.dateStr === dateStr); let selectedDayInfo = filteredItems.length > 0 ? filteredItems[0] : undefined; if (!selectedDayInfo) { AccountingInfoApi.query(dateStr, (resultSet: AccountingInfo[]) => { if (resultSet && resultSet?.length > 0) { this.selectedDayInfo.accountingList = resultSet; this.dayInfo = this.setSelectedDayBalance(resultSet, this.dayInfo); this.selectedDayInfo.dayInfo = this.dayInfo; this.dateArr.push(this.selectedDayInfo); DayInfoApi.updateData(this.dayInfo, () => {}); this.dateArr.push(this.selectedDayInfo); } }); } else { if (selectedDayInfo.accountingList.length > 0 && (selectedDayInfo.dayInfo.expense == 0 && selectedDayInfo.dayInfo.income == 0)) { selectedDayInfo.dayInfo = this.setSelectedDayBalance(selectedDayInfo.accountingList, selectedDayInfo.dayInfo); } else if (selectedDayInfo.accountingList.length == 0 && (selectedDayInfo.dayInfo.expense != 0 || selectedDayInfo.dayInfo.income != 0)) { selectedDayInfo.dayInfo = this.setSelectedDayBalance(selectedDayInfo.accountingList, selectedDayInfo.dayInfo); } this.selectedDayInfo = selectedDayInfo; } } 设置选中的日期
|
public setSelectedShowDate(ShowDateTime: number) {
this.showDate = ShowDateTime;
this.dateTitle = weekDateFormat(this.showDate);
// let selectedDayInfo = this.dateArr.find((item: WeekDateModel) => item.dateStr == dateToStr(new Date(ShowDateTime))) as WeekDateModel;
let filteredItems = this.dateArr.filter(item => item.dateStr === dateToStr(new Date(ShowDateTime)));
let selectedDayInfo = filteredItems.length > 0 ? filteredItems[0] : undefined;
if (selectedDayInfo) {
if (selectedDayInfo?.weekTitle === '') {
selectedDayInfo.weekTitle = this.dateTitle;
selectedDayInfo.date = new Date(ShowDateTime);
}
this.updateSelectedDayInfo(selectedDayInfo);
}
else {
selectedDayInfo = new WeekDateModel(this.dateTitle, dateToStr(new Date(ShowDateTime)), new Date(ShowDateTime));
selectedDayInfo.accountingList = [];
selectedDayInfo.dayInfo = new DayInfo(dateToStr(new Date(ShowDateTime)), 0, 0);
this.dateArr.push(selectedDayInfo);
// 将DateArr按日期排序
this.dateArr.sort((a, b) => a.date.getTime() - b.date.getTime());
this.updateSelectedDayInfo(selectedDayInfo);
}
}
|
AST#method_declaration#Left public setSelectedShowDate AST#parameter_list#Left ( AST#parameter#Left ShowDateTime : 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showDate AST#member_expression#Right = AST#expression#Left ShowDateTime 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 . dateTitle AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left weekDateFormat AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showDate 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 // let selectedDayInfo = this.dateArr.find((item: WeekDateModel) => item.dateStr == dateToStr(new Date(ShowDateTime))) as WeekDateModel; AST#expression_statement#Left AST#expression#Left let AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left filteredItems = 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 . dateArr AST#member_expression#Right AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left item => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . dateStr AST#member_expression#Right AST#expression#Right === AST#expression#Left dateToStr AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left ShowDateTime 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#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left let AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left selectedDayInfo = AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left filteredItems 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#Left AST#subscript_expression#Left AST#expression#Left filteredItems AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right : AST#expression#Left undefined AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left selectedDayInfo AST#expression#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 selectedDayInfo AST#expression#Right ?. weekTitle AST#member_expression#Right AST#expression#Right === AST#expression#Left '' 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 selectedDayInfo AST#expression#Right . weekTitle AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dateTitle AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left selectedDayInfo AST#expression#Right . date AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left ShowDateTime 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . updateSelectedDayInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left selectedDayInfo AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } else { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left selectedDayInfo = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left WeekDateModel AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dateTitle AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left dateToStr AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left ShowDateTime 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#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 ShowDateTime 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left selectedDayInfo AST#expression#Right . accountingList AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left selectedDayInfo AST#expression#Right . dayInfo AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left DayInfo AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left dateToStr AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left ShowDateTime 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#Left 0 AST#expression#Right , AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dateArr AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left selectedDayInfo AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right // 将DateArr按日期排序 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 . dateArr AST#member_expression#Right AST#expression#Right . sort AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left a AST#parameter#Right , AST#parameter#Left b AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 a AST#expression#Right . date AST#member_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 b AST#expression#Right AST#binary_expression#Right AST#expression#Right . date AST#member_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#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 this AST#expression#Right . updateSelectedDayInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left selectedDayInfo AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
public setSelectedShowDate(ShowDateTime: number) {
this.showDate = ShowDateTime;
this.dateTitle = weekDateFormat(this.showDate);
let filteredItems = this.dateArr.filter(item => item.dateStr === dateToStr(new Date(ShowDateTime)));
let selectedDayInfo = filteredItems.length > 0 ? filteredItems[0] : undefined;
if (selectedDayInfo) {
if (selectedDayInfo?.weekTitle === '') {
selectedDayInfo.weekTitle = this.dateTitle;
selectedDayInfo.date = new Date(ShowDateTime);
}
this.updateSelectedDayInfo(selectedDayInfo);
}
else {
selectedDayInfo = new WeekDateModel(this.dateTitle, dateToStr(new Date(ShowDateTime)), new Date(ShowDateTime));
selectedDayInfo.accountingList = [];
selectedDayInfo.dayInfo = new DayInfo(dateToStr(new Date(ShowDateTime)), 0, 0);
this.dateArr.push(selectedDayInfo);
this.dateArr.sort((a, b) => a.date.getTime() - b.date.getTime());
this.updateSelectedDayInfo(selectedDayInfo);
}
}
|
https://github.com/YShelter/Accouting_ArkTS.git/blob/8c663c85f2c11738d4eabf269c23dc1ec84eb013/entry/src/main/ets/Viewmodel/HomeViewModel.ets#L133-L157
|
ffdfcc37815c8a9c397bc583340473bff08e3738
|
github
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
ef_core/src/main/ets/core/base/OutDTO.ets
|
arkts
|
@Author csx
@DateTime 2023/12/29 22:45
@TODO OutDTO 输出对象
@Use 详细使用方法以及文档详见ohpm官网,地址https://ohpm.openharmony.cn/#/cn/detail/@yunkss%2Fef_core
|
export class OutDTO<T> {
//成功失败标识
private success: boolean;
//返回提示信息
private msg: string;
//响应编码
private code: string | number;
//返回单行数据
private dataRow: T;
//返回数据集合
private dataTable: Array<T>;
/**
* 构造函数
* @param success 是否成功标识
* @param msg 提示消息
* @param dataRow 单行数据
* @param dataTable 多行数据集合
*/
constructor(success: boolean, msg: string, dataRow: T, dataTable: Array<T>, code: string | number) {
this.msg = msg;
this.success = success;
this.code = code;
this.dataRow = dataRow;
this.dataTable = dataTable;
}
/**
* 创建空实例
* @returns
*/
static create(): OutDTO<string> {
let outDTO = new OutDTO<string>(true, '', '', [], 200);
return outDTO;
}
/**
* 成功-只包含消息
* @param msg 提示消息
* @returns
*/
static OK(msg: string): OutDTO<string> {
let outDTO = new OutDTO<string>(true, msg, '', [], 200);
return outDTO;
}
/**
* 成功-包含单行数据
* @param msg 提示消息
* @param dataRow 单行数据
* @returns
*/
static OKByDataRow<T>(msg: string, dataRow: T): OutDTO<T> {
let dto = new OutDTO<T>(true, msg, dataRow, [], 200);
return dto;
}
/**
* 成功-包含多行数据
* @param msg 提示消息
* @param dataTable 多行数据
* @param dataRow 单行数据(不传)
* @returns
*/
static OKByDataTable<T>(msg: string, dataTable: Array<T>, dataRow?: T): OutDTO<T> {
if (!dataRow) {
dataRow = Object as T;
}
let dto = new OutDTO<T>(true, msg, dataRow, dataTable, 200);
return dto;
}
/**
* 失败-包含提示消息
* @param msg 提示消息
* @returns
*/
static Error(msg: string): OutDTO<string> {
let dto = new OutDTO<string>(false, msg, '', [], 400);
return dto;
}
/**
* 失败-包含单行数据
* @param msg 提示消息
* @param dataRow 单行数据
* @returns
*/
static ErrorByDataRow<T>(msg: string, dataRow: T): OutDTO<T> {
let dto = new OutDTO<T>(false, msg, dataRow, [], 400);
return dto;
}
public setSuccess(success: boolean) {
this.success = success;
}
public getSuccess(): boolean {
return this.success;
}
public getCode(): string | number {
return this.code;
}
public setCode(code: string | number) {
this.code = code;
}
public getMsg(): string {
return this.msg;
}
public setMsg(msg: string) {
this.msg = msg;
}
public getDataRow(): T {
return this.dataRow;
}
public setDataRow(dataRow: T) {
this.dataRow = dataRow;
}
public getDataTable(): Array<T> {
return this.dataTable;
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class OutDTO AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#class_body#Left { //成功失败标识 AST#property_declaration#Left private success : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right //返回提示信息 AST#property_declaration#Left private msg : 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 code : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left number AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ; AST#property_declaration#Right //返回单行数据 AST#property_declaration#Left private dataRow : AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right //返回数据集合 AST#property_declaration#Left private dataTable : 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 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#property_declaration#Right /**
* 构造函数
* @param success 是否成功标识
* @param msg 提示消息
* @param dataRow 单行数据
* @param dataTable 多行数据集合
*/ AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left success : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left msg : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left dataRow : AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left dataTable : 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 T AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left code : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left number AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#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 . msg AST#member_expression#Right = AST#expression#Left msg 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 . success AST#member_expression#Right = AST#expression#Left success 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 . code AST#member_expression#Right = AST#expression#Left code 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 . dataRow AST#member_expression#Right = AST#expression#Left dataRow 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 . dataTable AST#member_expression#Right = AST#expression#Left dataTable 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 /**
* 创建空实例
* @returns
*/ AST#method_declaration#Left static create AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left OutDTO AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left outDTO = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left OutDTO AST#expression#Right AST#new_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#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#statement#Left AST#return_statement#Left return AST#expression#Left outDTO AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 成功-只包含消息
* @param msg 提示消息
* @returns
*/ AST#method_declaration#Left static OK AST#parameter_list#Left ( AST#parameter#Left msg : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left OutDTO AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left outDTO = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left OutDTO AST#expression#Right AST#new_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right , AST#expression#Left msg AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#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#statement#Left AST#return_statement#Left return AST#expression#Left outDTO AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 成功-包含单行数据
* @param msg 提示消息
* @param dataRow 单行数据
* @returns
*/ AST#method_declaration#Left static OKByDataRow AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left msg : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left dataRow : AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left OutDTO AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left dto = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left OutDTO AST#expression#Right AST#new_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 AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right , AST#expression#Left msg AST#expression#Right , AST#expression#Left dataRow AST#expression#Right , AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#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#statement#Left AST#return_statement#Left return AST#expression#Left dto AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 成功-包含多行数据
* @param msg 提示消息
* @param dataTable 多行数据
* @param dataRow 单行数据(不传)
* @returns
*/ AST#method_declaration#Left static OKByDataTable AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left msg : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left dataTable : 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 T AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left dataRow ? : AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left OutDTO 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#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left dataRow AST#expression#Right AST#unary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left dataRow = AST#expression#Left AST#as_expression#Left AST#expression#Left Object AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#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 let AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left dto = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left OutDTO AST#expression#Right AST#new_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 AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right , AST#expression#Left msg AST#expression#Right , AST#expression#Left dataRow AST#expression#Right , AST#expression#Left dataTable AST#expression#Right , AST#expression#Left 200 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 dto AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* 失败-包含提示消息
* @param msg 提示消息
* @returns
*/ AST#method_declaration#Left static Error AST#parameter_list#Left ( AST#parameter#Left msg : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left OutDTO AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left dto = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left OutDTO AST#expression#Right AST#new_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right , AST#expression#Left msg AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right , AST#expression#Left 400 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 dto AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 失败-包含单行数据
* @param msg 提示消息
* @param dataRow 单行数据
* @returns
*/ AST#method_declaration#Left static ErrorByDataRow AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left msg : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left dataRow : AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left OutDTO AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left dto = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left OutDTO AST#expression#Right AST#new_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 AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right , AST#expression#Left msg AST#expression#Right , AST#expression#Left dataRow AST#expression#Right , AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right , AST#expression#Left 400 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 dto AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left public setSuccess AST#parameter_list#Left ( AST#parameter#Left success : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . success AST#member_expression#Right = AST#expression#Left success AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left public getSuccess AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . success AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left public getCode AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left number AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . code AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left public setCode AST#parameter_list#Left ( AST#parameter#Left code : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left number AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . code AST#member_expression#Right = AST#expression#Left code AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left public getMsg AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . msg AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left public setMsg AST#parameter_list#Left ( AST#parameter#Left msg : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . msg AST#member_expression#Right = AST#expression#Left msg AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left public getDataRow AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataRow AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left public setDataRow AST#parameter_list#Left ( AST#parameter#Left dataRow : AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataRow AST#member_expression#Right = AST#expression#Left dataRow AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left public getDataTable 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 T AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataTable AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class OutDTO<T> {
private success: boolean;
private msg: string;
private code: string | number;
private dataRow: T;
private dataTable: Array<T>;
constructor(success: boolean, msg: string, dataRow: T, dataTable: Array<T>, code: string | number) {
this.msg = msg;
this.success = success;
this.code = code;
this.dataRow = dataRow;
this.dataTable = dataTable;
}
static create(): OutDTO<string> {
let outDTO = new OutDTO<string>(true, '', '', [], 200);
return outDTO;
}
static OK(msg: string): OutDTO<string> {
let outDTO = new OutDTO<string>(true, msg, '', [], 200);
return outDTO;
}
static OKByDataRow<T>(msg: string, dataRow: T): OutDTO<T> {
let dto = new OutDTO<T>(true, msg, dataRow, [], 200);
return dto;
}
static OKByDataTable<T>(msg: string, dataTable: Array<T>, dataRow?: T): OutDTO<T> {
if (!dataRow) {
dataRow = Object as T;
}
let dto = new OutDTO<T>(true, msg, dataRow, dataTable, 200);
return dto;
}
static Error(msg: string): OutDTO<string> {
let dto = new OutDTO<string>(false, msg, '', [], 400);
return dto;
}
static ErrorByDataRow<T>(msg: string, dataRow: T): OutDTO<T> {
let dto = new OutDTO<T>(false, msg, dataRow, [], 400);
return dto;
}
public setSuccess(success: boolean) {
this.success = success;
}
public getSuccess(): boolean {
return this.success;
}
public getCode(): string | number {
return this.code;
}
public setCode(code: string | number) {
this.code = code;
}
public getMsg(): string {
return this.msg;
}
public setMsg(msg: string) {
this.msg = msg;
}
public getDataRow(): T {
return this.dataRow;
}
public setDataRow(dataRow: T) {
this.dataRow = dataRow;
}
public getDataTable(): Array<T> {
return this.dataTable;
}
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_core/src/main/ets/core/base/OutDTO.ets#L23-L156
|
0d94487599e6cd01dc0ecd4f1b53034fc985cf5f
|
gitee
|
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/pageturninganimation/src/main/ets/view/PageTurningAnimation.ets
|
arkts
|
PageTurningAnimationComponent
|
功能描述: 翻页动效是应用开发中常见的动效场景,常见的有书籍翻页,日历翻页等。本例将介绍如何通过ArkUI提供的显示动画接口animateTo实现翻页的效果。
推荐场景: 翻页动效
核心组件:
1. pageTurningAnimate()
实现步骤:
1. 创建文本组件。创建时添加rotate属性,用来控制组件旋转。由于各组件旋转的角度和旋转中心不同,
需要父组件在调用时传入对应的参数,所以为对应变量添加@Prop装饰器,用来控制变量传递。
2. 创建父组件框架。由于文本组件分为上下两层,所以在父组件中采用Stack组件进行层叠布局。同时使用
Divider组件作为书籍两个页面间的分隔线。
3.添加翻页动效。在父组件中定义对应的变量,并在调用子组件时分别传入子组件。自定义pageTurningAnimate
函数,在其中使用animateTo方法添加动画效果,同时控制动画的时长,以及动画过程中各元素状态的改变。
在aboutToAppear方法中,使用setInterval方法重复调用pageTurningAnimate函数,以实现连续翻页动效。
|
@Component
export struct PageTurningAnimationComponent {
// 父组件变量设置,使用@State做状态管理
@State originalAngle: number = 0; // 初始角度
@State rotateAngleTextA: number = 0; // Text组件A的旋转角度
@State rotateAngleTextB: number = 0; // Text组件B的旋转角度
@State pageNumTextA: number = 0; // Text组件A的页面编号,用于刷新翻页动画结束时的页面编号
@State animatePageNumTextB: number = 1; // Text组件B的页面编号,用于显示翻页动画的页面编号
@State pageNumTextC: number = 0; // Text组件C的页面编号,用于占位不显示,在Text组件A的下层
@State nextPageNumTextD: number = 0; // Text组件D的页面编号,用于刷新下一个翻页的页面编号
@State leftX: string = '0%'; // 旋转中心点参数x,表示水平方向上旋转起始位置。本例中指定y轴作为旋转轴,所以这里设置'0%'表示旋转动效组件的左侧边缘位置作为旋转轴的水平起始点位置。
@State leftY: string = '0%'; // 旋转中心点参数y,表示垂直方向上旋转起始位置。
@State centerX: string = '50%'; // 旋转中心点参数x。本例中设置'50%'表示以组件的纵向中线为轴旋转。
@State centerY: string = '50%'; // 旋转中心点参数y。
// 在UI显示前,传入各项变量的具体值
aboutToAppear(): void {
// 通过setInterval函数每秒调用一次动画效果,实现连续翻页
setInterval(() => {
this.pageTurningAnimate();
}, 1000) // 函数调用周期要大于每次动画持续的时长
}
// 通过animateTo方法为组件添加动效,动效时长要小于setInterval函数调用周期
private pageTurningAnimate() {
// TODO: 知识点: 使用animateTo方法添加动画效果,同时控制动画的时长,以及动画过程中各元素状态的改变。
animateTo(
{
duration: 700, onFinish: () => {
// 动画结束时,Text组件A显示的页面编号和B显示的页面编号相等
this.pageNumTextA = this.animatePageNumTextB;
// 动画结束时,Text组件A以中心线为轴旋转180度,用于显示左侧翻页动画结束时的页面编号
this.rotateAngleTextA = 180;
// 动画结束时,Text组件B的旋转角度重置为0度
this.rotateAngleTextB = 0;
// 动画结束时,Text组件B显示的页面编号加1
this.animatePageNumTextB = (this.animatePageNumTextB + 1) % 8;
}
},
() => {
// 动画开始,Text组件B的旋转角度设置为180度
this.rotateAngleTextB = 180;
//动画开始,Text组件D的页面编号加1,用于刷新显示下一个翻页的页面编号
this.nextPageNumTextD = this.animatePageNumTextB + 1;
})
}
build() {
// TODO: 知识点: 创建父组件框架。由于文本组件分为上下两层,所以在父组件中采用Stack组件进行层叠布局。同时使用Divider组件作为书籍两个页面间的分隔线。
Stack() {
// 下层Row
Row() {
// Text组件C,用于占位不显示,在Text组件A的下层
BookPage({
pageNum: this.pageNumTextC,
rotateAngle: this.originalAngle,
positionX: this.leftX,
positionY: this.leftY
}).id('bookPageC')
// Text组件D,用于刷新下一个翻页的页面编号
BookPage({
pageNum: this.nextPageNumTextD,
rotateAngle: this.originalAngle,
positionX: this.leftX,
positionY: this.leftY
}).id('bookPageD')
}
// 上层Row
Row() {
// Text组件A的页面编号,用于刷新翻页动画结束时的页面编号
BookPage({
pageNum: this.pageNumTextA,
rotateAngle: this.rotateAngleTextA,
positionX: this.centerX,
positionY: this.centerY
}).id('bookPageA')
// Text组件B的页面编号,用于显示翻页动画的页面编号
BookPage({
pageNum: this.animatePageNumTextB,
rotateAngle: this.rotateAngleTextB,
positionX: this.leftX,
positionY: this.leftY
}).id('bookPageB')
}
// 添加两个页面间的分隔线
Divider()
.strokeWidth(5)
.color(Color.White)
.height($r('app.string.page_turning_animation_divider_height'))
.vertical(true)
}
.width($r('app.string.page_turning_animation_stack_width'))
.height($r('app.string.page_turning_animation_stack_height'))
.backgroundColor($r('app.color.page_turning_animation_stack_background_color'))
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct PageTurningAnimationComponent AST#component_body#Left { // 父组件变量设置,使用@State做状态管理 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right originalAngle : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right // 初始角度 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right rotateAngleTextA : 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 // Text组件A的旋转角度 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right rotateAngleTextB : 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 // Text组件B的旋转角度 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right pageNumTextA : 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 // Text组件A的页面编号,用于刷新翻页动画结束时的页面编号 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right animatePageNumTextB : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1 AST#expression#Right ; AST#property_declaration#Right // Text组件B的页面编号,用于显示翻页动画的页面编号 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right pageNumTextC : 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 // Text组件C的页面编号,用于占位不显示,在Text组件A的下层 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right nextPageNumTextD : 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 // Text组件D的页面编号,用于刷新下一个翻页的页面编号 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right leftX : 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 // 旋转中心点参数x,表示水平方向上旋转起始位置。本例中指定y轴作为旋转轴,所以这里设置'0%'表示旋转动效组件的左侧边缘位置作为旋转轴的水平起始点位置。 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right leftY : 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 // 旋转中心点参数y,表示垂直方向上旋转起始位置。 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right centerX : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '50%' AST#expression#Right ; AST#property_declaration#Right // 旋转中心点参数x。本例中设置'50%'表示以组件的纵向中线为轴旋转。 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right centerY : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '50%' AST#expression#Right ; AST#property_declaration#Right // 旋转中心点参数y。 // 在UI显示前,传入各项变量的具体值 AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { // 通过setInterval函数每秒调用一次动画效果,实现连续翻页 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left setInterval ( 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 . pageTurningAnimate 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#expression#Left 1000 AST#expression#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 函数调用周期要大于每次动画持续的时长 } AST#builder_function_body#Right AST#method_declaration#Right // 通过animateTo方法为组件添加动效,动效时长要小于setInterval函数调用周期 AST#method_declaration#Left private pageTurningAnimate AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { // TODO: 知识点: 使用animateTo方法添加动画效果,同时控制动画的时长,以及动画过程中各元素状态的改变。 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left animateTo ( AST#component_parameters#Left { AST#component_parameter#Left duration : AST#expression#Left 700 AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onFinish : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { // 动画结束时,Text组件A显示的页面编号和B显示的页面编号相等 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 . pageNumTextA AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . animatePageNumTextB AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 动画结束时,Text组件A以中心线为轴旋转180度,用于显示左侧翻页动画结束时的页面编号 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 . rotateAngleTextA AST#member_expression#Right = AST#expression#Left 180 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 动画结束时,Text组件B的旋转角度重置为0度 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 . rotateAngleTextB 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 // 动画结束时,Text组件B显示的页面编号加1 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 . animatePageNumTextB AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . animatePageNumTextB AST#member_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right % AST#expression#Left 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#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right AST#ERROR#Left , ( AST#ERROR#Right ) AST#ERROR#Left => AST#ERROR#Right AST#container_content_body#Left { // 动画开始,Text组件B的旋转角度设置为180度 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rotateAngleTextB AST#member_expression#Right = AST#expression#Left 180 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right //动画开始,Text组件D的页面编号加1,用于刷新显示下一个翻页的页面编号 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . nextPageNumTextD AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . animatePageNumTextB AST#member_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ) AST#ERROR#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { // TODO: 知识点: 创建父组件框架。由于文本组件分为上下两层,所以在父组件中采用Stack组件进行层叠布局。同时使用Divider组件作为书籍两个页面间的分隔线。 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Stack ( ) AST#container_content_body#Left { // 下层Row AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { // Text组件C,用于占位不显示,在Text组件A的下层 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left BookPage ( AST#component_parameters#Left { AST#component_parameter#Left pageNum : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . pageNumTextC AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left rotateAngle : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . originalAngle AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left positionX : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftX AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left positionY : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftY AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . id ( AST#expression#Left 'bookPageC' AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // Text组件D,用于刷新下一个翻页的页面编号 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left BookPage ( AST#component_parameters#Left { AST#component_parameter#Left pageNum : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . nextPageNumTextD AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left rotateAngle : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . originalAngle AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left positionX : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftX AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left positionY : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftY AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . id ( AST#expression#Left 'bookPageD' AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 上层Row AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { // Text组件A的页面编号,用于刷新翻页动画结束时的页面编号 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left BookPage ( AST#component_parameters#Left { AST#component_parameter#Left pageNum : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . pageNumTextA AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left rotateAngle : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rotateAngleTextA AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left positionX : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . centerX AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left positionY : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . centerY AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . id ( AST#expression#Left 'bookPageA' AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // Text组件B的页面编号,用于显示翻页动画的页面编号 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left BookPage ( AST#component_parameters#Left { AST#component_parameter#Left pageNum : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . animatePageNumTextB AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left rotateAngle : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rotateAngleTextB AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left positionX : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftX AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left positionY : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftY AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . id ( AST#expression#Left 'bookPageB' AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 添加两个页面间的分隔线 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Divider ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . strokeWidth ( AST#expression#Left 5 AST#expression#Right ) AST#modifier_chain_expression#Left . color ( 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 . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.page_turning_animation_divider_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . vertical ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#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.page_turning_animation_stack_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.page_turning_animation_stack_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.page_turning_animation_stack_background_color' 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#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct PageTurningAnimationComponent {
@State originalAngle: number = 0;
@State rotateAngleTextA: number = 0;
@State rotateAngleTextB: number = 0;
@State pageNumTextA: number = 0;
@State animatePageNumTextB: number = 1;
@State pageNumTextC: number = 0;
@State nextPageNumTextD: number = 0;
@State leftX: string = '0%';
@State leftY: string = '0%';
@State centerX: string = '50%';
@State centerY: string = '50%';
aboutToAppear(): void {
setInterval(() => {
this.pageTurningAnimate();
}, 1000)
}
private pageTurningAnimate() {
animateTo(
{
duration: 700, onFinish: () => {
this.pageNumTextA = this.animatePageNumTextB;
this.rotateAngleTextA = 180;
this.rotateAngleTextB = 0;
this.animatePageNumTextB = (this.animatePageNumTextB + 1) % 8;
}
},
() => {
this.rotateAngleTextB = 180;
this.nextPageNumTextD = this.animatePageNumTextB + 1;
})
}
build() {
Stack() {
Row() {
BookPage({
pageNum: this.pageNumTextC,
rotateAngle: this.originalAngle,
positionX: this.leftX,
positionY: this.leftY
}).id('bookPageC')
BookPage({
pageNum: this.nextPageNumTextD,
rotateAngle: this.originalAngle,
positionX: this.leftX,
positionY: this.leftY
}).id('bookPageD')
}
Row() {
BookPage({
pageNum: this.pageNumTextA,
rotateAngle: this.rotateAngleTextA,
positionX: this.centerX,
positionY: this.centerY
}).id('bookPageA')
BookPage({
pageNum: this.animatePageNumTextB,
rotateAngle: this.rotateAngleTextB,
positionX: this.leftX,
positionY: this.leftY
}).id('bookPageB')
}
Divider()
.strokeWidth(5)
.color(Color.White)
.height($r('app.string.page_turning_animation_divider_height'))
.vertical(true)
}
.width($r('app.string.page_turning_animation_stack_width'))
.height($r('app.string.page_turning_animation_stack_height'))
.backgroundColor($r('app.color.page_turning_animation_stack_background_color'))
}
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/pageturninganimation/src/main/ets/view/PageTurningAnimation.ets#L66-L163
|
e7377d5a569af4694af98a1aef9562cc8b3d24b7
|
gitee
|
Joker-x-dev/HarmonyKit.git
|
f97197ce157df7f303244fba42e34918306dfb08
|
feature/user/src/main/ets/viewmodel/ProfileViewModel.ets
|
arkts
|
getDisplayNickName
|
获取展示昵称
@returns {ResourceStr} 展示昵称
|
getDisplayNickName(): ResourceStr {
const nickName: string = this.userState.getUserInfo().nickName?.trim() ?? "";
return nickName.length > 0 ? nickName : $r("app.string.user_profile_nickname_empty");
}
/**
* 获取展示用户 ID
* @returns {ResourceStr} 展示用户 ID
*/
getDisplayUserId(): ResourceStr {
const userId: number = this.userState.getUserInfo().id ?? 0;
return userId > 0 ? `${userId}` : $r("app.string.user_profile_id_empty");
}
|
AST#method_declaration#Left getDisplayNickName AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left nickName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . userState AST#member_expression#Right AST#expression#Right . getUserInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . nickName AST#member_expression#Right AST#expression#Right ?. trim AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ?? AST#expression#Left "" AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#ERROR#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left nickName 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 ? nickName AST#ERROR#Left : AST#ERROR#Left $r ( "app.string.user_profile_nickname_empty" ) ; } /**
* 获取展示用户 ID
* @returns {ResourceStr} 展示用户 ID
*/ getDisplayUserId AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right { AST#ERROR#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left userId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 . userState AST#member_expression#Right AST#expression#Right . getUserInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right ?? AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left userId AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left userId AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.user_profile_id_empty" AST#expression#Right ) AST#resource_expression#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
|
getDisplayNickName(): ResourceStr {
const nickName: string = this.userState.getUserInfo().nickName?.trim() ?? "";
return nickName.length > 0 ? nickName : $r("app.string.user_profile_nickname_empty");
}
getDisplayUserId(): ResourceStr {
const userId: number = this.userState.getUserInfo().id ?? 0;
return userId > 0 ? `${userId}` : $r("app.string.user_profile_id_empty");
}
|
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/feature/user/src/main/ets/viewmodel/ProfileViewModel.ets#L20-L32
|
8f3c5a6a0444bbd0bde77bfaa37fb1003fac6639
|
github
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/pages/Index.ets
|
arkts
|
createColorSystem
|
创建颜色系统(支持深色模式)
|
private createColorSystem(primaryColor: string, isDark: boolean): ColorSystem {
if (isDark) {
// 深色模式颜色系统
return {
// 主品牌色
primary: primaryColor,
primaryHover: this.lightenColor(primaryColor, 0.2),
primaryLight: this.darkenColor(primaryColor, 0.7),
// 红色系 - 生日庆祝
redPrimary: '#FF6B6B',
redLight: '#4A1F1F',
// 绿色系 - 成功状态
greenPrimary: '#51CF66',
greenLight: '#1F4A1F',
// 橙色系 - 生日提醒
orangePrimary: '#FFB84D',
orangeLight: '#4A3A1F',
// 紫色系 - 代办事项
purplePrimary: '#A78BFA',
purpleLight: '#3D2D4A',
// 蓝色系 - 今日待办
bluePrimary: '#60A5FA',
blueLight: '#1F2937',
// 红色系 - 危险状态
danger: '#FF6B6B',
dangerLight: '#4A1F1F',
// 深色模式背景色系
whitePrimary: '#1A1A1A',
whiteSecondary: '#2D2D2D',
whiteTertiary: '#404040',
// 深色模式灰色系
gray50: '#404040',
gray100: '#4D4D4D',
gray200: '#5A5A5A',
gray300: '#666666',
gray400: '#737373',
gray500: '#808080',
gray600: '#8C8C8C',
gray700: '#999999',
gray800: '#A6A6A6',
gray900: '#B3B3B3',
// 深色模式文本色
textPrimary: '#FFFFFF',
textSecondary: '#CCCCCC',
textTertiary: '#999999'
};
} else {
// 浅色模式颜色系统
return {
// 主品牌色
primary: primaryColor,
primaryHover: this.darkenColor(primaryColor, 0.1),
primaryLight: this.lightenColor(primaryColor, 0.8),
// 红色系 - 生日庆祝
redPrimary: '#EF4444',
redLight: '#FEE2E2',
// 绿色系 - 成功状态
greenPrimary: '#10B981',
greenLight: '#D1FAE5',
// 橙色系 - 生日提醒
orangePrimary: '#F59E0B',
orangeLight: '#FEF3C7',
// 紫色系 - 代办事项
purplePrimary: '#8B5CF6',
purpleLight: '#EDE9FE',
// 蓝色系 - 今日待办
bluePrimary: '#3B82F6',
blueLight: '#DBEAFE',
// 红色系 - 危险状态
danger: '#FF6B6B',
dangerLight: '#FFE3E3',
// 浅色模式背景色系
whitePrimary: '#FFFFFF',
whiteSecondary: '#F9FAFB',
whiteTertiary: '#F3F4F6',
// 浅色模式灰色系
gray50: '#F9FAFB',
gray100: '#F3F4F6',
gray200: '#E5E7EB',
gray300: '#D1D5DB',
gray400: '#9CA3AF',
gray500: '#6B7280',
gray600: '#4B5563',
gray700: '#374151',
gray800: '#1F2937',
gray900: '#111827',
// 浅色模式文本色
textPrimary: '#1F2937',
textSecondary: '#6B7280',
textTertiary: '#9CA3AF'
};
}
}
|
AST#method_declaration#Left private createColorSystem AST#parameter_list#Left ( AST#parameter#Left primaryColor : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left isDark : 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 ColorSystem AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left isDark AST#expression#Right ) AST#block_statement#Left { // 深色模式颜色系统 AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { // 主品牌色 AST#property_assignment#Left AST#property_name#Left primary AST#property_name#Right : AST#expression#Left primaryColor AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left primaryHover AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . lightenColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left primaryColor AST#expression#Right , AST#expression#Left 0.2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left primaryLight AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . darkenColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left primaryColor AST#expression#Right , AST#expression#Left 0.7 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , // 红色系 - 生日庆祝 AST#property_assignment#Left AST#property_name#Left redPrimary AST#property_name#Right : AST#expression#Left '#FF6B6B' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left redLight AST#property_name#Right : AST#expression#Left '#4A1F1F' AST#expression#Right AST#property_assignment#Right , // 绿色系 - 成功状态 AST#property_assignment#Left AST#property_name#Left greenPrimary AST#property_name#Right : AST#expression#Left '#51CF66' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left greenLight AST#property_name#Right : AST#expression#Left '#1F4A1F' AST#expression#Right AST#property_assignment#Right , // 橙色系 - 生日提醒 AST#property_assignment#Left AST#property_name#Left orangePrimary AST#property_name#Right : AST#expression#Left '#FFB84D' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left orangeLight AST#property_name#Right : AST#expression#Left '#4A3A1F' AST#expression#Right AST#property_assignment#Right , // 紫色系 - 代办事项 AST#property_assignment#Left AST#property_name#Left purplePrimary AST#property_name#Right : AST#expression#Left '#A78BFA' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left purpleLight AST#property_name#Right : AST#expression#Left '#3D2D4A' AST#expression#Right AST#property_assignment#Right , // 蓝色系 - 今日待办 AST#property_assignment#Left AST#property_name#Left bluePrimary AST#property_name#Right : AST#expression#Left '#60A5FA' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left blueLight AST#property_name#Right : AST#expression#Left '#1F2937' AST#expression#Right AST#property_assignment#Right , // 红色系 - 危险状态 AST#property_assignment#Left AST#property_name#Left danger AST#property_name#Right : AST#expression#Left '#FF6B6B' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left dangerLight AST#property_name#Right : AST#expression#Left '#4A1F1F' AST#expression#Right AST#property_assignment#Right , // 深色模式背景色系 AST#property_assignment#Left AST#property_name#Left whitePrimary AST#property_name#Right : AST#expression#Left '#1A1A1A' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left whiteSecondary AST#property_name#Right : AST#expression#Left '#2D2D2D' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left whiteTertiary AST#property_name#Right : AST#expression#Left '#404040' AST#expression#Right AST#property_assignment#Right , // 深色模式灰色系 AST#property_assignment#Left AST#property_name#Left gray50 AST#property_name#Right : AST#expression#Left '#404040' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left gray100 AST#property_name#Right : AST#expression#Left '#4D4D4D' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left gray200 AST#property_name#Right : AST#expression#Left '#5A5A5A' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left gray300 AST#property_name#Right : AST#expression#Left '#666666' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left gray400 AST#property_name#Right : AST#expression#Left '#737373' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left gray500 AST#property_name#Right : AST#expression#Left '#808080' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left gray600 AST#property_name#Right : AST#expression#Left '#8C8C8C' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left gray700 AST#property_name#Right : AST#expression#Left '#999999' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left gray800 AST#property_name#Right : AST#expression#Left '#A6A6A6' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left gray900 AST#property_name#Right : AST#expression#Left '#B3B3B3' AST#expression#Right AST#property_assignment#Right , // 深色模式文本色 AST#property_assignment#Left AST#property_name#Left textPrimary AST#property_name#Right : AST#expression#Left '#FFFFFF' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left textSecondary AST#property_name#Right : AST#expression#Left '#CCCCCC' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left textTertiary AST#property_name#Right : AST#expression#Left '#999999' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { // 浅色模式颜色系统 AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { // 主品牌色 AST#property_assignment#Left AST#property_name#Left primary AST#property_name#Right : AST#expression#Left primaryColor AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left primaryHover AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . darkenColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left primaryColor AST#expression#Right , AST#expression#Left 0.1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left primaryLight AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . lightenColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left primaryColor AST#expression#Right , AST#expression#Left 0.8 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , // 红色系 - 生日庆祝 AST#property_assignment#Left AST#property_name#Left redPrimary AST#property_name#Right : AST#expression#Left '#EF4444' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left redLight AST#property_name#Right : AST#expression#Left '#FEE2E2' AST#expression#Right AST#property_assignment#Right , // 绿色系 - 成功状态 AST#property_assignment#Left AST#property_name#Left greenPrimary AST#property_name#Right : AST#expression#Left '#10B981' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left greenLight AST#property_name#Right : AST#expression#Left '#D1FAE5' AST#expression#Right AST#property_assignment#Right , // 橙色系 - 生日提醒 AST#property_assignment#Left AST#property_name#Left orangePrimary AST#property_name#Right : AST#expression#Left '#F59E0B' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left orangeLight AST#property_name#Right : AST#expression#Left '#FEF3C7' AST#expression#Right AST#property_assignment#Right , // 紫色系 - 代办事项 AST#property_assignment#Left AST#property_name#Left purplePrimary AST#property_name#Right : AST#expression#Left '#8B5CF6' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left purpleLight AST#property_name#Right : AST#expression#Left '#EDE9FE' AST#expression#Right AST#property_assignment#Right , // 蓝色系 - 今日待办 AST#property_assignment#Left AST#property_name#Left bluePrimary AST#property_name#Right : AST#expression#Left '#3B82F6' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left blueLight AST#property_name#Right : AST#expression#Left '#DBEAFE' AST#expression#Right AST#property_assignment#Right , // 红色系 - 危险状态 AST#property_assignment#Left AST#property_name#Left danger AST#property_name#Right : AST#expression#Left '#FF6B6B' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left dangerLight AST#property_name#Right : AST#expression#Left '#FFE3E3' AST#expression#Right AST#property_assignment#Right , // 浅色模式背景色系 AST#property_assignment#Left AST#property_name#Left whitePrimary AST#property_name#Right : AST#expression#Left '#FFFFFF' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left whiteSecondary AST#property_name#Right : AST#expression#Left '#F9FAFB' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left whiteTertiary AST#property_name#Right : AST#expression#Left '#F3F4F6' AST#expression#Right AST#property_assignment#Right , // 浅色模式灰色系 AST#property_assignment#Left AST#property_name#Left gray50 AST#property_name#Right : AST#expression#Left '#F9FAFB' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left gray100 AST#property_name#Right : AST#expression#Left '#F3F4F6' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left gray200 AST#property_name#Right : AST#expression#Left '#E5E7EB' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left gray300 AST#property_name#Right : AST#expression#Left '#D1D5DB' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left gray400 AST#property_name#Right : AST#expression#Left '#9CA3AF' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left gray500 AST#property_name#Right : AST#expression#Left '#6B7280' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left gray600 AST#property_name#Right : AST#expression#Left '#4B5563' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left gray700 AST#property_name#Right : AST#expression#Left '#374151' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left gray800 AST#property_name#Right : AST#expression#Left '#1F2937' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left gray900 AST#property_name#Right : AST#expression#Left '#111827' AST#expression#Right AST#property_assignment#Right , // 浅色模式文本色 AST#property_assignment#Left AST#property_name#Left textPrimary AST#property_name#Right : AST#expression#Left '#1F2937' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left textSecondary AST#property_name#Right : AST#expression#Left '#6B7280' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left textTertiary AST#property_name#Right : AST#expression#Left '#9CA3AF' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private createColorSystem(primaryColor: string, isDark: boolean): ColorSystem {
if (isDark) {
return {
primary: primaryColor,
primaryHover: this.lightenColor(primaryColor, 0.2),
primaryLight: this.darkenColor(primaryColor, 0.7),
redPrimary: '#FF6B6B',
redLight: '#4A1F1F',
greenPrimary: '#51CF66',
greenLight: '#1F4A1F',
orangePrimary: '#FFB84D',
orangeLight: '#4A3A1F',
purplePrimary: '#A78BFA',
purpleLight: '#3D2D4A',
bluePrimary: '#60A5FA',
blueLight: '#1F2937',
danger: '#FF6B6B',
dangerLight: '#4A1F1F',
whitePrimary: '#1A1A1A',
whiteSecondary: '#2D2D2D',
whiteTertiary: '#404040',
gray50: '#404040',
gray100: '#4D4D4D',
gray200: '#5A5A5A',
gray300: '#666666',
gray400: '#737373',
gray500: '#808080',
gray600: '#8C8C8C',
gray700: '#999999',
gray800: '#A6A6A6',
gray900: '#B3B3B3',
textPrimary: '#FFFFFF',
textSecondary: '#CCCCCC',
textTertiary: '#999999'
};
} else {
return {
primary: primaryColor,
primaryHover: this.darkenColor(primaryColor, 0.1),
primaryLight: this.lightenColor(primaryColor, 0.8),
redPrimary: '#EF4444',
redLight: '#FEE2E2',
greenPrimary: '#10B981',
greenLight: '#D1FAE5',
orangePrimary: '#F59E0B',
orangeLight: '#FEF3C7',
purplePrimary: '#8B5CF6',
purpleLight: '#EDE9FE',
bluePrimary: '#3B82F6',
blueLight: '#DBEAFE',
danger: '#FF6B6B',
dangerLight: '#FFE3E3',
whitePrimary: '#FFFFFF',
whiteSecondary: '#F9FAFB',
whiteTertiary: '#F3F4F6',
gray50: '#F9FAFB',
gray100: '#F3F4F6',
gray200: '#E5E7EB',
gray300: '#D1D5DB',
gray400: '#9CA3AF',
gray500: '#6B7280',
gray600: '#4B5563',
gray700: '#374151',
gray800: '#1F2937',
gray900: '#111827',
textPrimary: '#1F2937',
textSecondary: '#6B7280',
textTertiary: '#9CA3AF'
};
}
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/Index.ets#L5884-L5994
|
ec268d992e5cd0bac2b1f0783f8bff466adeb56e
|
github
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/videotrimmer/src/main/ets/constants/Constants.ets
|
arkts
|
通用常量
|
export default class CommonConstants {
/**
* 首页图片宽度
*/
static readonly firstImageWidth = 762;
/**
* 首页图片高度
*/
static readonly firstImageHeight = 431;
/**
* 首页图片从视频中截取的开始时间
*/
static readonly FIRST_IMAGE_START_TIME = 1000;
/**
* 首页图片从视频中截取的结束时间
*/
static readonly FIRST_IMAGE_END_TIME = 12000;
/**
* 进度最大值
*/
static readonly PROGRESS_MAX = 100;
/**
* 重试间隔
*/
static readonly UPLOAD_INTERVAL_TIME = 1000;
/**
* 一秒钟毫秒数
*/
static readonly MS_ONE_SECOND = 1000;
/**
* 一秒钟微秒数
*/
static readonly US_ONE_SECOND = 1000000;
/**
* 压缩分辨率
*/
static readonly SCALE_NUM = 100;
}
|
AST#export_declaration#Left export default AST#class_declaration#Left class CommonConstants AST#class_body#Left { /**
* 首页图片宽度
*/ AST#property_declaration#Left static readonly firstImageWidth = AST#expression#Left 762 AST#expression#Right ; AST#property_declaration#Right /**
* 首页图片高度
*/ AST#property_declaration#Left static readonly firstImageHeight = AST#expression#Left 431 AST#expression#Right ; AST#property_declaration#Right /**
* 首页图片从视频中截取的开始时间
*/ AST#property_declaration#Left static readonly FIRST_IMAGE_START_TIME = AST#expression#Left 1000 AST#expression#Right ; AST#property_declaration#Right /**
* 首页图片从视频中截取的结束时间
*/ AST#property_declaration#Left static readonly FIRST_IMAGE_END_TIME = AST#expression#Left 12000 AST#expression#Right ; AST#property_declaration#Right /**
* 进度最大值
*/ AST#property_declaration#Left static readonly PROGRESS_MAX = AST#expression#Left 100 AST#expression#Right ; AST#property_declaration#Right /**
* 重试间隔
*/ AST#property_declaration#Left static readonly UPLOAD_INTERVAL_TIME = AST#expression#Left 1000 AST#expression#Right ; AST#property_declaration#Right /**
* 一秒钟毫秒数
*/ AST#property_declaration#Left static readonly MS_ONE_SECOND = AST#expression#Left 1000 AST#expression#Right ; AST#property_declaration#Right /**
* 一秒钟微秒数
*/ AST#property_declaration#Left static readonly US_ONE_SECOND = AST#expression#Left 1000000 AST#expression#Right ; AST#property_declaration#Right /**
* 压缩分辨率
*/ AST#property_declaration#Left static readonly SCALE_NUM = AST#expression#Left 100 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 firstImageWidth = 762;
static readonly firstImageHeight = 431;
static readonly FIRST_IMAGE_START_TIME = 1000;
static readonly FIRST_IMAGE_END_TIME = 12000;
static readonly PROGRESS_MAX = 100;
static readonly UPLOAD_INTERVAL_TIME = 1000;
static readonly MS_ONE_SECOND = 1000;
static readonly US_ONE_SECOND = 1000000;
static readonly SCALE_NUM = 100;
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/videotrimmer/src/main/ets/constants/Constants.ets#L19-L56
|
6b10a6066e62ededb77a4f477d5afac1754d9295
|
gitee
|
|
jxdiaodeyi/YX_Sports.git
|
af5346bd3d5003c33c306ff77b4b5e9184219893
|
YX_Sports/oh_modules/.ohpm/@pura+harmony-utils@1.3.6/oh_modules/@pura/harmony-utils/src/main/ets/crypto/SM4.ets
|
arkts
|
encryptGCMSegment
|
加密(GCM模式)分段,异步
@param dataBlob 加密或者解密的数据。dataBlob不能为null。
@param key 指定加密或解密的密钥。
@param gcmParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。
@param len 自定义的数据拆分长度。
@returns
|
static async encryptGCMSegment(dataBlob: cryptoFramework.DataBlob, key: cryptoFramework.Key,
gcmParams: cryptoFramework.GcmParamsSpec, len: number = 128): Promise<cryptoFramework.DataBlob> {
let cipher = cryptoFramework.createCipher('SM4_128|GCM|PKCS7');
await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, key, gcmParams);
let encryptData = new Uint8Array();
for (let i = 0; i < dataBlob.data.length; i += len) {
let updateData = dataBlob.data.subarray(i, i + len);
let updateDataBlob: cryptoFramework.DataBlob = { data: updateData };
let updateOutput = await cipher.update(updateDataBlob); //分段update
let mergeTData = new Uint8Array(encryptData.length + updateOutput.data.length);
mergeTData.set(encryptData);
mergeTData.set(updateOutput.data, encryptData.length);
encryptData = mergeTData;
}
gcmParams.authTag = await cipher.doFinal(null);
let encryptBlob: cryptoFramework.DataBlob = { data: encryptData };
return encryptBlob;
}
|
AST#method_declaration#Left static async encryptGCMSegment AST#parameter_list#Left ( AST#parameter#Left dataBlob : 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 key : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . Key AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left gcmParams : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . GcmParamsSpec AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left len : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 128 AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left cipher = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createCipher AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'SM4_128|GCM|PKCS7' 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 cipher AST#expression#Right AST#await_expression#Right AST#expression#Right . init AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . CryptoMode AST#member_expression#Right AST#expression#Right . ENCRYPT_MODE AST#member_expression#Right AST#expression#Right , AST#expression#Left key AST#expression#Right , AST#expression#Left gcmParams AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left encryptData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Uint8Array 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#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left dataBlob AST#expression#Right AST#binary_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#assignment_expression#Left i += AST#expression#Left len AST#expression#Right AST#assignment_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left updateData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dataBlob AST#expression#Right . data AST#member_expression#Right AST#expression#Right . subarray AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left i AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right + AST#expression#Left len AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left updateDataBlob : 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#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left data AST#property_name#Right : AST#expression#Left updateData AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left updateOutput = 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 cipher AST#expression#Right AST#await_expression#Right AST#expression#Right . update AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left updateDataBlob 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 //分段update AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left mergeTData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Uint8Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left encryptData AST#expression#Right . length AST#member_expression#Right AST#expression#Right + AST#expression#Left updateOutput AST#expression#Right AST#binary_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 mergeTData AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left encryptData 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 mergeTData AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left updateOutput AST#expression#Right . data AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left encryptData AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left encryptData = AST#expression#Left mergeTData AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left gcmParams AST#expression#Right . authTag 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 cipher AST#expression#Right AST#await_expression#Right AST#expression#Right . doFinal AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left encryptBlob : 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#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left data AST#property_name#Right : AST#expression#Left encryptData 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 encryptBlob AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static async encryptGCMSegment(dataBlob: cryptoFramework.DataBlob, key: cryptoFramework.Key,
gcmParams: cryptoFramework.GcmParamsSpec, len: number = 128): Promise<cryptoFramework.DataBlob> {
let cipher = cryptoFramework.createCipher('SM4_128|GCM|PKCS7');
await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, key, gcmParams);
let encryptData = new Uint8Array();
for (let i = 0; i < dataBlob.data.length; i += len) {
let updateData = dataBlob.data.subarray(i, i + len);
let updateDataBlob: cryptoFramework.DataBlob = { data: updateData };
let updateOutput = await cipher.update(updateDataBlob);
let mergeTData = new Uint8Array(encryptData.length + updateOutput.data.length);
mergeTData.set(encryptData);
mergeTData.set(updateOutput.data, encryptData.length);
encryptData = mergeTData;
}
gcmParams.authTag = await cipher.doFinal(null);
let encryptBlob: cryptoFramework.DataBlob = { data: encryptData };
return encryptBlob;
}
|
https://github.com/jxdiaodeyi/YX_Sports.git/blob/af5346bd3d5003c33c306ff77b4b5e9184219893/YX_Sports/oh_modules/.ohpm/@pura+harmony-utils@1.3.6/oh_modules/@pura/harmony-utils/src/main/ets/crypto/SM4.ets#L253-L270
|
8831964207d26297fa187104534710fb30fbc0f6
|
github
|
open9527/OpenHarmony
|
fdea69ed722d426bf04e817ec05bff4002e81a4e
|
libs/core/src/main/ets/utils/CharUtils.ets
|
arkts
|
字符工具类
|
export class CharUtils {
private constructor() {}
/**
* 是否空白符 空白符包括空格、制表符、全角空格和不间断空格
* @param c
* @returns
*/
static isBlankChar(c: number): boolean {
return CharUtils.isWhitespace(c)
|| CharUtils.isSpaceChar(c)
|| c == 0xFEFF
|| c == 0x202A
|| c == 0x0000;
}
/**
* 检查字符是否位于ASCII范围内(0~127)
* @param ch 被检查的字符
* @returns `true`表示为ASCII字符,否则为`false`
*/
static isAscii(ch: string): boolean {
// 确保输入的是单个字符
if (ch.length !== 1) throw new Error("Input must be a single character");
return ch.charCodeAt(0) < 128;
}
/**
* 判断是否为emoji表情符
* @param c 字符
* @returns 是否为emoji
*/
static isEmoji(c: number): boolean {
// 使用 TypeScript 类型断言来告诉编译器我们已知这个条件不会是null或undefined
const isNotEmoji = (c === 0x0) ||
(c === 0x9) ||
(c === 0xA) ||
(c === 0xD) ||
((c >= 0x20 && c == 0xD7FF)) ||
((c >= 0xE000 && c == 0xFFFD)) ||
((c >= 0x100000 && c == 0x10FFFF));
return !isNotEmoji;
}
private static isWhitespace(codePoint: number): boolean {
const whitespaceRegex = /^\s$/;
const character = String.fromCodePoint(codePoint);
return whitespaceRegex.test(character);
}
private static isSpaceChar(codePoint: number): boolean {
const spaceCategories = [
"Zs", // Space separator
"Zl", // Line separator
"Zp"// Paragraph separator
];
const character = String.fromCodePoint(codePoint);
const category = character.charCodeAt(0).toString(16);
return spaceCategories.includes(category);
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class CharUtils AST#class_body#Left { AST#constructor_declaration#Left private constructor AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { } AST#block_statement#Right AST#constructor_declaration#Right /**
* 是否空白符 空白符包括空格、制表符、全角空格和不间断空格
* @param c
* @returns
*/ AST#method_declaration#Left static isBlankChar AST#parameter_list#Left ( AST#parameter#Left c : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CharUtils AST#expression#Right . isWhitespace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left c AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left CharUtils AST#expression#Right AST#binary_expression#Right AST#expression#Right . isSpaceChar AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left c AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right == AST#expression#Left 0xFEFF AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right == AST#expression#Left 0x202A AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right == AST#expression#Left 0x0000 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 检查字符是否位于ASCII范围内(0~127)
* @param ch 被检查的字符
* @returns `true`表示为ASCII字符,否则为`false`
*/ AST#method_declaration#Left static isAscii AST#parameter_list#Left ( AST#parameter#Left ch : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 确保输入的是单个字符 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ch AST#expression#Right . length AST#member_expression#Right AST#expression#Right !== AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#statement#Left AST#throw_statement#Left throw AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "Input must be a single character" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#throw_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ch AST#expression#Right . charCodeAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right < AST#expression#Left 128 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 判断是否为emoji表情符
* @param c 字符
* @returns 是否为emoji
*/ AST#method_declaration#Left static isEmoji AST#parameter_list#Left ( AST#parameter#Left c : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 使用 TypeScript 类型断言来告诉编译器我们已知这个条件不会是null或undefined AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left isNotEmoji = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right === AST#expression#Left 0x0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right || AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right === AST#expression#Left 0x9 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right === AST#expression#Left 0xA AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right === AST#expression#Left 0xD AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right >= AST#expression#Left 0x20 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right == AST#expression#Left 0xD7FF AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right >= AST#expression#Left 0xE000 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right == AST#expression#Left 0xFFFD AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right >= AST#expression#Left 0x100000 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right == AST#expression#Left 0x10FFFF AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#unary_expression#Left ! AST#expression#Left isNotEmoji 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 AST#method_declaration#Left private static isWhitespace AST#parameter_list#Left ( AST#parameter#Left codePoint : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left whitespaceRegex AST#variable_declarator#Right AST#ERROR#Left = AST#ERROR#Left / ^ \s AST#ERROR#Right $ / AST#ERROR#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left character = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left String AST#expression#Right . fromCodePoint AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left codePoint AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left whitespaceRegex AST#expression#Right . test AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left character AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left private static isSpaceChar AST#parameter_list#Left ( AST#parameter#Left codePoint : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left spaceCategories = AST#expression#Left AST#array_literal#Left [ AST#expression#Left "Zs" AST#expression#Right , // Space separator AST#expression#Left "Zl" AST#expression#Right , // Line separator AST#expression#Left "Zp" AST#expression#Right // Paragraph separator ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left character = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left String AST#expression#Right . fromCodePoint AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left codePoint AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left category = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left character AST#expression#Right . charCodeAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 16 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left spaceCategories AST#expression#Right . includes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left category AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class CharUtils {
private constructor() {}
static isBlankChar(c: number): boolean {
return CharUtils.isWhitespace(c)
|| CharUtils.isSpaceChar(c)
|| c == 0xFEFF
|| c == 0x202A
|| c == 0x0000;
}
static isAscii(ch: string): boolean {
if (ch.length !== 1) throw new Error("Input must be a single character");
return ch.charCodeAt(0) < 128;
}
static isEmoji(c: number): boolean {
const isNotEmoji = (c === 0x0) ||
(c === 0x9) ||
(c === 0xA) ||
(c === 0xD) ||
((c >= 0x20 && c == 0xD7FF)) ||
((c >= 0xE000 && c == 0xFFFD)) ||
((c >= 0x100000 && c == 0x10FFFF));
return !isNotEmoji;
}
private static isWhitespace(codePoint: number): boolean {
const whitespaceRegex = /^\s$/;
const character = String.fromCodePoint(codePoint);
return whitespaceRegex.test(character);
}
private static isSpaceChar(codePoint: number): boolean {
const spaceCategories = [
"Zs",
"Zl",
"Zp"
];
const character = String.fromCodePoint(codePoint);
const category = character.charCodeAt(0).toString(16);
return spaceCategories.includes(category);
}
}
|
https://github.com/open9527/OpenHarmony/blob/fdea69ed722d426bf04e817ec05bff4002e81a4e/libs/core/src/main/ets/utils/CharUtils.ets#L4-L68
|
1dfc18608175a381b2d526a05e7135c52b4f0190
|
gitee
|
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
eftool/src/main/ets/core/media/FileUtil.ets
|
arkts
|
getCacheDirPath
|
获取缓存目录下的文件夹路径或文件路径。
@param dirPath 文件路径,支持完整路径 和 相对路径(download/wps/doc)。dirPath传空表示根目录
@param fileName 文件名(test.text)
@returns
|
static getCacheDirPath(dirPath: string, fileName?: string): string {
let filePath = getContext().cacheDir; //根目录
if (!StrUtil.isEmpty(dirPath)) {
if (FileUtil.hasDirPath(dirPath)) { //路径中包含根目录,是完整路径。
filePath = dirPath;
} else { //路径中不包含根目录,拼接成完整路径。
filePath = filePath + FileUtil.separator + dirPath;
}
if (!fs.accessSync(filePath)) {
FileUtil.mkdirSync(filePath) //如果文件夹不存在就创建
}
}
if (fileName && !StrUtil.isEmpty(fileName)) {
filePath = filePath + FileUtil.separator + fileName;
}
return filePath;
}
|
AST#method_declaration#Left static getCacheDirPath AST#parameter_list#Left ( AST#parameter#Left dirPath : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left fileName ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left filePath = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . cacheDir 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#unary_expression#Left ! AST#expression#Left StrUtil AST#expression#Right AST#unary_expression#Right AST#expression#Right . isEmpty AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left dirPath AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtil AST#expression#Right . hasDirPath AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left dirPath 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 filePath = AST#expression#Left dirPath AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { //路径中不包含根目录,拼接成完整路径。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left filePath = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left filePath AST#expression#Right + AST#expression#Left FileUtil AST#expression#Right AST#binary_expression#Right AST#expression#Right . separator AST#member_expression#Right AST#expression#Right + AST#expression#Left dirPath AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#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 filePath 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 FileUtil AST#expression#Right . mkdirSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left filePath 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#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 fileName AST#expression#Right && AST#expression#Left AST#unary_expression#Left ! AST#expression#Left StrUtil AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . isEmpty AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left fileName AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left filePath = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left filePath AST#expression#Right + AST#expression#Left FileUtil AST#expression#Right AST#binary_expression#Right AST#expression#Right . separator AST#member_expression#Right AST#expression#Right + AST#expression#Left fileName AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left filePath AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static getCacheDirPath(dirPath: string, fileName?: string): string {
let filePath = getContext().cacheDir;
if (!StrUtil.isEmpty(dirPath)) {
if (FileUtil.hasDirPath(dirPath)) {
filePath = dirPath;
} else {
filePath = filePath + FileUtil.separator + dirPath;
}
if (!fs.accessSync(filePath)) {
FileUtil.mkdirSync(filePath)
}
}
if (fileName && !StrUtil.isEmpty(fileName)) {
filePath = filePath + FileUtil.separator + fileName;
}
return filePath;
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/eftool/src/main/ets/core/media/FileUtil.ets#L64-L80
|
72a4b260c8bfa06fccc9177e0c79362212aa593d
|
gitee
|
openharmony/interface_sdk-js
|
c349adc73e2ec1f61f6fca489b5af059e3ed6999
|
arkts/@arkts.collections.d.ets
|
arkts
|
flipBitsByRange
|
Flips a range of bit values in a bit vector.(Flip 0 to 1, flip 1 to 0).
@param { number } fromIndex - The starting position of the index, containing the value at that index position.
@param { number } toIndex - The end of the index, excluding the value at that index.
@throws { BusinessError } 401 - Parameter error. Possible causes:
1.Mandatory parameters are left unspecified.
2.Incorrect parameter types.
@throws { BusinessError } 10200001 - The value of fromIndex or toIndex is out of range.
@throws { BusinessError } 10200011 - The flipBitsByRange method cannot be bound.
@throws { BusinessError } 10200201 - Concurrent modification error.
@syscap SystemCapability.Utils.Lang
@atomicservice
@since 12
Flips a range of bit values in a bit vector.(Flip 0 to 1, flip 1 to 0).
@param { number } fromIndex - The starting position of the index, containing the value at that index position.
@param { number } toIndex - The end of the index, excluding the value at that index.
@throws { BusinessError } 401 - Parameter error. Possible causes:
1.Mandatory parameters are left unspecified.
2.Incorrect parameter types.
@throws { BusinessError } 10200001 - The value of fromIndex or toIndex is out of range.
@throws { BusinessError } 10200011 - The flipBitsByRange method cannot be bound.
@throws { BusinessError } 10200201 - Concurrent modification error.
@syscap SystemCapability.Utils.Lang
@crossplatform
@atomicservice
@since 18
|
flipBitsByRange(fromIndex: number, toIndex: number): void;
|
AST#method_declaration#Left flipBitsByRange AST#parameter_list#Left ( AST#parameter#Left fromIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left toIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right
|
flipBitsByRange(fromIndex: number, toIndex: number): void;
|
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/arkts/@arkts.collections.d.ets#L12494-L12494
|
b7860d478731c0b73abf4d7992e38978b480906f
|
gitee
|
openharmony/developtools_profiler
|
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
|
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/utils/Transformer.ets
|
arkts
|
generateTransformedValuesScatter
|
Transforms an List of Entry into a float array containing the x and
y values transformed with all matrices for the SCATTERCHART.
@param data
@return
|
public generateTransformedValuesScatter(
data: IScatterDataSet,
phaseX: number,
phaseY: number,
froms: number,
to: number
): number[] {
const count: number = to - froms * phaseX + 1 * 2;
if (this.valuePointsForGenerateTransformedValuesScatter.length != count) {
this.valuePointsForGenerateTransformedValuesScatter = new Array<number>(count);
}
var valuePoints: number[] = this.valuePointsForGenerateTransformedValuesScatter;
for (var j = 0; j < count; j += 2) {
var e: Entry = data.getEntryForIndex(j / 2 + froms);
if (e != null) {
valuePoints[j] = e.getX();
valuePoints[j + 1] = e.getY() * phaseY;
} else {
valuePoints[j] = 0;
valuePoints[j + 1] = 0;
}
}
this.getValueToPixelMatrix().mapPoints(valuePoints);
return valuePoints;
}
|
AST#method_declaration#Left public generateTransformedValuesScatter AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left IScatterDataSet AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left phaseX : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left phaseY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left froms : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left to : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] 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 count : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left to AST#expression#Right - AST#expression#Left AST#binary_expression#Left AST#expression#Left froms AST#expression#Right * AST#expression#Left phaseX 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 1 AST#expression#Right * AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#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 . valuePointsForGenerateTransformedValuesScatter AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right != AST#expression#Left count 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 . valuePointsForGenerateTransformedValuesScatter AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left count AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left var AST#variable_declarator#Left valuePoints : 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#member_expression#Left AST#expression#Left this AST#expression#Right . valuePointsForGenerateTransformedValuesScatter AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left var AST#variable_declarator#Left j = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#binary_expression#Left AST#expression#Left j AST#expression#Right < AST#expression#Left count AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#expression#Left AST#assignment_expression#Left j += AST#expression#Left 2 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left var AST#variable_declarator#Left e : AST#type_annotation#Left AST#primary_type#Left Entry 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 data AST#expression#Right . getEntryForIndex 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 j AST#expression#Right / AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left froms AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left e AST#expression#Right != AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left valuePoints AST#expression#Right [ AST#expression#Left j AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left = e AST#ERROR#Right . getX 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#binary_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 valuePoints AST#expression#Right [ AST#expression#Left AST#binary_expression#Left AST#expression#Left j AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left = e AST#ERROR#Right . getY 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 phaseY AST#expression#Right AST#binary_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#subscript_expression#Left AST#expression#Left valuePoints AST#expression#Right [ AST#expression#Left j 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 0 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 valuePoints AST#expression#Right [ AST#expression#Left AST#binary_expression#Left AST#expression#Left j AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_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 0 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getValueToPixelMatrix AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . mapPoints AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left valuePoints 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 valuePoints AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public generateTransformedValuesScatter(
data: IScatterDataSet,
phaseX: number,
phaseY: number,
froms: number,
to: number
): number[] {
const count: number = to - froms * phaseX + 1 * 2;
if (this.valuePointsForGenerateTransformedValuesScatter.length != count) {
this.valuePointsForGenerateTransformedValuesScatter = new Array<number>(count);
}
var valuePoints: number[] = this.valuePointsForGenerateTransformedValuesScatter;
for (var j = 0; j < count; j += 2) {
var e: Entry = data.getEntryForIndex(j / 2 + froms);
if (e != null) {
valuePoints[j] = e.getX();
valuePoints[j + 1] = e.getY() * phaseY;
} else {
valuePoints[j] = 0;
valuePoints[j + 1] = 0;
}
}
this.getValueToPixelMatrix().mapPoints(valuePoints);
return valuePoints;
}
|
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/utils/Transformer.ets#L103-L132
|
d5a507342840b19023744b151c1a0e3437531494
|
gitee
|
openharmony/xts_tools
|
784a2e99d894e6bc2aba8c38f6bb68032442b1c8
|
sample/AppSampleD/entry/src/main/ets/component/SearchResultComponent.ets
|
arkts
|
aboutToAppear
|
综合、视频等title选择索引
|
aboutToAppear() {
// 默认值
if (this.inputSearch === '') {
this.inputSearch = MockInput.TEST_INPUT_CONTENT_1;
}
// 依据不同的搜索展示不同的模拟数据
Logger.info(TAG, `this.inputSearch: ${JSON.stringify(this.inputSearch)}`);
if (this.inputSearch.indexOf(MockInput.TEST_INPUT_CONTENT_1) !== -1) {
// 输入"黑夜问白天"的模拟数据
this.currSearchResult = this.searchResultList[0];
} else if (this.inputSearch.indexOf(MockInput.TEST_INPUT_CONTENT_2) !== -1) {
// 输入"哦想"的模拟数据
this.currSearchResult = this.searchResultList[1];
} else if (this.inputSearch.indexOf(MockInput.TEST_INPUT_CONTENT_3) !== -1) {
// 输入"我不愿让你一个人"的模拟数据
this.currSearchResult = this.searchResultList[2];
}
Logger.info(TAG, `this.currSearchResult: ${JSON.stringify(this.currSearchResult)}`);
}
|
AST#method_declaration#Left aboutToAppear 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 . inputSearch AST#member_expression#Right AST#expression#Right === AST#expression#Left '' 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 . inputSearch AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left MockInput AST#expression#Right . TEST_INPUT_CONTENT_1 AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right // 依据不同的搜索展示不同的模拟数据 AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` this.inputSearch: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputSearch AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputSearch AST#member_expression#Right AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left MockInput AST#expression#Right . TEST_INPUT_CONTENT_1 AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right !== AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { // 输入"黑夜问白天"的模拟数据 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currSearchResult AST#member_expression#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . searchResultList AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } else AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputSearch AST#member_expression#Right AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left MockInput AST#expression#Right . TEST_INPUT_CONTENT_2 AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right !== AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { // 输入"哦想"的模拟数据 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currSearchResult AST#member_expression#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . searchResultList AST#member_expression#Right AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } else AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputSearch AST#member_expression#Right AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left MockInput AST#expression#Right . TEST_INPUT_CONTENT_3 AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right !== AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { // 输入"我不愿让你一个人"的模拟数据 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currSearchResult AST#member_expression#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . searchResultList AST#member_expression#Right AST#expression#Right [ AST#expression#Left 2 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_if_statement#Right AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` this.currSearchResult: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currSearchResult AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
aboutToAppear() {
if (this.inputSearch === '') {
this.inputSearch = MockInput.TEST_INPUT_CONTENT_1;
}
Logger.info(TAG, `this.inputSearch: ${JSON.stringify(this.inputSearch)}`);
if (this.inputSearch.indexOf(MockInput.TEST_INPUT_CONTENT_1) !== -1) {
this.currSearchResult = this.searchResultList[0];
} else if (this.inputSearch.indexOf(MockInput.TEST_INPUT_CONTENT_2) !== -1) {
this.currSearchResult = this.searchResultList[1];
} else if (this.inputSearch.indexOf(MockInput.TEST_INPUT_CONTENT_3) !== -1) {
this.currSearchResult = this.searchResultList[2];
}
Logger.info(TAG, `this.currSearchResult: ${JSON.stringify(this.currSearchResult)}`);
}
|
https://github.com/openharmony/xts_tools/blob/784a2e99d894e6bc2aba8c38f6bb68032442b1c8/sample/AppSampleD/entry/src/main/ets/component/SearchResultComponent.ets#L35-L53
|
c3e90236b7b0f92b8e9f3c5eb264ffad42581e02
|
gitee
|
wangjinyuan/JS-TS-ArkTS-database.git
|
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
|
npm/alprazolamdiv/11.5.1/package/src/client/websocket/packets/handlers/TypingStart.ets
|
arkts
|
应用约束:1. 强制使用静态类型
|
constructor(
client: any,
since: Date,
lastTimestamp: Date,
_timeout: number
) {
this.client = client;
this.since = since;
this.lastTimestamp = lastTimestamp;
this._timeout = _timeout;
}
|
AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left client : AST#type_annotation#Left AST#primary_type#Left any AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left since : AST#type_annotation#Left AST#primary_type#Left Date AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left lastTimestamp : AST#type_annotation#Left AST#primary_type#Left Date AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left _timeout : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . client AST#member_expression#Right = AST#expression#Left client 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 . since AST#member_expression#Right = AST#expression#Left since 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 . lastTimestamp AST#member_expression#Right = AST#expression#Left lastTimestamp 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 . _timeout AST#member_expression#Right = AST#expression#Left _timeout 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(
client: any,
since: Date,
lastTimestamp: Date,
_timeout: number
) {
this.client = client;
this.since = since;
this.lastTimestamp = lastTimestamp;
this._timeout = _timeout;
}
|
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/client/websocket/packets/handlers/TypingStart.ets#L53-L63
|
49405cf05b124fe1a21187819797a77d65c41606
|
github
|
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/CharUtil.ets
|
arkts
|
TODO 字符工具类
author: 桃花镇童长老ᥫ᭡
since: 2024/05/01
|
export class CharUtil {
/**
* 判断字符串char是否是数字
* @param char
* @returns
*/
static isDigit(char: string): boolean {
return i18n.Unicode.isDigit(char);
}
/**
* 判断字符串char是否是字母
* @param char
* @returns
*/
static isLetter(char: string): boolean {
return i18n.Unicode.isLetter(char);
}
/**
* 判断字符串char是否是小写字母
* @param char
* @returns
*/
static isLowerCase(char: string): boolean {
return i18n.Unicode.isLowerCase(char);
}
/**
* 判断字符串char是否是大写字母
* @param char
* @returns
*/
static isUpperCase(char: string): boolean {
return i18n.Unicode.isUpperCase(char);
}
/**
* 判断字符串char是否是空格符
* @param char
* @returns
*/
static isSpaceChar(char: string): boolean {
return i18n.Unicode.isSpaceChar(char);
}
/**
* 判断字符串char是否是空白符
* @param char
* @returns
*/
static isWhitespace(char: string): boolean {
return i18n.Unicode.isWhitespace(char);
}
/**
* 判断字符串char是否是从右到左语言的字符
* @param char
* @returns
*/
static isRTL(char: string): boolean {
return i18n.Unicode.isRTL(char);
}
/**
* 判断字符串char是否是表意文字
* @param char
* @returns
*/
static isIdeograph(char: string): boolean {
return i18n.Unicode.isIdeograph(char);
}
/**
* 判断是否空白符 空白符包括空格、制表符、全角空格和不间断空格
* @param c
* @returns
*/
static isBlankChar(c: number): boolean {
return CharUtil.isWhitespace(c.toString())
|| CharUtil.isSpaceChar(c.toString())
|| c === 0xFEFF || c === 0x202A || c === 0x0000;
}
/**
* 判断字符是否位于ASCII范围内(其中0-31是控制字符,32-127表示从A到Z的字母字符)
* @param char 字符
* @returns
*/
static isAscii(char: string): boolean {
if (char.length === 1) { //确保输入的是单个字符
return char.charCodeAt(0) < 128;
} else {
return false;
}
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class CharUtil AST#class_body#Left { /**
* 判断字符串char是否是数字
* @param char
* @returns
*/ AST#method_declaration#Left static isDigit AST#parameter_list#Left ( AST#parameter#Left char : 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 i18n AST#expression#Right . Unicode AST#member_expression#Right AST#expression#Right . isDigit AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left char 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 /**
* 判断字符串char是否是字母
* @param char
* @returns
*/ AST#method_declaration#Left static isLetter AST#parameter_list#Left ( AST#parameter#Left char : 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 i18n AST#expression#Right . Unicode AST#member_expression#Right AST#expression#Right . isLetter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left char 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 /**
* 判断字符串char是否是小写字母
* @param char
* @returns
*/ AST#method_declaration#Left static isLowerCase AST#parameter_list#Left ( AST#parameter#Left char : 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 i18n AST#expression#Right . Unicode AST#member_expression#Right AST#expression#Right . isLowerCase AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left char 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 /**
* 判断字符串char是否是大写字母
* @param char
* @returns
*/ AST#method_declaration#Left static isUpperCase AST#parameter_list#Left ( AST#parameter#Left char : 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 i18n AST#expression#Right . Unicode AST#member_expression#Right AST#expression#Right . isUpperCase AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left char 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 /**
* 判断字符串char是否是空格符
* @param char
* @returns
*/ AST#method_declaration#Left static isSpaceChar AST#parameter_list#Left ( AST#parameter#Left char : 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 i18n AST#expression#Right . Unicode AST#member_expression#Right AST#expression#Right . isSpaceChar AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left char 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 /**
* 判断字符串char是否是空白符
* @param char
* @returns
*/ AST#method_declaration#Left static isWhitespace AST#parameter_list#Left ( AST#parameter#Left char : 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 i18n AST#expression#Right . Unicode AST#member_expression#Right AST#expression#Right . isWhitespace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left char 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 /**
* 判断字符串char是否是从右到左语言的字符
* @param char
* @returns
*/ AST#method_declaration#Left static isRTL AST#parameter_list#Left ( AST#parameter#Left char : 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 i18n AST#expression#Right . Unicode AST#member_expression#Right AST#expression#Right . isRTL AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left char 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 /**
* 判断字符串char是否是表意文字
* @param char
* @returns
*/ AST#method_declaration#Left static isIdeograph AST#parameter_list#Left ( AST#parameter#Left char : 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 i18n AST#expression#Right . Unicode AST#member_expression#Right AST#expression#Right . isIdeograph AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left char 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 c
* @returns
*/ AST#method_declaration#Left static isBlankChar AST#parameter_list#Left ( AST#parameter#Left c : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CharUtil AST#expression#Right . isWhitespace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left c AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left CharUtil AST#expression#Right AST#binary_expression#Right AST#expression#Right . isSpaceChar AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left c AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right === AST#expression#Left 0xFEFF AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right === AST#expression#Left 0x202A AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right === AST#expression#Left 0x0000 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 判断字符是否位于ASCII范围内(其中0-31是控制字符,32-127表示从A到Z的字母字符)
* @param char 字符
* @returns
*/ AST#method_declaration#Left static isAscii AST#parameter_list#Left ( AST#parameter#Left char : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left char AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { //确保输入的是单个字符 AST#statement#Left AST#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 char AST#expression#Right . charCodeAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right < AST#expression#Left 128 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class CharUtil {
static isDigit(char: string): boolean {
return i18n.Unicode.isDigit(char);
}
static isLetter(char: string): boolean {
return i18n.Unicode.isLetter(char);
}
static isLowerCase(char: string): boolean {
return i18n.Unicode.isLowerCase(char);
}
static isUpperCase(char: string): boolean {
return i18n.Unicode.isUpperCase(char);
}
static isSpaceChar(char: string): boolean {
return i18n.Unicode.isSpaceChar(char);
}
static isWhitespace(char: string): boolean {
return i18n.Unicode.isWhitespace(char);
}
static isRTL(char: string): boolean {
return i18n.Unicode.isRTL(char);
}
static isIdeograph(char: string): boolean {
return i18n.Unicode.isIdeograph(char);
}
static isBlankChar(c: number): boolean {
return CharUtil.isWhitespace(c.toString())
|| CharUtil.isSpaceChar(c.toString())
|| c === 0xFEFF || c === 0x202A || c === 0x0000;
}
static isAscii(char: string): boolean {
if (char.length === 1) {
return char.charCodeAt(0) < 128;
} else {
return false;
}
}
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/CharUtil.ets#L23-L125
|
27c8a8ab9279e4a579179ab839c5fb352276239b
|
gitee
|
|
Piagari/arkts_example.git
|
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
|
hmos_app-main/hmos_app-main/legado-Harmony-master/entry/src/main/ets/componets/Reader/MusicPlayer.ets
|
arkts
|
formatMilliseconds
|
private Player: media.AVPlayer = new media 格式化时间
|
formatMilliseconds(milliseconds: number): string {
const totalSeconds = Math.floor(milliseconds / 1000);
const minutes = Math.floor(totalSeconds / 60);
const seconds = totalSeconds % 60;
// 格式化秒数为两位数字
const formattedSeconds = seconds < 10 ? `0${seconds}` : `${seconds}`;
return `${minutes}:${formattedSeconds}`;
}
|
AST#method_declaration#Left formatMilliseconds AST#parameter_list#Left ( AST#parameter#Left milliseconds : 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 totalSeconds = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left milliseconds AST#expression#Right / AST#expression#Left 1000 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left minutes = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left totalSeconds AST#expression#Right / AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left seconds = AST#expression#Left AST#binary_expression#Left AST#expression#Left totalSeconds AST#expression#Right % AST#expression#Left 60 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 formattedSeconds = AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left seconds AST#expression#Right < AST#expression#Left 10 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#template_literal#Left ` 0 AST#template_substitution#Left $ { AST#expression#Left seconds AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right : AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left seconds AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left minutes AST#expression#Right } AST#template_substitution#Right : AST#template_substitution#Left $ { AST#expression#Left formattedSeconds AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
formatMilliseconds(milliseconds: number): string {
const totalSeconds = Math.floor(milliseconds / 1000);
const minutes = Math.floor(totalSeconds / 60);
const seconds = totalSeconds % 60;
const formattedSeconds = seconds < 10 ? `0${seconds}` : `${seconds}`;
return `${minutes}:${formattedSeconds}`;
}
|
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/legado-Harmony-master/entry/src/main/ets/componets/Reader/MusicPlayer.ets#L25-L34
|
f98edfad98afec7d40b97efcde8a86bc9746a43a
|
github
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_dialog/src/main/ets/dialog/DialogHelper.ets
|
arkts
|
generateId
|
生成弹框id
|
static generateId() {
return ActionBaseCore.getInstance().generateDialogId();
}
|
AST#method_declaration#Left static generateId AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#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 . generateDialogId 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 generateId() {
return ActionBaseCore.getInstance().generateDialogId();
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_dialog/src/main/ets/dialog/DialogHelper.ets#L120-L122
|
87405a216aeeeb181a165b92563da3edc315b75c
|
gitee
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
ef_crypto/src/main/ets/crypto/encryption/SM4Sync.ets
|
arkts
|
decodeECB
|
解密-ECB模式
@param str 加密的字符串
@param sm4Key SM4密钥
@param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
@param dataCoding 返回结果编码方式(hex/base64)-默认不传为base64格式
|
static decodeECB(str: string, sm4Key: string, keyCoding: buffer.BufferEncoding,
dataCoding: buffer.BufferEncoding = 'base64'): string {
return CryptoSyncUtil.decodeECB(str, sm4Key, 'SM4_128', 'SM4_128|ECB|PKCS7', 128, keyCoding, dataCoding);
}
|
AST#method_declaration#Left static decodeECB AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left sm4Key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left 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_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 CryptoSyncUtil AST#expression#Right . decodeECB AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left sm4Key AST#expression#Right , AST#expression#Left 'SM4_128' AST#expression#Right , AST#expression#Left 'SM4_128|ECB|PKCS7' AST#expression#Right , AST#expression#Left 128 AST#expression#Right , AST#expression#Left keyCoding AST#expression#Right , AST#expression#Left dataCoding 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 decodeECB(str: string, sm4Key: string, keyCoding: buffer.BufferEncoding,
dataCoding: buffer.BufferEncoding = 'base64'): string {
return CryptoSyncUtil.decodeECB(str, sm4Key, 'SM4_128', 'SM4_128|ECB|PKCS7', 128, keyCoding, dataCoding);
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto/src/main/ets/crypto/encryption/SM4Sync.ets#L58-L61
|
ed39c8bb37ef49111a65913409f8c5d1508c402b
|
gitee
|
openharmony-sig/knowledge_demo_smart_home
|
6cdf5d81ef84217f386c4200bfc4124a0ded5a0d
|
FA/DistScheduleEts/entry/src/main/ets/controlPage/common/utils/controlPageUtil.ets
|
arkts
|
getKeyValue
|
获取 JSON key 值
|
static getKeyValue( data:string, ...args) {
let jsonObject = JSON.parse(data);
let properties = jsonObject.services[0].properties;
let arr = []
for( var i = 0; i < args.length; i++) {
let key = args[i]
arr[i] = properties[key]
}
return arr;
}
|
AST#method_declaration#Left static getKeyValue AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left ... args AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left jsonObject = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left properties = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left jsonObject AST#expression#Right . services AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . properties 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 arr = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left var AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left args AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left key AST#ERROR#Left = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left args AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left arr AST#ERROR#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left properties AST#expression#Right [ AST#expression#Left key AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#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 arr AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static getKeyValue( data:string, ...args) {
let jsonObject = JSON.parse(data);
let properties = jsonObject.services[0].properties;
let arr = []
for( var i = 0; i < args.length; i++) {
let key = args[i]
arr[i] = properties[key]
}
return arr;
}
|
https://github.com/openharmony-sig/knowledge_demo_smart_home/blob/6cdf5d81ef84217f386c4200bfc4124a0ded5a0d/FA/DistScheduleEts/entry/src/main/ets/controlPage/common/utils/controlPageUtil.ets#L27-L36
|
db0d9dc0d298642a44e2be72875361f264a1ddef
|
gitee
|
azhuge233/ASFShortcut-HN.git
|
d1669c920c56317611b5b0375aa5315c1b91211b
|
entry/src/main/ets/common/utils/CommonUtils.ets
|
arkts
|
getDate
|
获取时间(毫秒)
|
private getDate(): string {
let date = new Date(systemDateTime.getTime());
const formattedTime = `${date.getTime().toString()}`;
Logger.debug(this.LOG_TAG, formattedTime);
return formattedTime;
}
|
AST#method_declaration#Left private getDate AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left date = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left systemDateTime 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#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 formattedTime = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date 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 . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#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 Logger AST#expression#Right . debug AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . LOG_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left formattedTime 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 formattedTime AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private getDate(): string {
let date = new Date(systemDateTime.getTime());
const formattedTime = `${date.getTime().toString()}`;
Logger.debug(this.LOG_TAG, formattedTime);
return formattedTime;
}
|
https://github.com/azhuge233/ASFShortcut-HN.git/blob/d1669c920c56317611b5b0375aa5315c1b91211b/entry/src/main/ets/common/utils/CommonUtils.ets#L200-L207
|
843c67352d6eee8eb92d1199ce6db6b8bb72f6a0
|
github
|
conrad_sheeran/TickAuth
|
8ef852e12999d15cf70394cdab82d08ac5843143
|
features/steam/src/main/ets/common/Constants.ets
|
arkts
|
Copyright (c) 2024 Yang He
TickAuth is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
export class Constants {
static readonly DOMAIN: number = 0x00203;
static readonly TOTPVIEW_LIST_SIZE: string = "100%";
static readonly TOTPVIEW_LIST_SPACE: number = 12;
static readonly TOTPVIEW_LISTITEM_MAXLINE: number = 1;
static readonly TOTPVIEW_LISTITEM_TOTP_WIDTH: string = "50%";
static readonly TOTPVIEW_LISTITEM_TOTP_HEIGHT: string = "50%";
static readonly TOTPVIEW_LISTITEM_WIDTH: string = "100%";
static readonly TOTPVIEW_LISTITEM_HEIGHT: string = "13.5%";
static readonly NOKEYINJSON_IMAGE_MARGIN: string = "7%";
static readonly ANIMATION_DURING: number = 500;
}
|
AST#export_declaration#Left export AST#class_declaration#Left class Constants AST#class_body#Left { AST#property_declaration#Left static readonly DOMAIN : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0x00203 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly TOTPVIEW_LIST_SIZE : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "100%" AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly TOTPVIEW_LIST_SPACE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 12 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly TOTPVIEW_LISTITEM_MAXLINE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly TOTPVIEW_LISTITEM_TOTP_WIDTH : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "50%" AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly TOTPVIEW_LISTITEM_TOTP_HEIGHT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "50%" AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly TOTPVIEW_LISTITEM_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 AST#property_declaration#Left static readonly TOTPVIEW_LISTITEM_HEIGHT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "13.5%" AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly NOKEYINJSON_IMAGE_MARGIN : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "7%" AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly ANIMATION_DURING : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 500 AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class Constants {
static readonly DOMAIN: number = 0x00203;
static readonly TOTPVIEW_LIST_SIZE: string = "100%";
static readonly TOTPVIEW_LIST_SPACE: number = 12;
static readonly TOTPVIEW_LISTITEM_MAXLINE: number = 1;
static readonly TOTPVIEW_LISTITEM_TOTP_WIDTH: string = "50%";
static readonly TOTPVIEW_LISTITEM_TOTP_HEIGHT: string = "50%";
static readonly TOTPVIEW_LISTITEM_WIDTH: string = "100%";
static readonly TOTPVIEW_LISTITEM_HEIGHT: string = "13.5%";
static readonly NOKEYINJSON_IMAGE_MARGIN: string = "7%";
static readonly ANIMATION_DURING: number = 500;
}
|
https://github.com/conrad_sheeran/TickAuth/blob/8ef852e12999d15cf70394cdab82d08ac5843143/features/steam/src/main/ets/common/Constants.ets#L18-L38
|
cd6a092c761c565132ebaede87a3cb10898386d4
|
gitee
|
|
Piagari/arkts_example.git
|
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
|
hmos_app-main/hmos_app-main/DriverLicenseExam-master/commons/commonLib/src/main/ets/utils/LocateUtil.ets
|
arkts
|
getPreLocationPosition
|
Get cache location information
|
public static getPreLocationPosition() {
try {
let location = geoLocationManager.getLastLocation();
LocateUtil.userLatitude = location.latitude;
LocateUtil.userLongitude = location.longitude;
Logger.debug(TAG,
`getPreLocationPosition success, latitude: ${location.latitude}, longitude: ${location.longitude}`);
} catch (err) {
Logger.error(TAG, `getPreLocationPosition failed, code: ${err.code}, message: ${err.message}`);
LocateUtil.locationFailedAlert(err.code);
}
}
|
AST#method_declaration#Left public static getPreLocationPosition AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left location = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left geoLocationManager AST#expression#Right . getLastLocation AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left LocateUtil AST#expression#Right . userLatitude AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left location AST#expression#Right . latitude 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 LocateUtil AST#expression#Right . userLongitude AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left location AST#expression#Right . longitude AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . debug 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 ` getPreLocationPosition success, latitude: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left location AST#expression#Right . latitude AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , longitude: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left location AST#expression#Right . longitude AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` getPreLocationPosition failed, code: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , message: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LocateUtil AST#expression#Right . locationFailedAlert AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public static getPreLocationPosition() {
try {
let location = geoLocationManager.getLastLocation();
LocateUtil.userLatitude = location.latitude;
LocateUtil.userLongitude = location.longitude;
Logger.debug(TAG,
`getPreLocationPosition success, latitude: ${location.latitude}, longitude: ${location.longitude}`);
} catch (err) {
Logger.error(TAG, `getPreLocationPosition failed, code: ${err.code}, message: ${err.message}`);
LocateUtil.locationFailedAlert(err.code);
}
}
|
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/DriverLicenseExam-master/commons/commonLib/src/main/ets/utils/LocateUtil.ets#L25-L36
|
803465c446fda59321d26634b3f6003db0308ee4
|
github
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
ef_ui/src/main/ets/ui/select/Cascade.ets
|
arkts
|
getAreaData
|
获取区县数据
@param prevCode 省code
@param cityCode 市code
@returns
|
private getAreaData(prevCode: string, cityCode: string): Array<City> {
return ((this.provinceList.filter((pro: City) => pro.code == prevCode)
.pop() as City).children.filter((city: City) => city.code == cityCode).pop() as City).children;
}
|
AST#method_declaration#Left private getAreaData AST#parameter_list#Left ( AST#parameter#Left prevCode : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left cityCode : 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 Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left City 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#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 AST#call_expression#Left AST#expression#Left AST#member_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 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 . provinceList AST#member_expression#Right AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left pro : AST#type_annotation#Left AST#primary_type#Left City AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left pro AST#expression#Right . code AST#member_expression#Right AST#expression#Right == AST#expression#Left prevCode 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 . pop AST#member_expression#Right 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 City AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . children AST#member_expression#Right AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left city : AST#type_annotation#Left AST#primary_type#Left City AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left city AST#expression#Right . code AST#member_expression#Right AST#expression#Right == AST#expression#Left cityCode 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 . pop AST#member_expression#Right 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 City AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . children AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private getAreaData(prevCode: string, cityCode: string): Array<City> {
return ((this.provinceList.filter((pro: City) => pro.code == prevCode)
.pop() as City).children.filter((city: City) => city.code == cityCode).pop() as City).children;
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_ui/src/main/ets/ui/select/Cascade.ets#L126-L129
|
5334f17b889d83e5675d06e3c46b9a2b6cf3c0b7
|
gitee
|
Joker-x-dev/HarmonyKit.git
|
f97197ce157df7f303244fba42e34918306dfb08
|
core/state/src/main/ets/model/SafeAreaInsets.ets
|
arkts
|
@file 安全区内边距类型定义
@author Joker.X
安全区内边距
|
export interface SafeAreaInsets {
/**
* 顶部安全区边距(vp)
*/
top: number;
/**
* 左侧安全区边距(vp)
*/
left: number;
/**
* 底部安全区边距(vp)
*/
bottom: number;
/**
* 右侧安全区边距(vp)
*/
right: number;
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface SafeAreaInsets AST#object_type#Left { /**
* 顶部安全区边距(vp)
*/ AST#type_member#Left top : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /**
* 左侧安全区边距(vp)
*/ AST#type_member#Left left : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /**
* 底部安全区边距(vp)
*/ AST#type_member#Left bottom : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /**
* 右侧安全区边距(vp)
*/ AST#type_member#Left right : 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 SafeAreaInsets {
top: number;
left: number;
bottom: number;
right: number;
}
|
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/state/src/main/ets/model/SafeAreaInsets.ets#L9-L29
|
9a18433aaaa746e7fb429e83d6b8acf31b44358c
|
github
|
|
ChangweiZhang/chardet-arkts.git
|
3a214882ec6a2753c0fed84162952aa659341c19
|
src/main/ets/components/utils.ets
|
arkts
|
May also check if every element is a number <= 255 but it a little bit slower
|
export function isByteArray(input: Uint8Array): boolean {
if (input == null || typeof input != 'object') return false;
return isFinite(input.length) && input.length >= 0;
}
;
|
AST#export_declaration#Left export AST#function_declaration#Left function isByteArray AST#parameter_list#Left ( AST#parameter#Left input : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left input 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 AST#unary_expression#Left typeof AST#expression#Left input AST#expression#Right AST#unary_expression#Right AST#expression#Right != AST#expression#Left 'object' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left isFinite AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left input AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right && AST#expression#Left input 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right ; AST#export_declaration#Right
|
export function isByteArray(input: Uint8Array): boolean {
if (input == null || typeof input != 'object') return false;
return isFinite(input.length) && input.length >= 0;
}
;
|
https://github.com/ChangweiZhang/chardet-arkts.git/blob/3a214882ec6a2753c0fed84162952aa659341c19/src/main/ets/components/utils.ets#L3-L8
|
72ff12e1abb1b49b528060e60bb274c8443d7d98
|
github
|
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/Solutions/IM/Chat/products/phone/entry/src/main/ets/pages/Index.ets
|
arkts
|
TabBuilder
|
设置tabBar样式的位置、未选中图片、选中图片及文字显示的参数
|
@Builder
TabBuilder(index: number, imageNormal: Resource, imageSelected: Resource, text: Resource) {
Column() {
Divider()
.vertical(false)
.strokeWidth(DIVIDER_LINE_STROKWIDTH)
.color($r('app.color.tab_bar_separator_line_color'))
.opacity(TABBAR_SEPARATE_LINE)
Image(this.currentIndex === index ? imageSelected : imageNormal)
.syncLoad(true)
.width($r('app.integer.tabbar_image_width'))
.height($r('app.integer.tabbar_image_height'))
.margin($r('app.integer.tabbar_image_margin'))
.objectFit(ImageFit.Contain)
Text(text)
.fontSize($r('app.integer.tabbar_item_font_size'))
.fontColor(this.currentIndex === index ?
$r('app.color.tabbar_font_color_selected') : $r('app.color.tabbar_font_color_normal'));
}
.height($r('app.string.layout_100'))
.width($r('app.string.layout_100'))
}
build() {
Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentIndex }) {
TabContent() {
Column() {
TopBar()
ChatListDisplayView()
}
}
.tabBar(this.TabBuilder(TAB_INDEX_0,
$r('app.media.chatIconNormal'),
$r('app.media.chatIconSelected'),
$r('app.string.chat')));
TabContent() {
FriendsPage()
}
.tabBar(this.TabBuilder(TAB_INDEX_1,
$r('app.media.contactIconNormal'),
$r('app.media.contactIconSelected'),
$r('app.string.contacts')));
TabContent() {
DiscoverPage()
}
.tabBar(this.TabBuilder(TAB_INDEX_2,
$r('app.media.findIconNormal'),
$r('app.media.findIconSelected'),
$r('app.string.discovery')));
TabContent() {
SettingPage()
}
.tabBar(this.TabBuilder(TAB_INDEX_3,
$r('app.media.profileIconNormal'),
$r('app.media.profileIconSelected'),
$r('app.string.my')));
}
.onChange((index: number) => {
this.currentIndex = index;
if (this.currentIndex === TAB_INDEX_0) {
this.message = $r('app.string.chat');
} else if (this.currentIndex === TAB_INDEX_1) {
this.message = $r('app.string.contacts');
} else if (this.currentIndex === TAB_INDEX_2) {
this.message = $r('app.string.discovery');
} else if (this.currentIndex === TAB_INDEX_3) {
this.message = $r('app.string.my');
}
})
.barWidth($r('app.string.layout_100'))
.barHeight($r('app.integer.tabbar_height'))
.backgroundColor($r('app.color.tabbar_background'))
}
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right TabBuilder AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left imageNormal : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left imageSelected : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left text : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { 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 . vertical ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . strokeWidth ( AST#expression#Left DIVIDER_LINE_STROKWIDTH AST#expression#Right ) AST#modifier_chain_expression#Left . color ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.tab_bar_separator_line_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left TABBAR_SEPARATE_LINE AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left Image ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentIndex AST#member_expression#Right AST#expression#Right === AST#expression#Left index AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#ERROR#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left imageSelected AST#expression#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left imageNormal AST#primary_type#Right AST#type_annotation#Right ) AST#ERROR#Right . syncLoad 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 . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.tabbar_image_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.tabbar_image_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . margin AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.tabbar_image_margin' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . objectFit AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left ImageFit AST#expression#Right . Contain AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left Text AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left text AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontSize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.tabbar_item_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentIndex AST#member_expression#Right AST#expression#Right === AST#expression#Left index AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.tabbar_font_color_selected' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.tabbar_font_color_normal' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left ; } AST#ERROR#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.layout_100' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.layout_100' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left } build AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right { AST#property_name#Left Tabs AST#property_name#Right ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left barPosition AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left BarPosition AST#expression#Right . End AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left controller AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . controller AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left index AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentIndex AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#ERROR#Right AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left TabContent AST#property_name#Right AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left Column 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#object_literal#Left { AST#ERROR#Left AST#property_name#Left TopBar AST#property_name#Right AST#parameter_list#Left ( ) AST#parameter_list#Right AST#property_name#Left ChatListDisplayView AST#property_name#Right AST#parameter_list#Left ( ) AST#parameter_list#Right } AST#ERROR#Right } AST#object_literal#Right AST#expression#Right . tabBar 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 . TabBuilder AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAB_INDEX_0 AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.chatIconNormal' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.chatIconSelected' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.chat' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left TabContent 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#object_literal#Left { AST#ERROR#Left AST#property_name#Left FriendsPage AST#property_name#Right AST#parameter_list#Left ( ) AST#parameter_list#Right AST#ERROR#Right } AST#object_literal#Right AST#expression#Right . tabBar 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 . TabBuilder AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAB_INDEX_1 AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.contactIconNormal' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.contactIconSelected' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.contacts' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left TabContent 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#object_literal#Left { AST#ERROR#Left AST#property_name#Left DiscoverPage AST#property_name#Right AST#parameter_list#Left ( ) AST#parameter_list#Right AST#ERROR#Right } AST#object_literal#Right AST#expression#Right . tabBar 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 . TabBuilder AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAB_INDEX_2 AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.findIconNormal' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.findIconSelected' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.discovery' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left TabContent 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#object_literal#Left { AST#ERROR#Left AST#property_name#Left SettingPage AST#property_name#Right AST#parameter_list#Left ( ) AST#parameter_list#Right AST#ERROR#Right } AST#object_literal#Right AST#expression#Right . tabBar 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 . TabBuilder AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAB_INDEX_3 AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.profileIconNormal' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.profileIconSelected' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.my' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#property_assignment#Right AST#object_literal#Right AST#expression#Right . onChange 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 index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentIndex AST#member_expression#Right = AST#expression#Left index 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 this AST#expression#Right . currentIndex AST#member_expression#Right AST#expression#Right === AST#expression#Left TAB_INDEX_0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . message AST#member_expression#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.chat' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else 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 . currentIndex AST#member_expression#Right AST#expression#Right === AST#expression#Left TAB_INDEX_1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . message AST#member_expression#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.contacts' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else 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 . currentIndex AST#member_expression#Right AST#expression#Right === AST#expression#Left TAB_INDEX_2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . message AST#member_expression#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.discovery' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else 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 . currentIndex AST#member_expression#Right AST#expression#Right === AST#expression#Left TAB_INDEX_3 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 . message AST#member_expression#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.my' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . barWidth AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.layout_100' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . barHeight AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.tabbar_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . backgroundColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.tabbar_background' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
TabBuilder(index: number, imageNormal: Resource, imageSelected: Resource, text: Resource) {
Column() {
Divider()
.vertical(false)
.strokeWidth(DIVIDER_LINE_STROKWIDTH)
.color($r('app.color.tab_bar_separator_line_color'))
.opacity(TABBAR_SEPARATE_LINE)
Image(this.currentIndex === index ? imageSelected : imageNormal)
.syncLoad(true)
.width($r('app.integer.tabbar_image_width'))
.height($r('app.integer.tabbar_image_height'))
.margin($r('app.integer.tabbar_image_margin'))
.objectFit(ImageFit.Contain)
Text(text)
.fontSize($r('app.integer.tabbar_item_font_size'))
.fontColor(this.currentIndex === index ?
$r('app.color.tabbar_font_color_selected') : $r('app.color.tabbar_font_color_normal'));
}
.height($r('app.string.layout_100'))
.width($r('app.string.layout_100'))
}
build() {
Tabs({ barPosition: BarPosition.End, controller: this.controller, index: this.currentIndex }) {
TabContent() {
Column() {
TopBar()
ChatListDisplayView()
}
}
.tabBar(this.TabBuilder(TAB_INDEX_0,
$r('app.media.chatIconNormal'),
$r('app.media.chatIconSelected'),
$r('app.string.chat')));
TabContent() {
FriendsPage()
}
.tabBar(this.TabBuilder(TAB_INDEX_1,
$r('app.media.contactIconNormal'),
$r('app.media.contactIconSelected'),
$r('app.string.contacts')));
TabContent() {
DiscoverPage()
}
.tabBar(this.TabBuilder(TAB_INDEX_2,
$r('app.media.findIconNormal'),
$r('app.media.findIconSelected'),
$r('app.string.discovery')));
TabContent() {
SettingPage()
}
.tabBar(this.TabBuilder(TAB_INDEX_3,
$r('app.media.profileIconNormal'),
$r('app.media.profileIconSelected'),
$r('app.string.my')));
}
.onChange((index: number) => {
this.currentIndex = index;
if (this.currentIndex === TAB_INDEX_0) {
this.message = $r('app.string.chat');
} else if (this.currentIndex === TAB_INDEX_1) {
this.message = $r('app.string.contacts');
} else if (this.currentIndex === TAB_INDEX_2) {
this.message = $r('app.string.discovery');
} else if (this.currentIndex === TAB_INDEX_3) {
this.message = $r('app.string.my');
}
})
.barWidth($r('app.string.layout_100'))
.barHeight($r('app.integer.tabbar_height'))
.backgroundColor($r('app.color.tabbar_background'))
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Solutions/IM/Chat/products/phone/entry/src/main/ets/pages/Index.ets#L39-L115
|
13e206455778a32f9fbccd8c5afde7ee7ffdb602
|
gitee
|
WinWang/HarmoneyOpenEye.git
|
57f0542795336009aa0d46fd9fa5b07facc2ae87
|
entry/src/main/ets/utils/StorageUtils.ets
|
arkts
|
getPreferences
|
获取Prefer实例
@param preferenceName
@returns
|
static async getPreferences(preferenceName: string = defaultPreferenceName) {
return await dataPreferences.getPreferences(this.context, preferenceName)
}
|
AST#method_declaration#Left static async getPreferences AST#parameter_list#Left ( AST#parameter#Left preferenceName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left defaultPreferenceName AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left dataPreferences AST#expression#Right AST#await_expression#Right AST#expression#Right . getPreferences AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right AST#expression#Right , AST#expression#Left preferenceName AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static async getPreferences(preferenceName: string = defaultPreferenceName) {
return await dataPreferences.getPreferences(this.context, preferenceName)
}
|
https://github.com/WinWang/HarmoneyOpenEye.git/blob/57f0542795336009aa0d46fd9fa5b07facc2ae87/entry/src/main/ets/utils/StorageUtils.ets#L21-L23
|
2b6a688e0a20ba20cf41519a7381e758f3a36522
|
github
|
Joker-x-dev/HarmonyKit.git
|
f97197ce157df7f303244fba42e34918306dfb08
|
core/util/src/main/ets/toast/ToastUtils.ets
|
arkts
|
@file Toast 工具类,封装 IBestToast 常用能力
@author Joker.X
|
export class ToastUtils {
/**
* 显示普通 Toast
* @param {string | ResourceStr} message - 提示内容
* @returns {void} 无返回值
*/
static show(message: string | ResourceStr): void {
IBestToast.show(message);
}
/**
* 显示成功提示
* @param {string | ResourceStr} message - 提示内容
* @returns {void} 无返回值
*/
static showSuccess(message: string | ResourceStr): void {
IBestToast.show({
type: "success",
message: message
});
}
/**
* 显示失败提示
* @param {string | ResourceStr} message - 提示内容
* @returns {void} 无返回值
*/
static showError(message: string | ResourceStr): void {
IBestToast.show({
type: "fail",
message: message
});
}
/**
* 显示警告提示
* @param {string | ResourceStr} message - 提示内容
* @returns {void} 无返回值
*/
static showWarning(message: string | ResourceStr): void {
IBestToast.show({
type: "warning",
message: message
});
}
/**
* 显示加载中提示
* @returns {void} 无返回值
*/
static showLoading(): void {
IBestToast.showLoading();
}
/**
* 显示 Spinner 加载提示
* @param {string | ResourceStr} message - 提示内容
* @returns {void} 无返回值
*/
static showSpinnerLoading(message: string | ResourceStr): void {
IBestToast.show({
type: "loading",
loadingType: "spinner",
message: message
});
}
/**
* 显示带图标的 Toast
* @param {string | ResourceStr} message - 提示内容
* @param {Resource | string} icon - 图标资源或网络地址
* @returns {void} 无返回值
*/
static showIcon(message: string | ResourceStr, icon: Resource | string): void {
IBestToast.show({
icon: icon,
iconWidth: 50,
message: message
});
}
/**
* 显示顶部 Toast
* @param {string | ResourceStr} message - 提示内容
* @returns {void} 无返回值
*/
static showTop(message: string | ResourceStr): void {
IBestToast.show({
position: "top",
offsetY: "20%",
message: message
});
}
/**
* 显示底部 Toast
* @param {string | ResourceStr} message - 提示内容
* @returns {void} 无返回值
*/
static showBottom(message: string | ResourceStr): void {
IBestToast.show({
position: "bottom",
offsetY: "-20%",
message: message
});
}
/**
* 显示强制截断换行 Toast
* @param {string | ResourceStr} message - 提示内容
* @returns {void} 无返回值
*/
static showBreakAll(message: string | ResourceStr): void {
IBestToast.show({
wordBreak: "break-all",
message: message
});
}
/**
* 显示按词换行 Toast
* @param {ResourceStr} message - 提示内容
* @returns {void} 无返回值
*/
static showBreakWord(message: string | ResourceStr): void {
IBestToast.show({
wordBreak: "break-word",
message: message
});
}
/**
* 隐藏 Toast
* @returns {void} 无返回值
*/
static hide(): void {
IBestToast.hide();
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class ToastUtils AST#class_body#Left { /**
* 显示普通 Toast
* @param {string | ResourceStr} message - 提示内容
* @returns {void} 无返回值
*/ AST#method_declaration#Left static show AST#parameter_list#Left ( AST#parameter#Left message : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left ResourceStr AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left IBestToast AST#expression#Right . show AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left message AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* 显示成功提示
* @param {string | ResourceStr} message - 提示内容
* @returns {void} 无返回值
*/ AST#method_declaration#Left static showSuccess AST#parameter_list#Left ( AST#parameter#Left message : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left ResourceStr AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left IBestToast AST#expression#Right . show AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left "success" AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left message AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* 显示失败提示
* @param {string | ResourceStr} message - 提示内容
* @returns {void} 无返回值
*/ AST#method_declaration#Left static showError AST#parameter_list#Left ( AST#parameter#Left message : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left ResourceStr AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left IBestToast AST#expression#Right . show AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left "fail" AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left message AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* 显示警告提示
* @param {string | ResourceStr} message - 提示内容
* @returns {void} 无返回值
*/ AST#method_declaration#Left static showWarning AST#parameter_list#Left ( AST#parameter#Left message : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left ResourceStr AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left IBestToast AST#expression#Right . show AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left "warning" AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left message AST#expression#Right AST#property_assignment#Right } AST#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 /**
* 显示加载中提示
* @returns {void} 无返回值
*/ AST#method_declaration#Left static showLoading 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 IBestToast AST#expression#Right . showLoading AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* 显示 Spinner 加载提示
* @param {string | ResourceStr} message - 提示内容
* @returns {void} 无返回值
*/ AST#method_declaration#Left static showSpinnerLoading AST#parameter_list#Left ( AST#parameter#Left message : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left ResourceStr AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left IBestToast AST#expression#Right . show AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left "loading" AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left loadingType AST#property_name#Right : AST#expression#Left "spinner" AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left message AST#expression#Right AST#property_assignment#Right } AST#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 /**
* 显示带图标的 Toast
* @param {string | ResourceStr} message - 提示内容
* @param {Resource | string} icon - 图标资源或网络地址
* @returns {void} 无返回值
*/ AST#method_declaration#Left static showIcon AST#parameter_list#Left ( AST#parameter#Left message : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left ResourceStr AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left icon : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Resource AST#primary_type#Right | AST#primary_type#Left string AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left IBestToast AST#expression#Right . show AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left icon AST#property_name#Right : AST#expression#Left icon AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left iconWidth AST#property_name#Right : AST#expression#Left 50 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left message AST#expression#Right AST#property_assignment#Right } AST#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 /**
* 显示顶部 Toast
* @param {string | ResourceStr} message - 提示内容
* @returns {void} 无返回值
*/ AST#method_declaration#Left static showTop AST#parameter_list#Left ( AST#parameter#Left message : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left ResourceStr AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left IBestToast AST#expression#Right . show AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left position AST#property_name#Right : AST#expression#Left "top" AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetY AST#property_name#Right : AST#expression#Left "20%" AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left message AST#expression#Right AST#property_assignment#Right } AST#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 /**
* 显示底部 Toast
* @param {string | ResourceStr} message - 提示内容
* @returns {void} 无返回值
*/ AST#method_declaration#Left static showBottom AST#parameter_list#Left ( AST#parameter#Left message : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left ResourceStr AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left IBestToast AST#expression#Right . show AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left position AST#property_name#Right : AST#expression#Left "bottom" AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetY AST#property_name#Right : AST#expression#Left "-20%" AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left message AST#expression#Right AST#property_assignment#Right } AST#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 /**
* 显示强制截断换行 Toast
* @param {string | ResourceStr} message - 提示内容
* @returns {void} 无返回值
*/ AST#method_declaration#Left static showBreakAll AST#parameter_list#Left ( AST#parameter#Left message : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left ResourceStr AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left IBestToast AST#expression#Right . show AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left wordBreak AST#property_name#Right : AST#expression#Left "break-all" AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left message AST#expression#Right AST#property_assignment#Right } AST#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 /**
* 显示按词换行 Toast
* @param {ResourceStr} message - 提示内容
* @returns {void} 无返回值
*/ AST#method_declaration#Left static showBreakWord AST#parameter_list#Left ( AST#parameter#Left message : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left ResourceStr AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left IBestToast AST#expression#Right . show AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left wordBreak AST#property_name#Right : AST#expression#Left "break-word" AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left message AST#expression#Right AST#property_assignment#Right } AST#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 /**
* 隐藏 Toast
* @returns {void} 无返回值
*/ AST#method_declaration#Left static hide 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 IBestToast AST#expression#Right . hide AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class ToastUtils {
static show(message: string | ResourceStr): void {
IBestToast.show(message);
}
static showSuccess(message: string | ResourceStr): void {
IBestToast.show({
type: "success",
message: message
});
}
static showError(message: string | ResourceStr): void {
IBestToast.show({
type: "fail",
message: message
});
}
static showWarning(message: string | ResourceStr): void {
IBestToast.show({
type: "warning",
message: message
});
}
static showLoading(): void {
IBestToast.showLoading();
}
static showSpinnerLoading(message: string | ResourceStr): void {
IBestToast.show({
type: "loading",
loadingType: "spinner",
message: message
});
}
static showIcon(message: string | ResourceStr, icon: Resource | string): void {
IBestToast.show({
icon: icon,
iconWidth: 50,
message: message
});
}
static showTop(message: string | ResourceStr): void {
IBestToast.show({
position: "top",
offsetY: "20%",
message: message
});
}
static showBottom(message: string | ResourceStr): void {
IBestToast.show({
position: "bottom",
offsetY: "-20%",
message: message
});
}
static showBreakAll(message: string | ResourceStr): void {
IBestToast.show({
wordBreak: "break-all",
message: message
});
}
static showBreakWord(message: string | ResourceStr): void {
IBestToast.show({
wordBreak: "break-word",
message: message
});
}
static hide(): void {
IBestToast.hide();
}
}
|
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/util/src/main/ets/toast/ToastUtils.ets#L7-L145
|
e8dea7167d4519bc54ded728793205a8257d4fa6
|
github
|
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
ef_ui/src/main/ets/ui/base/ButtonUtil.ets
|
arkts
|
ButtonUtil
|
@Author csx
@DateTime 2024/7/2 16:24:07
@TODO ButtonUtil 场景化按钮工具类
@Use 详细使用方法以及文档详见ohpm官网,地址https://ohpm.openharmony.cn/#/cn/detail/@yunkss%2Fef_ui
|
@Component
export struct ButtonUtil {
/**
* 场景按钮入参实体
*/
@Prop btnOptions: BtnOptions = new BtnOptions();
build() {
FunctionalButtonBuilder.builder({
openType: this.btnOptions.type,
label: this.btnOptions.label,
styleOption: {
//按钮镂空
plain: true
},
appParam: this.btnOptions.appParams
}, (data) => {
ToastUtil.showToast(data);
});
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ButtonUtil AST#component_body#Left { /**
* 场景按钮入参实体
*/ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right btnOptions : AST#type_annotation#Left AST#primary_type#Left BtnOptions 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 BtnOptions AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FunctionalButtonBuilder AST#expression#Right . builder 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 openType AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . btnOptions AST#member_expression#Right AST#expression#Right . type AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left label AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . btnOptions AST#member_expression#Right AST#expression#Right . label AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left styleOption AST#property_name#Right : AST#expression#Left AST#object_literal#Left { //按钮镂空 AST#property_assignment#Left AST#property_name#Left plain AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left appParam AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . btnOptions AST#member_expression#Right AST#expression#Right . appParams AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left data AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ToastUtil AST#expression#Right . showToast 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#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#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct ButtonUtil {
@Prop btnOptions: BtnOptions = new BtnOptions();
build() {
FunctionalButtonBuilder.builder({
openType: this.btnOptions.type,
label: this.btnOptions.label,
styleOption: {
plain: true
},
appParam: this.btnOptions.appParams
}, (data) => {
ToastUtil.showToast(data);
});
}
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_ui/src/main/ets/ui/base/ButtonUtil.ets#L204-L224
|
e00217f09eb434579b60db1b82c884e26d18181e
|
gitee
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
ef_ui/src/main/ets/ui/base/ImmersionUtil.ets
|
arkts
|
getBoundingRectPosition
|
TODO 知识点:通过获取到的屏幕属性和屏幕不可用区域来判断不可用区域位置
1.getCutoutInfo接口获取到不可用区域的左边界、上边界、宽度、高度。
2.不可用区域左边宽度即为左边界的值。
3.不可用区域右边界宽度等于屏幕宽度减去不可用区域宽度和左边界。
4.获取到不可用区域到左右屏幕边缘的宽度进行对比判断出不可用区域位置。
5.不可用区域位于中间时,不同设备左右距离可能存在小于10的差值,判断是否在中间取去左右距离差值的绝对值进行判断。
@returns left:左偏移量 right:右偏移量
|
getBoundingRectPosition(): TextMargin {
if (this.boundingRect !== null && this.displayClass !== null && this.boundingRect[0] !== undefined) {
// 不可用区域右侧到屏幕右边界的距离:屏幕宽度减去左侧宽度和不可用区域宽度
const boundingRectRight: number =
this.displayClass.width - (this.boundingRect[0].left + this.boundingRect[0].width);
// 不可用区域左侧到屏幕左边界的距离:getCutoutInfo接口可以直接获取
const boundingRectLeft: number = this.boundingRect[0].left;
// 部分设备不可用区域在中间时存在左右距离会有10像素以内的差距,获取到的左右距离差值绝对值小于10都按照不可用区域位于中间处理
if (Math.abs(boundingRectLeft - boundingRectRight) <= 10) {
return { left: 0, right: 0 };
}
if (boundingRectLeft > boundingRectRight) {
// 不可用区域在右边
return { left: 0, right: this.displayClass.width - boundingRectLeft };
} else if (boundingRectLeft < boundingRectRight) {
// 不可用区域在左边
return { left: this.boundingRect[0].left + this.boundingRect[0].width, right: 0 };
}
}
return { left: 0, right: 0 };
}
|
AST#method_declaration#Left getBoundingRectPosition AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left TextMargin 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#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . boundingRect 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#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . displayClass 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#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . boundingRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_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#variable_declaration#Left const AST#variable_declarator#Left boundingRectRight : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . displayClass AST#member_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right - AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . boundingRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right 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 . boundingRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 不可用区域左侧到屏幕左边界的距离:getCutoutInfo接口可以直接获取 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left boundingRectLeft : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . boundingRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . left AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 部分设备不可用区域在中间时存在左右距离会有10像素以内的差距,获取到的左右距离差值绝对值小于10都按照不可用区域位于中间处理 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . abs AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left boundingRectLeft AST#expression#Right - AST#expression#Left boundingRectRight AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right <= AST#expression#Left 10 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left boundingRectLeft AST#expression#Right > AST#expression#Left boundingRectRight 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . displayClass AST#member_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right - AST#expression#Left boundingRectLeft AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left boundingRectLeft AST#expression#Right < AST#expression#Left boundingRectRight 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_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#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . boundingRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right 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 . boundingRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
getBoundingRectPosition(): TextMargin {
if (this.boundingRect !== null && this.displayClass !== null && this.boundingRect[0] !== undefined) {
const boundingRectRight: number =
this.displayClass.width - (this.boundingRect[0].left + this.boundingRect[0].width);
const boundingRectLeft: number = this.boundingRect[0].left;
if (Math.abs(boundingRectLeft - boundingRectRight) <= 10) {
return { left: 0, right: 0 };
}
if (boundingRectLeft > boundingRectRight) {
return { left: 0, right: this.displayClass.width - boundingRectLeft };
} else if (boundingRectLeft < boundingRectRight) {
return { left: this.boundingRect[0].left + this.boundingRect[0].width, right: 0 };
}
}
return { left: 0, right: 0 };
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_ui/src/main/ets/ui/base/ImmersionUtil.ets#L108-L128
|
06ba20ac7d1f744b715d67e6d6c3bee2777eac98
|
gitee
|
iichen-bycode/ArkTsWanandroid.git
|
ad128756a6c703d9a72cf7f6da128c27fc63bd00
|
entry/src/main/ets/http/api.ets
|
arkts
|
取消收藏列表文章
@param date
@returns
|
export function unCollectListArticle(id: number,originId:number) {
return axiosClient.post<any>({
url: `lg/uncollect/${id}/json`,
params: {
originId:originId || -1
},
checkResultCode: true,
checkLoginState: true,
needJumpToLogin: true
})
}
|
AST#export_declaration#Left export AST#function_declaration#Left function unCollectListArticle AST#parameter_list#Left ( AST#parameter#Left id : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left originId : 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left axiosClient AST#expression#Right . post AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left any AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` lg/uncollect/ AST#template_substitution#Left $ { AST#expression#Left id AST#expression#Right } AST#template_substitution#Right /json ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left params AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left originId AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left originId AST#expression#Right || AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left checkResultCode AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left checkLoginState AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left needJumpToLogin AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export function unCollectListArticle(id: number,originId:number) {
return axiosClient.post<any>({
url: `lg/uncollect/${id}/json`,
params: {
originId:originId || -1
},
checkResultCode: true,
checkLoginState: true,
needJumpToLogin: true
})
}
|
https://github.com/iichen-bycode/ArkTsWanandroid.git/blob/ad128756a6c703d9a72cf7f6da128c27fc63bd00/entry/src/main/ets/http/api.ets#L93-L103
|
1afb73bbfda06b1e1b0a250b75db791687e81291
|
github
|
|
zqaini002/YaoYaoLingXian.git
|
5095b12cbeea524a87c42d0824b1702978843d39
|
YaoYaoLingXian/entry/src/main/ets/pages/dream/DreamEditPage.ets
|
arkts
|
getFileIdFromUri
|
从URI中获取文件ID - 修正正则表达式以正确提取ID
|
private getFileIdFromUri(uri: string): string | null {
try {
// 匹配形如 file://media/Photo/1/IMG_1747504493_000/xxx.png 的URI
const regex = /file:\/\/media\/Photo\/(\d+)\/([^\/]+)/;
const match = uri.match(regex);
if (match && match.length >= 2) {
return match[1]; // 返回ID部分 (1)
}
return null;
} catch (error) {
const errorMsg: string = error instanceof Error ? error.message : String(error);
console.error(`解析URI失败: ${errorMsg}`);
return null;
}
}
|
AST#method_declaration#Left private getFileIdFromUri AST#parameter_list#Left ( AST#parameter#Left uri : 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#try_statement#Left try AST#block_statement#Left { // 匹配形如 file://media/Photo/1/IMG_1747504493_000/xxx.png 的URI AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left regex = 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#expression#Right / AST#expression#Left file AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#ERROR#Left : \ / \ AST#ERROR#Right / AST#expression#Left media AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#ERROR#Left \ AST#ERROR#Right / AST#expression#Left Photo AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right AST#ERROR#Left \ / AST#parameter_list#Left ( AST#ERROR#Left \d + AST#ERROR#Right ) AST#parameter_list#Right \ / ( [ ^ \ / AST#ERROR#Left ] AST#ERROR#Right + ) / AST#ERROR#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left match = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left uri 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#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 match AST#expression#Right && AST#expression#Left match AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right >= AST#expression#Left 2 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#subscript_expression#Left AST#expression#Left match AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right // 返回ID部分 (1) } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left errorMsg : 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#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#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 ` 解析URI失败: AST#template_substitution#Left $ { AST#expression#Left errorMsg AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private getFileIdFromUri(uri: string): string | null {
try {
const regex = /file:\/\/media\/Photo\/(\d+)\/([^\/]+)/;
const match = uri.match(regex);
if (match && match.length >= 2) {
return match[1];
}
return null;
} catch (error) {
const errorMsg: string = error instanceof Error ? error.message : String(error);
console.error(`解析URI失败: ${errorMsg}`);
return null;
}
}
|
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/pages/dream/DreamEditPage.ets#L848-L862
|
f08b114b3c244ad16bd6510affb42225099d47e3
|
github
|
Joker-x-dev/CoolMallArkTS.git
|
9f3fabf89fb277692cb82daf734c220c7282919c
|
feature/common/src/main/ets/view/WebPage.ets
|
arkts
|
WebPage
|
@file 网页页面视图
@author Joker.X
|
@ComponentV2
export struct WebPage {
/**
* 网页页面 ViewModel
*/
@Local
private vm: WebViewModel = new WebViewModel();
/**
* 构建网页页面
* @returns {void} 无返回值
*/
build() {
AppNavDestination({
title: "网页",
viewModel: this.vm
}) {
this.WebContent();
}
}
/**
* 网页页面内容视图
* @returns {void} 无返回值
*/
@Builder
private WebContent() {
Text("网页页面内容视图")
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ ComponentV2 AST#decorator#Right export struct WebPage AST#component_body#Left { /**
* 网页页面 ViewModel
*/ AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right private vm : AST#type_annotation#Left AST#primary_type#Left WebViewModel 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 WebViewModel AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right /**
* 构建网页页面
* @returns {void} 无返回值
*/ AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left AppNavDestination ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left "网页" AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left viewModel : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . WebContent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right /**
* 网页页面内容视图
* @returns {void} 无返回值
*/ AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right private WebContent AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left "网页页面内容视图" AST#expression#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@ComponentV2
export struct WebPage {
@Local
private vm: WebViewModel = new WebViewModel();
build() {
AppNavDestination({
title: "网页",
viewModel: this.vm
}) {
this.WebContent();
}
}
@Builder
private WebContent() {
Text("网页页面内容视图")
}
}
|
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/common/src/main/ets/view/WebPage.ets#L8-L37
|
44431be8660a45a7a043d6fe12c56019d2f177c4
|
github
|
2763981847/Clock-Alarm.git
|
8949bedddb7d011021848196735f30ffe2bd1daf
|
entry/src/main/ets/common/util/DimensionUtils.ets
|
arkts
|
getVp
|
获取屏幕水平适配 vp 值。
@param value 资源值
@return 适配后的 vp 值
|
static getVp(value: Resource): number {
let beforeVp = context.resourceManager.getNumber(value.id);
return px2vp(DimensionUtil.adaptDimension(beforeVp));
}
|
AST#method_declaration#Left static getVp AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left beforeVp = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . resourceManager AST#member_expression#Right AST#expression#Right . getNumber AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left value AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left px2vp AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DimensionUtil AST#expression#Right . adaptDimension AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left beforeVp AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static getVp(value: Resource): number {
let beforeVp = context.resourceManager.getNumber(value.id);
return px2vp(DimensionUtil.adaptDimension(beforeVp));
}
|
https://github.com/2763981847/Clock-Alarm.git/blob/8949bedddb7d011021848196735f30ffe2bd1daf/entry/src/main/ets/common/util/DimensionUtils.ets#L52-L55
|
b43479a5bd17023bb40fdb4a8f5aecf99389205c
|
github
|
vhall/VHLive_SDK_Harmony
|
29c820e5301e17ae01bc6bdcc393a4437b518e7c
|
watchKit/src/main/ets/builder/PlayerSettingBuilder.ets
|
arkts
|
createDivider
|
创建特定样式的分隔线
|
@Builder
createDivider() {
Divider()
.vertical(false)
.strokeWidth(0.5)
.color(0xE0E0E0)
.width('80%')
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right createDivider 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 Divider ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . vertical ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . strokeWidth ( AST#expression#Left 0.5 AST#expression#Right ) AST#modifier_chain_expression#Left . color ( AST#expression#Left 0xE0E0E0 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '80%' 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
createDivider() {
Divider()
.vertical(false)
.strokeWidth(0.5)
.color(0xE0E0E0)
.width('80%')
}
|
https://github.com/vhall/VHLive_SDK_Harmony/blob/29c820e5301e17ae01bc6bdcc393a4437b518e7c/watchKit/src/main/ets/builder/PlayerSettingBuilder.ets#L109-L116
|
f66db7b815e65aa624ef16f14e65455bcb648ed1
|
gitee
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/advertisingpage/src/main/ets/components/AdvertisingPage.ets
|
arkts
|
AdvertisingPageComponent
|
按键靠近右侧屏幕距离
功能描述:本示例介绍了如何实现全屏启动页
推荐场景:应用冷启动广告页
核心组件:
1.changeFullScreen
2.timerInterval
实现步骤:
1.通过window.getLastWindow在页面启动时实现沉浸式布局。
2.通过定时器设置自动进入页面时长,也可手动跳过进入页面。
|
@Component
export struct AdvertisingPageComponent {
@State pageCountDown: number = 6; // 进场动画总用时6s
@StorageProp('windowSize') windowSize: window.Size = {
width: display.getDefaultDisplaySync().width,
height: display.getDefaultDisplaySync().height
};
@Link isShow: boolean;
private timer: number = 0;
/**
* 页面显示打开沉浸式,页面销毁关闭
* @param isFull是否需要打开沉浸式
*/
changeFullScreen(isFull: boolean) {
let context = getContext();
window.getLastWindow(context, (err, window) => {
window.setWindowLayoutFullScreen(isFull);
})
}
/**
* 控制页面显示倒计时
*/
timerInterval() {
this.timer = setInterval(() => {
this.pageCountDown--;
if (this.pageCountDown === 0) {
this.changeFullScreen(false);
clearInterval(this.timer);
this.isShow = false;
}
}, 1000)
}
aboutToAppear(): void {
this.changeFullScreen(true);
this.timerInterval();
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) {
// 广告页动图和描述
Column() {
Row() {
Image($r('app.media.enter_app_animation'))
.objectFit(ImageFit.Contain)
.width('100%')
.aspectRatio(1.4)
}
.margin({ top: $r('app.integer.advertising_page_gif_margin') })
Column() {
Text($r('app.string.advertising_page'))
.fontSize($r('app.integer.advertising_page_font_size'))
Text($r('app.string.advertising_description'))
.margin({ top: $r('app.integer.advertising_description_text_margin') })
.fontSize($r('app.integer.advertising_description_font_size'))
.opacity(0.6)
}
.margin({ top: $r('app.integer.advertising_description_margin') })
}
.width('100%')
// 跳过按钮和倒计时
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Text($r('app.string.skip'))
.fontSize($r('app.integer.advertising_description_skip_font_size'))
.textAlign(TextAlign.Center)
.fontColor(Color.White)
Text(`${this.pageCountDown}`)
.fontSize($r('app.integer.advertising_description_skip_font_size'))
.textAlign(TextAlign.Center)
.fontColor(Color.White)
.margin({ left: $r('app.integer.advertising_description_pageCountDown_margin') })
}
.position({
x: px2vp(this.windowSize.width - OFFSET_RIGHT_LEN),
y: $r('app.integer.advertising_description_skip_position_y')
})
.width($r('app.integer.advertising_description_skip_width'))
.aspectRatio(2.4)
.backgroundColor($r('app.string.advertising_description_backgroundColor'))
.borderRadius($r('app.integer.advertising_description_skip_borderRadius'))
.onClick(() => {
clearInterval(this.timer); // 手动跳过时关闭定时器
this.changeFullScreen(false);
this.pageCountDown = 0;
this.isShow = false;
})
}
.width('100%')
.backgroundColor($r('app.color.advertising_backgroundColor'))
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct AdvertisingPageComponent AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right pageCountDown : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 6 AST#expression#Right ; AST#property_declaration#Right // 进场动画总用时6s AST#property_declaration#Left AST#decorator#Left @ StorageProp ( AST#expression#Left 'windowSize' AST#expression#Right ) AST#decorator#Right windowSize : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Size AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#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#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Link AST#decorator#Right isShow : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left private timer : 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 /**
* 页面显示打开沉浸式,页面销毁关闭
* @param isFull是否需要打开沉浸式
*/ AST#method_declaration#Left changeFullScreen AST#parameter_list#Left ( AST#parameter#Left isFull : 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#variable_declaration#Left let AST#variable_declarator#Left context = AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( ) AST#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 window AST#expression#Right . getLastWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right , AST#parameter#Left window 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 window AST#expression#Right . setWindowLayoutFullScreen AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left isFull AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 控制页面显示倒计时
*/ AST#method_declaration#Left timerInterval AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . timer AST#member_expression#Right = 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#update_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . pageCountDown AST#member_expression#Right AST#expression#Right -- AST#update_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 this AST#expression#Right . pageCountDown AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . changeFullScreen AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . timer 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 this AST#expression#Right . isShow AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right , AST#expression#Left 1000 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . changeFullScreen 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . timerInterval AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Flex ( AST#component_parameters#Left { AST#component_parameter#Left direction : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexDirection AST#expression#Right . Column AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left alignItems : AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { // 广告页动图和描述 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.enter_app_animation' AST#expression#Right ) AST#resource_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 . Contain 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 . aspectRatio ( AST#expression#Left 1.4 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 . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.advertising_page_gif_margin' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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.advertising_page' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.advertising_page_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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.advertising_description' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.advertising_description_text_margin' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.advertising_description_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left 0.6 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.advertising_description_margin' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#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 Flex ( AST#component_parameters#Left { AST#component_parameter#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#component_parameter#Right , AST#component_parameter#Left alignItems : AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.skip' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.advertising_description_skip_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#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 this AST#expression#Right . pageCountDown 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 AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.advertising_description_skip_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.advertising_description_pageCountDown_margin' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 . position ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left px2vp AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . windowSize AST#member_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right - AST#expression#Left OFFSET_RIGHT_LEN AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.advertising_description_skip_position_y' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.advertising_description_skip_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . aspectRatio ( AST#expression#Left 2.4 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.advertising_description_backgroundColor' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.advertising_description_skip_borderRadius' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left clearInterval AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . timer AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 手动跳过时关闭定时器 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . changeFullScreen AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; 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 . pageCountDown 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 . isShow AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.advertising_backgroundColor' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct AdvertisingPageComponent {
@State pageCountDown: number = 6;
@StorageProp('windowSize') windowSize: window.Size = {
width: display.getDefaultDisplaySync().width,
height: display.getDefaultDisplaySync().height
};
@Link isShow: boolean;
private timer: number = 0;
changeFullScreen(isFull: boolean) {
let context = getContext();
window.getLastWindow(context, (err, window) => {
window.setWindowLayoutFullScreen(isFull);
})
}
timerInterval() {
this.timer = setInterval(() => {
this.pageCountDown--;
if (this.pageCountDown === 0) {
this.changeFullScreen(false);
clearInterval(this.timer);
this.isShow = false;
}
}, 1000)
}
aboutToAppear(): void {
this.changeFullScreen(true);
this.timerInterval();
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) {
Column() {
Row() {
Image($r('app.media.enter_app_animation'))
.objectFit(ImageFit.Contain)
.width('100%')
.aspectRatio(1.4)
}
.margin({ top: $r('app.integer.advertising_page_gif_margin') })
Column() {
Text($r('app.string.advertising_page'))
.fontSize($r('app.integer.advertising_page_font_size'))
Text($r('app.string.advertising_description'))
.margin({ top: $r('app.integer.advertising_description_text_margin') })
.fontSize($r('app.integer.advertising_description_font_size'))
.opacity(0.6)
}
.margin({ top: $r('app.integer.advertising_description_margin') })
}
.width('100%')
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Text($r('app.string.skip'))
.fontSize($r('app.integer.advertising_description_skip_font_size'))
.textAlign(TextAlign.Center)
.fontColor(Color.White)
Text(`${this.pageCountDown}`)
.fontSize($r('app.integer.advertising_description_skip_font_size'))
.textAlign(TextAlign.Center)
.fontColor(Color.White)
.margin({ left: $r('app.integer.advertising_description_pageCountDown_margin') })
}
.position({
x: px2vp(this.windowSize.width - OFFSET_RIGHT_LEN),
y: $r('app.integer.advertising_description_skip_position_y')
})
.width($r('app.integer.advertising_description_skip_width'))
.aspectRatio(2.4)
.backgroundColor($r('app.string.advertising_description_backgroundColor'))
.borderRadius($r('app.integer.advertising_description_skip_borderRadius'))
.onClick(() => {
clearInterval(this.timer);
this.changeFullScreen(false);
this.pageCountDown = 0;
this.isShow = false;
})
}
.width('100%')
.backgroundColor($r('app.color.advertising_backgroundColor'))
}
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/advertisingpage/src/main/ets/components/AdvertisingPage.ets#L35-L129
|
3bf36e44baa8a1bf038db4858586964e9dbcdfe6
|
gitee
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/models/managers/onlinesearch/OnlineWordManager.ets
|
arkts
|
loadWord
|
/ 查询单词详情
|
loadWord(titleEn: string, completion: (success: boolean, msg: string | null, word: OnlineWord | null) => void): void {
const params: HttpUtils.HttpParams = {}
params[CodingKeys.TitleEn] = titleEn
const isCurCnt = LanguageManager.isTraditionalChinese()
const subRoute = isCurCnt ? "word_cnt" : "word_cns"
const url = `${Servers.getRouteUrl(Route.word)}/${subRoute}`
Http.request(url, HttpUtils.Method.GET, params, (succeed: boolean, msg: string | null, result: Object[] | null) => {
if (!succeed || !result) {
completion(false, msg, null)
return
}
try {
// 解析JSON数据
const list = OnlineWord.fromArray(result)
// 返回第一条数据
completion(true, msg, list.length > 0 ? list[0] : null)
} catch (error) {
completion(false, `JSON解析失败: ${error}`, null)
}
})
}
|
AST#method_declaration#Left loadWord AST#parameter_list#Left ( AST#parameter#Left titleEn : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left completion : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left success : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left msg : 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#parameter#Right , AST#parameter#Left word : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left OnlineWord AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left 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 void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left params : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left HttpUtils . HttpParams AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#ERROR#Left params AST#ERROR#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left CodingKeys AST#expression#Right . TitleEn AST#member_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Right = AST#expression#Left titleEn 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 isCurCnt = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LanguageManager AST#expression#Right . isTraditionalChinese 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 subRoute = AST#expression#Left AST#conditional_expression#Left AST#expression#Left isCurCnt AST#expression#Right ? AST#expression#Left "word_cnt" AST#expression#Right : AST#expression#Left "word_cns" AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left url = 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 Servers AST#expression#Right . getRouteUrl AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Route AST#expression#Right . word AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right / AST#template_substitution#Left $ { AST#expression#Left subRoute AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#ERROR#Left Http AST#ERROR#Right . request AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left url AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left HttpUtils AST#expression#Right . Method AST#member_expression#Right AST#expression#Right . GET AST#member_expression#Right AST#expression#Right , AST#expression#Left params AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left succeed : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left msg : 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#parameter#Right , AST#parameter#Left result : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#array_type#Left Object [ ] AST#array_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#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#unary_expression#Left ! AST#expression#Left succeed AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left AST#unary_expression#Left ! AST#expression#Left result AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left completion AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right , AST#expression#Left msg AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#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 { // 解析JSON数据 AST#ERROR#Left const AST#variable_declarator#Left list = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left OnlineWord AST#expression#Right . fromArray AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left result AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right // 返回第一条数据 comp AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left letion AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right , AST#expression#Left msg AST#expression#Right , AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left list 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#Left AST#subscript_expression#Left AST#expression#Left list 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#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left completion AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` JSON解析失败: AST#template_substitution#Left $ { AST#expression#Left error AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_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#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
loadWord(titleEn: string, completion: (success: boolean, msg: string | null, word: OnlineWord | null) => void): void {
const params: HttpUtils.HttpParams = {}
params[CodingKeys.TitleEn] = titleEn
const isCurCnt = LanguageManager.isTraditionalChinese()
const subRoute = isCurCnt ? "word_cnt" : "word_cns"
const url = `${Servers.getRouteUrl(Route.word)}/${subRoute}`
Http.request(url, HttpUtils.Method.GET, params, (succeed: boolean, msg: string | null, result: Object[] | null) => {
if (!succeed || !result) {
completion(false, msg, null)
return
}
try {
const list = OnlineWord.fromArray(result)
completion(true, msg, list.length > 0 ? list[0] : null)
} catch (error) {
completion(false, `JSON解析失败: ${error}`, null)
}
})
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/managers/onlinesearch/OnlineWordManager.ets#L24-L47
|
b9a43f238000cd60a74ca77c0018e01a313b7e29
|
github
|
fengcreate/harmony-document
|
798534b0f76399dc84e7940f5b14b3ae4e53c6a9
|
BackupRestore/entry/src/main/ets/restore/fileMigrate/FileTransferManager.ets
|
arkts
|
File migration and conversion management.
|
export default class FileTransferManager {
/**
* Move HarmonyOS 4.0 files to the designated location of HarmonyOS NEXT.
*
* @param context context.
*/
transfer(context: common.Context): void {
if (this.moveFiles(context)) {
hilog.info(0x0000, 'BackupRestore FileTransferManager', 'transfer success');
return;
}
hilog.error(0x0000, 'BackupRestore FileTransferManager', 'transfer fail');
}
/**
* Move files from the original backup and recovery path to the directory specified in the application's sandbox path.
*
* @param context context.
* @return success return true, failed return false.
*/
private moveFiles(context: common.Context): boolean {
try {
let cePathPrefix: string = '/data/storage/el2/backup/restore/com.example.backuprestore/ce';
let sourceFilePath: string = cePathPrefix + '/files/sourceFiles';
if (!fileIo.accessSync(sourceFilePath)) {
hilog.error(0x0000, 'BackupRestore FileTransferManager', `moveFiles, ${sourceFilePath} can't access`);
return false;
}
let listFileNames: string[] = fileIo.listFileSync(sourceFilePath);
if (!listFileNames || listFileNames.length === 0) {
hilog.error(0x0000, 'BackupRestore FileTransferManager', `moveFiles, ${sourceFilePath} is not file`);
return false;
}
let targetPath: string = context.filesDir + '/targetFiles';
if (!fileIo.accessSync(targetPath)) {
fileIo.mkdirSync(targetPath);
}
listFileNames.forEach((fileName: string) => {
let srcPath: string = `${sourceFilePath}/${fileName}`;
let destPath: string = `${targetPath}/${fileName}`;
if (fileIo.statSync(srcPath).isFile()) {
fileIo.moveFileSync(srcPath, destPath);
} else {
fileIo.moveDirSync(srcPath, targetPath);
}
});
return true;
} catch (error) {
hilog.error(0x0000, 'BackupRestore FileTransferManager', `moveFiles, error: ${JSON.stringify(error)}`);
return false;
}
}
}
|
AST#export_declaration#Left export default AST#class_declaration#Left class FileTransferManager AST#class_body#Left { /**
* Move HarmonyOS 4.0 files to the designated location of HarmonyOS NEXT.
*
* @param context context.
*/ AST#method_declaration#Left transfer AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . Context AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . moveFiles 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#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'BackupRestore FileTransferManager' AST#expression#Right , AST#expression#Left 'transfer success' 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 . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'BackupRestore FileTransferManager' AST#expression#Right , AST#expression#Left 'transfer fail' 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 /**
* Move files from the original backup and recovery path to the directory specified in the application's sandbox path.
*
* @param context context.
* @return success return true, failed return false.
*/ AST#method_declaration#Left private moveFiles AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . Context AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean 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 let AST#variable_declarator#Left cePathPrefix : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '/data/storage/el2/backup/restore/com.example.backuprestore/ce' 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 sourceFilePath : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left cePathPrefix AST#expression#Right + AST#expression#Left '/files/sourceFiles' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left fileIo 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 sourceFilePath 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 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 'BackupRestore FileTransferManager' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` moveFiles, AST#template_substitution#Left $ { AST#expression#Left sourceFilePath AST#expression#Right } AST#template_substitution#Right can't access ` 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 let AST#variable_declarator#Left listFileNames : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fileIo AST#expression#Right . listFileSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sourceFilePath AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left listFileNames AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left listFileNames 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#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 'BackupRestore FileTransferManager' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` moveFiles, AST#template_substitution#Left $ { AST#expression#Left sourceFilePath AST#expression#Right } AST#template_substitution#Right is not file ` 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 let AST#variable_declarator#Left targetPath : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . filesDir AST#member_expression#Right AST#expression#Right + AST#expression#Left '/targetFiles' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left fileIo 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 targetPath 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 fileIo AST#expression#Right . mkdirSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left targetPath 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 listFileNames AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left fileName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left srcPath : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left sourceFilePath AST#expression#Right } AST#template_substitution#Right / AST#template_substitution#Left $ { AST#expression#Left fileName AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left destPath : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left targetPath AST#expression#Right } AST#template_substitution#Right / AST#template_substitution#Left $ { AST#expression#Left fileName AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fileIo AST#expression#Right . statSync 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 . isFile 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fileIo AST#expression#Right . moveFileSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcPath AST#expression#Right , AST#expression#Left destPath AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fileIo AST#expression#Right . moveDirSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcPath AST#expression#Right , AST#expression#Left targetPath AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#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 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 'BackupRestore FileTransferManager' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` moveFiles, 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 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 } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export default class FileTransferManager {
transfer(context: common.Context): void {
if (this.moveFiles(context)) {
hilog.info(0x0000, 'BackupRestore FileTransferManager', 'transfer success');
return;
}
hilog.error(0x0000, 'BackupRestore FileTransferManager', 'transfer fail');
}
private moveFiles(context: common.Context): boolean {
try {
let cePathPrefix: string = '/data/storage/el2/backup/restore/com.example.backuprestore/ce';
let sourceFilePath: string = cePathPrefix + '/files/sourceFiles';
if (!fileIo.accessSync(sourceFilePath)) {
hilog.error(0x0000, 'BackupRestore FileTransferManager', `moveFiles, ${sourceFilePath} can't access`);
return false;
}
let listFileNames: string[] = fileIo.listFileSync(sourceFilePath);
if (!listFileNames || listFileNames.length === 0) {
hilog.error(0x0000, 'BackupRestore FileTransferManager', `moveFiles, ${sourceFilePath} is not file`);
return false;
}
let targetPath: string = context.filesDir + '/targetFiles';
if (!fileIo.accessSync(targetPath)) {
fileIo.mkdirSync(targetPath);
}
listFileNames.forEach((fileName: string) => {
let srcPath: string = `${sourceFilePath}/${fileName}`;
let destPath: string = `${targetPath}/${fileName}`;
if (fileIo.statSync(srcPath).isFile()) {
fileIo.moveFileSync(srcPath, destPath);
} else {
fileIo.moveDirSync(srcPath, targetPath);
}
});
return true;
} catch (error) {
hilog.error(0x0000, 'BackupRestore FileTransferManager', `moveFiles, error: ${JSON.stringify(error)}`);
return false;
}
}
}
|
https://github.com/fengcreate/harmony-document/blob/798534b0f76399dc84e7940f5b14b3ae4e53c6a9/BackupRestore/entry/src/main/ets/restore/fileMigrate/FileTransferManager.ets#L23-L77
|
fb9e993c7005a9ed08d42068073e24c9d8294f28
|
gitee
|
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/common/i18n/I18nManager.ets
|
arkts
|
getCurrentLanguage
|
获取当前语言
|
getCurrentLanguage(): SupportedLanguage {
return this.currentLanguage;
}
|
AST#method_declaration#Left getCurrentLanguage AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left SupportedLanguage 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 . currentLanguage AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
getCurrentLanguage(): SupportedLanguage {
return this.currentLanguage;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/i18n/I18nManager.ets#L359-L361
|
8b9770d2082b37334fa8150b333a723e8a3c9fec
|
github
|
2763981847/Clock-Alarm.git
|
8949bedddb7d011021848196735f30ffe2bd1daf
|
entry/src/main/ets/view/Detail/dialog/IntervalDialog.ets
|
arkts
|
构建对话框的内容
|
build() {
// 使用Flex布局
Flex() {
// 如果间隔时间或间隔次数大于0
if ((this.intervalTimesSelect | this.intervalMinuteSelect) > 0) {
// 创建一个通用对话框
CommonDialog({
title: $r('app.string.ring_interval'), // 设置标题
controller: this.controller, // 设置控制器
// 确认按钮的回调函数
onConfirm: () => {
// 更新AlarmItem的间隔分钟和次数
this.alarmItem.intervalMinute = Number(this.intervalMinuteSelect.toFixed(0))
this.alarmItem.intervalTimes = Number(this.intervalTimesSelect.toFixed(0))
}
}) {
// 创建两个间隔设置项
this.IntervalItem($r('app.string.ring_interval_content'), 0) // 间隔分钟设置项
// 分割线
Divider()
.opacity($r('app.float.divider_opacity')) // 设置透明度
.color($r('app.color.grey_divider')) // 设置颜色
.lineCap(LineCapStyle.Round) // 设置线帽样式
// 间隔次数设置项
this.IntervalItem($r('app.string.ring_times_content'), CommonConstants.DEFAULT_SINGLE)
}
}
}
}
|
AST#build_method#Left build ( ) AST#build_body#Left { // 使用Flex布局 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Flex ( ) AST#container_content_body#Left { // 如果间隔时间或间隔次数大于0 AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . intervalTimesSelect AST#member_expression#Right AST#expression#Right | AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . intervalMinuteSelect AST#member_expression#Right AST#expression#Right ) AST#parenthesized_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 CommonDialog ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.ring_interval' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , // 设置标题 AST#component_parameter#Left controller : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . controller AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , // 设置控制器 // 确认按钮的回调函数 AST#component_parameter#Left onConfirm : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { // 更新AlarmItem的间隔分钟和次数 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 . alarmItem AST#member_expression#Right AST#expression#Right . intervalMinute AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left Number 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 . intervalMinuteSelect AST#member_expression#Right AST#expression#Right . toFixed 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#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . alarmItem AST#member_expression#Right AST#expression#Right . intervalTimes AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left Number 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 . intervalTimesSelect AST#member_expression#Right AST#expression#Right . toFixed 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#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#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 . IntervalItem AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.ring_interval_content' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right // 间隔分钟设置项 // 分割线 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Divider ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . opacity ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.divider_opacity' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) // 设置透明度 AST#modifier_chain_expression#Left . color ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.grey_divider' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) // 设置颜色 AST#modifier_chain_expression#Left . lineCap ( AST#expression#Left AST#member_expression#Left AST#expression#Left LineCapStyle AST#expression#Right . Round AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 设置线帽样式 // 间隔次数设置项 AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . IntervalItem AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.ring_times_content' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DEFAULT_SINGLE 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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right
|
build() {
Flex() {
if ((this.intervalTimesSelect | this.intervalMinuteSelect) > 0) {
CommonDialog({
title: $r('app.string.ring_interval'),
controller: this.controller,
onConfirm: () => {
this.alarmItem.intervalMinute = Number(this.intervalMinuteSelect.toFixed(0))
this.alarmItem.intervalTimes = Number(this.intervalTimesSelect.toFixed(0))
}
}) {
this.IntervalItem($r('app.string.ring_interval_content'), 0)
Divider()
.opacity($r('app.float.divider_opacity'))
.color($r('app.color.grey_divider'))
.lineCap(LineCapStyle.Round)
this.IntervalItem($r('app.string.ring_times_content'), CommonConstants.DEFAULT_SINGLE)
}
}
}
}
|
https://github.com/2763981847/Clock-Alarm.git/blob/8949bedddb7d011021848196735f30ffe2bd1daf/entry/src/main/ets/view/Detail/dialog/IntervalDialog.ets#L29-L57
|
a271c43e9c03752b7a1638b14a82b98247861dcd
|
github
|
|
openharmony/xts_tools
|
784a2e99d894e6bc2aba8c38f6bb68032442b1c8
|
sample/AppSampleD/entry/src/main/ets/appsampled/data/SearchResult.ets
|
arkts
|
视频展示图片的文件名称
|
constructor(videoAuthorName: string, videoAuthorIcon: Resource, videoLikeNum: string, videoTitle: string, video: Resource) {
this.videoAuthorName = videoAuthorName;
this.videoAuthorIcon = videoAuthorIcon;
this.videoLikeNum = videoLikeNum;
this.videoTitle = videoTitle;
this.video = video;
}
|
AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left videoAuthorName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left videoAuthorIcon : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left videoLikeNum : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left videoTitle : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left video : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . videoAuthorName AST#member_expression#Right = AST#expression#Left videoAuthorName 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 . videoAuthorIcon AST#member_expression#Right = AST#expression#Left videoAuthorIcon 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 . videoLikeNum AST#member_expression#Right = AST#expression#Left videoLikeNum 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 . videoTitle AST#member_expression#Right = AST#expression#Left videoTitle 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 . video AST#member_expression#Right = AST#expression#Left video 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(videoAuthorName: string, videoAuthorIcon: Resource, videoLikeNum: string, videoTitle: string, video: Resource) {
this.videoAuthorName = videoAuthorName;
this.videoAuthorIcon = videoAuthorIcon;
this.videoLikeNum = videoLikeNum;
this.videoTitle = videoTitle;
this.video = video;
}
|
https://github.com/openharmony/xts_tools/blob/784a2e99d894e6bc2aba8c38f6bb68032442b1c8/sample/AppSampleD/entry/src/main/ets/appsampled/data/SearchResult.ets#L90-L96
|
0959b4a4f72d611525d3cfa0fbdb16bc408fe80a
|
gitee
|
|
liuchao0739/arkTS_universal_starter.git
|
0ca845f5ae0e78db439dc09f712d100c0dd46ed3
|
entry/src/main/ets/theme/ThemeManager.ets
|
arkts
|
getCurrentTheme
|
获取当前主题
|
getCurrentTheme(): ThemeMode {
return this.currentTheme;
}
|
AST#method_declaration#Left getCurrentTheme AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left ThemeMode 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 . currentTheme AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
getCurrentTheme(): ThemeMode {
return this.currentTheme;
}
|
https://github.com/liuchao0739/arkTS_universal_starter.git/blob/0ca845f5ae0e78db439dc09f712d100c0dd46ed3/entry/src/main/ets/theme/ThemeManager.ets#L96-L98
|
5f4686c53c2f9edc243da53e14499e0f94c7ab89
|
github
|
CongDuang/PlayHarmony.git
|
674a0459e1b20db9de8c837dff6a8d1f06330e79
|
entry/src/main/ets/pages/main/view/HomeView.ets
|
arkts
|
getHomeListData
|
获取首页列表数据
@param page 页码
@returns
|
async getHomeListData(page: number): Promise<boolean> {
let topArticleList: ArticleModel[] = [];
if (page === 0) {
const topArticleResp = await HttpUtil.getInstance().get<ArticleModel[], undefined>('/article/top/json')
if (topArticleResp.errorCode === ErroCode.OK && topArticleResp.data) {
topArticleList = topArticleResp.data!;
}
}
// 获取列表数据
const resp: BaseResp<PageInlineResp<ArticleModel>> =
await HttpUtil.getInstance()
.get<PageInlineResp<ArticleModel>, undefined>(`/article/list/${page}/json?page_size=20`);
if (resp.errorCode === ErroCode.OK && resp.data) {
if (page === 0) {
this.homeArticleList.length = 0;
}
// 先拼接置顶的数据
if (topArticleList.length > 0) {
this.homeArticleList.push(...topArticleList);
}
// 拼接数据
this.homeArticleList.push(...resp.data!.datas);
// 如果接口调用成功了,再修改 page
this.page = page;
return true;
}
return false;
}
|
AST#method_declaration#Left async getHomeListData AST#parameter_list#Left ( AST#parameter#Left page : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left topArticleList : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ArticleModel [ ] 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 page AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left topArticleResp = 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 HttpUtil AST#expression#Right AST#await_expression#Right AST#expression#Right . getInstance AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ArticleModel [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left undefined AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left '/article/top/json' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left topArticleResp AST#expression#Right . errorCode AST#member_expression#Right AST#expression#Right === AST#expression#Left ErroCode AST#expression#Right AST#binary_expression#Right AST#expression#Right . OK AST#member_expression#Right AST#expression#Right && AST#expression#Left topArticleResp AST#expression#Right AST#binary_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left topArticleList = AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left topArticleResp AST#expression#Right . data AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 获取列表数据 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left resp : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left BaseResp AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left PageInlineResp AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left ArticleModel AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left HttpUtil AST#expression#Right AST#await_expression#Right AST#expression#Right . getInstance AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left PageInlineResp AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left ArticleModel AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left undefined AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` /article/list/ AST#template_substitution#Left $ { AST#expression#Left page AST#expression#Right } AST#template_substitution#Right /json?page_size=20 ` 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#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resp AST#expression#Right . errorCode AST#member_expression#Right AST#expression#Right === AST#expression#Left ErroCode AST#expression#Right AST#binary_expression#Right AST#expression#Right . OK AST#member_expression#Right AST#expression#Right && AST#expression#Left resp AST#expression#Right AST#binary_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left page AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . homeArticleList AST#member_expression#Right AST#expression#Right . length 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#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 topArticleList AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . homeArticleList AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#spread_element#Left ... AST#expression#Left topArticleList 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#if_statement#Right AST#statement#Right // 拼接数据 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . homeArticleList AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#spread_element#Left ... AST#expression#Left AST#member_expression#Left AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resp AST#expression#Right . data AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . datas AST#member_expression#Right AST#expression#Right AST#spread_element#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 如果接口调用成功了,再修改 page AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . page AST#member_expression#Right = AST#expression#Left page AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async getHomeListData(page: number): Promise<boolean> {
let topArticleList: ArticleModel[] = [];
if (page === 0) {
const topArticleResp = await HttpUtil.getInstance().get<ArticleModel[], undefined>('/article/top/json')
if (topArticleResp.errorCode === ErroCode.OK && topArticleResp.data) {
topArticleList = topArticleResp.data!;
}
}
const resp: BaseResp<PageInlineResp<ArticleModel>> =
await HttpUtil.getInstance()
.get<PageInlineResp<ArticleModel>, undefined>(`/article/list/${page}/json?page_size=20`);
if (resp.errorCode === ErroCode.OK && resp.data) {
if (page === 0) {
this.homeArticleList.length = 0;
}
if (topArticleList.length > 0) {
this.homeArticleList.push(...topArticleList);
}
this.homeArticleList.push(...resp.data!.datas);
this.page = page;
return true;
}
return false;
}
|
https://github.com/CongDuang/PlayHarmony.git/blob/674a0459e1b20db9de8c837dff6a8d1f06330e79/entry/src/main/ets/pages/main/view/HomeView.ets#L41-L69
|
916d759c56d4b24fc3732f60e9e2ca9dd158a50d
|
github
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/TypeUtil.ets
|
arkts
|
isArrayBuffer
|
检查是否为ArrayBuffer类型。
@param value
@returns
|
static isArrayBuffer(value: Object): boolean {
return new util.types().isArrayBuffer(value);
}
|
AST#method_declaration#Left static isArrayBuffer AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left util AST#expression#Right AST#new_expression#Right AST#expression#Right . types AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . isArrayBuffer 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 isArrayBuffer(value: Object): boolean {
return new util.types().isArrayBuffer(value);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/TypeUtil.ets#L145-L147
|
e280d8722f80ec93ad3c80b45811d57d042640b4
|
gitee
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Security/StringCipherArkTS/entry/src/main/ets/common/utils/AesUtil.ets
|
arkts
|
Constructor initialization to generate a key.
|
constructor() {
let symAlgName = CommonConstants.ENCRYPTION_MODE;
let symKeyGenerator = cryptoFramework.createSymKeyGenerator(symAlgName);
// Randomly generate a 256-bit symmetric key by using a key generator.
let keyMaterialBlob = this.genKeyMaterialBlob(CommonConstants.KEY_DATA);
symKeyGenerator.convertKey(keyMaterialBlob, (err, symKey) => {
if (err) {
Logger.error(`Convert symKey failed, ${err.code}, ${err.message}`);
return;
}
this.globalKey = symKey;
// Generating an encryption/Decryption generator.
let cipherAlgName = CommonConstants.GENERATOR_NAME;
try {
this.globalCipher = cryptoFramework.createCipher(cipherAlgName);
} catch (error) {
Logger.error(`createCipher failed, error is ${JSON.stringify(err)}`);
}
});
}
|
AST#constructor_declaration#Left constructor AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left symAlgName = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . ENCRYPTION_MODE 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 symKeyGenerator = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createSymKeyGenerator AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left symAlgName 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 // Randomly generate a 256-bit symmetric key by using a key generator. AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left keyMaterialBlob = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . genKeyMaterialBlob AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . KEY_DATA AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left symKeyGenerator AST#expression#Right . convertKey AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left keyMaterialBlob AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right , AST#parameter#Left symKey AST#parameter#Right ) AST#parameter_list#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 Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` Convert symKey failed, AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , AST#template_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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . globalKey AST#member_expression#Right = AST#expression#Left symKey AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // Generating an encryption/Decryption generator. AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left cipherAlgName = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . GENERATOR_NAME AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . globalCipher AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createCipher AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left cipherAlgName 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 Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` createCipher failed, error is AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err 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#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right
|
constructor() {
let symAlgName = CommonConstants.ENCRYPTION_MODE;
let symKeyGenerator = cryptoFramework.createSymKeyGenerator(symAlgName);
let keyMaterialBlob = this.genKeyMaterialBlob(CommonConstants.KEY_DATA);
symKeyGenerator.convertKey(keyMaterialBlob, (err, symKey) => {
if (err) {
Logger.error(`Convert symKey failed, ${err.code}, ${err.message}`);
return;
}
this.globalKey = symKey;
let cipherAlgName = CommonConstants.GENERATOR_NAME;
try {
this.globalCipher = cryptoFramework.createCipher(cipherAlgName);
} catch (error) {
Logger.error(`createCipher failed, error is ${JSON.stringify(err)}`);
}
});
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Security/StringCipherArkTS/entry/src/main/ets/common/utils/AesUtil.ets#L29-L48
|
2c27c62a23dc447b45a1d4ae8fbb1decbfeb8daf
|
gitee
|
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/pages/Index.ets
|
arkts
|
buildCalendarContent
|
构建日历页面内容
|
@Builder
buildCalendarContent() {
Stack() {
Column({ space: 16 }) {
// 日历头部 - 月份导航
this.buildCalendarHeader()
// 日历网格
this.buildCalendarGrid()
// 日期操作面板显示区域
if (this.showDateActionPanel) {
// 日期详情面板
Column({ space: 16 }) {
// 面板头部
Row() {
Column({ space: 4 }) {
Text(this.selectedDate ? `${this.selectedDate.getFullYear()}年${this.selectedDate.getMonth() + 1}月${this.selectedDate.getDate()}日` : '未选择日期')
.fontSize(18)
.fontWeight(FontWeight.Bold)
.fontColor('#333333')
Text(this.selectedDateDetail && this.selectedDateDetail.lunarDate ?
`${this.selectedDateDetail.lunarDate.fullText} ${this.selectedDateDetail.weekday}` :
`星期${['日','一','二','三','四','五','六'][this.selectedDate?.getDay() || 0]}`)
.fontSize(14)
.fontColor('#666666')
}
.alignItems(HorizontalAlign.Start)
.layoutWeight(1)
Text('✕')
.fontSize(16)
.fontColor('#999999')
.onClick(() => {
this.showDateActionPanel = false;
})
}
.width('100%')
// 当日详情信息
this.buildDateDetailInfo()
// 操作按钮
Row({ space: 12 }) {
// 添加纪念日按钮
Row({ space: 8 }) {
Text('🎉')
.fontSize(16)
Text('添加纪念日')
.fontSize(14)
.fontColor('#FFFFFF')
}
.padding({ left: 16, right: 16, top: 12, bottom: 12 })
.backgroundColor('#FF6B6B')
.borderRadius(8)
.layoutWeight(1)
.justifyContent(FlexAlign.Center)
.onClick(() => {
this.showAddAnniversaryDialog = true;
})
// 添加代办事项按钮
Row({ space: 8 }) {
Text('📝')
.fontSize(16)
Text('添加代办')
.fontSize(14)
.fontColor('#FFFFFF')
}
.padding({ left: 16, right: 16, top: 12, bottom: 12 })
.backgroundColor('#4CAF50')
.borderRadius(8)
.layoutWeight(1)
.justifyContent(FlexAlign.Center)
.onClick(() => {
this.showAddTodoDialog = true;
})
}
.width('100%')
}
.width('100%')
.padding(20)
.backgroundColor('#FFFFFF')
.borderRadius(16)
.shadow({
radius: 12,
color: 'rgba(0,0,0,0.15)',
offsetX: 0,
offsetY: 4
})
.margin({ left: 20, right: 20, top: 8, bottom: 8 })
}
// 本月生日概览
this.buildMonthBirthdayOverview()
}
.width('100%')
.alignItems(HorizontalAlign.Center)
// 添加纪念日对话框
if (this.showAddAnniversaryDialog) {
this.buildAddAnniversaryDialog()
}
// 添加代办事项对话框
if (this.showAddTodoDialog) {
this.buildAddTodoDialog()
}
}
.width('100%')
.alignContent(Alignment.TopStart)
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildCalendarContent AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Stack ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 16 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { // 日历头部 - 月份导航 AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buildCalendarHeader AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right // 日历网格 AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buildCalendarGrid AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right // 日期操作面板显示区域 AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showDateActionPanel AST#member_expression#Right AST#expression#Right ) { // 日期详情面板 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 16 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { // 面板头部 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 4 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedDate AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedDate AST#member_expression#Right AST#expression#Right . getFullYear AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right 年 AST#template_substitution#Left $ { AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedDate AST#member_expression#Right AST#expression#Right . getMonth AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right } AST#template_substitution#Right 月 AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedDate AST#member_expression#Right AST#expression#Right . getDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right 日 ` AST#template_literal#Right 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 18 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#333333' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedDateDetail AST#member_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . selectedDateDetail AST#member_expression#Right AST#expression#Right . lunarDate AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedDateDetail AST#member_expression#Right AST#expression#Right . lunarDate AST#member_expression#Right AST#expression#Right . fullText AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedDateDetail AST#member_expression#Right AST#expression#Right . weekday AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right : AST#expression#Left AST#template_literal#Left ` 星期 AST#template_substitution#Left $ { AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#array_literal#Left [ AST#expression#Left '日' AST#expression#Right , AST#expression#Left '一' AST#expression#Right , AST#expression#Left '二' AST#expression#Right , AST#expression#Left '三' AST#expression#Right , AST#expression#Left '四' AST#expression#Right , AST#expression#Left '五' AST#expression#Right , AST#expression#Left '六' AST#expression#Right ] AST#array_literal#Right AST#expression#Right [ AST#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 . selectedDate AST#member_expression#Right AST#expression#Right ?. getDay AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . 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#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '✕' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#999999' AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showDateActionPanel AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#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#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 当日详情信息 AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buildDateDetailInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right // 操作按钮 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left 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 Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 8 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '🎉' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#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 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#FFFFFF' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . 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 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#FF6B6B' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 8 AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . 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 . showAddAnniversaryDialog AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#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 Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 8 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '📝' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#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 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#FFFFFF' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . 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 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#4CAF50' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 8 AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . 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 . showAddTodoDialog AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#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#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 20 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#FFFFFF' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 16 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 'rgba(0,0,0,0.15)' 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 4 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 left AST#property_name#Right : AST#expression#Left 20 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 20 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 8 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 8 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buildMonthBirthdayOverview AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#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 this AST#expression#Right . showAddAnniversaryDialog AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buildAddAnniversaryDialog 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#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showAddTodoDialog AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buildAddTodoDialog 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#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 . alignContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . TopStart AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
buildCalendarContent() {
Stack() {
Column({ space: 16 }) {
this.buildCalendarHeader()
this.buildCalendarGrid()
if (this.showDateActionPanel) {
Column({ space: 16 }) {
Row() {
Column({ space: 4 }) {
Text(this.selectedDate ? `${this.selectedDate.getFullYear()}年${this.selectedDate.getMonth() + 1}月${this.selectedDate.getDate()}日` : '未选择日期')
.fontSize(18)
.fontWeight(FontWeight.Bold)
.fontColor('#333333')
Text(this.selectedDateDetail && this.selectedDateDetail.lunarDate ?
`${this.selectedDateDetail.lunarDate.fullText} ${this.selectedDateDetail.weekday}` :
`星期${['日','一','二','三','四','五','六'][this.selectedDate?.getDay() || 0]}`)
.fontSize(14)
.fontColor('#666666')
}
.alignItems(HorizontalAlign.Start)
.layoutWeight(1)
Text('✕')
.fontSize(16)
.fontColor('#999999')
.onClick(() => {
this.showDateActionPanel = false;
})
}
.width('100%')
this.buildDateDetailInfo()
Row({ space: 12 }) {
Row({ space: 8 }) {
Text('🎉')
.fontSize(16)
Text('添加纪念日')
.fontSize(14)
.fontColor('#FFFFFF')
}
.padding({ left: 16, right: 16, top: 12, bottom: 12 })
.backgroundColor('#FF6B6B')
.borderRadius(8)
.layoutWeight(1)
.justifyContent(FlexAlign.Center)
.onClick(() => {
this.showAddAnniversaryDialog = true;
})
Row({ space: 8 }) {
Text('📝')
.fontSize(16)
Text('添加代办')
.fontSize(14)
.fontColor('#FFFFFF')
}
.padding({ left: 16, right: 16, top: 12, bottom: 12 })
.backgroundColor('#4CAF50')
.borderRadius(8)
.layoutWeight(1)
.justifyContent(FlexAlign.Center)
.onClick(() => {
this.showAddTodoDialog = true;
})
}
.width('100%')
}
.width('100%')
.padding(20)
.backgroundColor('#FFFFFF')
.borderRadius(16)
.shadow({
radius: 12,
color: 'rgba(0,0,0,0.15)',
offsetX: 0,
offsetY: 4
})
.margin({ left: 20, right: 20, top: 8, bottom: 8 })
}
this.buildMonthBirthdayOverview()
}
.width('100%')
.alignItems(HorizontalAlign.Center)
if (this.showAddAnniversaryDialog) {
this.buildAddAnniversaryDialog()
}
if (this.showAddTodoDialog) {
this.buildAddTodoDialog()
}
}
.width('100%')
.alignContent(Alignment.TopStart)
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/Index.ets#L2164-L2276
|
9c322a4ec4f2f469cac918c91ce95c9ae2931ca4
|
github
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/DocsSample/CoreFile/UserFile/UserFileURI/entry/src/main/ets/pages/Index.ets
|
arkts
|
copyingFileByUriExample
|
[Start function_example] [Start copy_file_uri_example ]
|
async copyingFileByUriExample() {
let fileAccessHelper: fileAccess.FileAccessHelper;
// wantInfos 从getFileAccessAbilityInfo()获取
let wantInfos: Want[] = [
{
bundleName: 'com.ohos.UserFile.ExternalFileManager',
abilityName: 'FileExtensionAbility',
},
];
try {
fileAccessHelper = fileAccess.createFileAccessHelper(context, wantInfos);
if (!fileAccessHelper) {
Logger.error('createFileAccessHelper interface returns an undefined object');
}
// 以内置存储目录为例
// 示例代码sourceUri表示Download目录,该uri是对应的fileInfo中uri
// 开发者应根据自己实际获取的uri进行开发
let sourceUri: string = 'file://docs/storage/Users/currentUser/Download/renameFile.txt';
// 将文件复制到的位置uri
let destUri: string = 'file://docs/storage/Users/currentUser/Documents';
// 如果文件名冲突,要使用的文件名
let displayName: string = 'file.txt';
// 存放返回的uri
let fileUri: string;
try {
// 复制文件返回该文件的uri
fileUri = await fileAccessHelper.copyFile(sourceUri, destUri, displayName);
if (!fileUri) {
Logger.error('copyFile return undefined object');
}
Logger.info('copyFile success, fileUri: ' + JSON.stringify(fileUri));
this.uriMessage = 'CopyAFileSuccess';
} catch (err) {
let error: BusinessError = err as BusinessError;
Logger.error('copyFile failed, errCode:' + error.code + ', errMessage:' + error.message);
}
} catch (err) {
let error: BusinessError = err as BusinessError;
Logger.error('createFileAccessHelper failed, errCode:' + error.code + ', errMessage:' + error.message);
}
}
|
AST#method_declaration#Left async copyingFileByUriExample AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left fileAccessHelper : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left fileAccess . FileAccessHelper AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // wantInfos 从getFileAccessAbilityInfo()获取 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left wantInfos : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Want [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bundleName AST#property_name#Right : AST#expression#Left 'com.ohos.UserFile.ExternalFileManager' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left abilityName AST#property_name#Right : AST#expression#Left 'FileExtensionAbility' AST#expression#Right AST#property_assignment#Right , } AST#object_literal#Right AST#expression#Right , ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left fileAccessHelper = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fileAccess AST#expression#Right . createFileAccessHelper AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left wantInfos AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left fileAccessHelper 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 Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'createFileAccessHelper interface returns an undefined object' 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 // 以内置存储目录为例 // 示例代码sourceUri表示Download目录,该uri是对应的fileInfo中uri // 开发者应根据自己实际获取的uri进行开发 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left sourceUri : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'file://docs/storage/Users/currentUser/Download/renameFile.txt' AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 将文件复制到的位置uri AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left destUri : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'file://docs/storage/Users/currentUser/Documents' 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 displayName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'file.txt' AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 存放返回的uri AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left fileUri : AST#type_annotation#Left AST#primary_type#Left string 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 { // 复制文件返回该文件的uri AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left fileUri = 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 fileAccessHelper AST#expression#Right AST#await_expression#Right AST#expression#Right . copyFile AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sourceUri AST#expression#Right , AST#expression#Left destUri AST#expression#Right , AST#expression#Left displayName AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left fileUri 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 Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'copyFile return undefined object' 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 Logger 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 'copyFile success, fileUri: ' 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 fileUri AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . uriMessage AST#member_expression#Right = AST#expression#Left 'CopyAFileSuccess' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left error : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left 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 Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'copyFile failed, errCode:' AST#expression#Right + AST#expression#Left error AST#expression#Right AST#binary_expression#Right AST#expression#Right . code AST#member_expression#Right AST#expression#Right + AST#expression#Left ', errMessage:' AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left error AST#expression#Right AST#binary_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#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#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left error : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left 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 Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'createFileAccessHelper failed, errCode:' AST#expression#Right + AST#expression#Left error AST#expression#Right AST#binary_expression#Right AST#expression#Right . code AST#member_expression#Right AST#expression#Right + AST#expression#Left ', errMessage:' AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left error AST#expression#Right AST#binary_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async copyingFileByUriExample() {
let fileAccessHelper: fileAccess.FileAccessHelper;
let wantInfos: Want[] = [
{
bundleName: 'com.ohos.UserFile.ExternalFileManager',
abilityName: 'FileExtensionAbility',
},
];
try {
fileAccessHelper = fileAccess.createFileAccessHelper(context, wantInfos);
if (!fileAccessHelper) {
Logger.error('createFileAccessHelper interface returns an undefined object');
}
let sourceUri: string = 'file://docs/storage/Users/currentUser/Download/renameFile.txt';
let destUri: string = 'file://docs/storage/Users/currentUser/Documents';
let displayName: string = 'file.txt';
let fileUri: string;
try {
fileUri = await fileAccessHelper.copyFile(sourceUri, destUri, displayName);
if (!fileUri) {
Logger.error('copyFile return undefined object');
}
Logger.info('copyFile success, fileUri: ' + JSON.stringify(fileUri));
this.uriMessage = 'CopyAFileSuccess';
} catch (err) {
let error: BusinessError = err as BusinessError;
Logger.error('copyFile failed, errCode:' + error.code + ', errMessage:' + error.message);
}
} catch (err) {
let error: BusinessError = err as BusinessError;
Logger.error('createFileAccessHelper failed, errCode:' + error.code + ', errMessage:' + error.message);
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/CoreFile/UserFile/UserFileURI/entry/src/main/ets/pages/Index.ets#L261-L301
|
96630a22f4c8e014d15c66be341878527dd0fc91
|
gitee
|
salehelper/algorithm_arkts.git
|
61af15272038646775a4745fca98a48ba89e1f4e
|
entry/src/main/ets/sorting/BubbleSort.ets
|
arkts
|
sort
|
冒泡排序算法
@param arr 需要排序的数组
@returns 排序后的数组
|
public static sort(arr: number[]): number[] {
const n = arr.length;
// 创建数组副本以避免修改原数组
const result = [...arr];
for (let i = 0; i < n - 1; i++) {
for (let j = 0; j < n - i - 1; j++) {
// 如果当前元素大于下一个元素,则交换它们
if (result[j] > result[j + 1]) {
// 使用临时变量进行交换
const temp = result[j];
result[j] = result[j + 1];
result[j + 1] = temp;
}
}
}
return result;
}
|
AST#method_declaration#Left public static sort 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_list#Right : 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#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left n = AST#expression#Left AST#member_expression#Left AST#expression#Left arr AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 创建数组副本以避免修改原数组 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left result = AST#expression#Left AST#array_literal#Left [ ... AST#expression#Left arr 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#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left AST#binary_expression#Left AST#expression#Left n AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right 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#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left j = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#binary_expression#Left AST#expression#Left j AST#expression#Right < AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left n AST#expression#Right - AST#expression#Left i 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#binary_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left j 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 result AST#expression#Right [ AST#expression#Left j AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right > AST#expression#Left AST#subscript_expression#Left AST#expression#Left result AST#expression#Right [ AST#expression#Left AST#binary_expression#Left AST#expression#Left j AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right 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#variable_declaration#Left const AST#variable_declarator#Left temp = AST#expression#Left AST#subscript_expression#Left AST#expression#Left result AST#expression#Right [ AST#expression#Left j AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left result AST#expression#Right [ AST#expression#Left j AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left = result AST#ERROR#Right [ AST#expression#Left AST#binary_expression#Left AST#expression#Left j AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left result AST#expression#Right [ AST#expression#Left AST#binary_expression#Left AST#expression#Left j AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left = temp AST#ERROR#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public static sort(arr: number[]): number[] {
const n = arr.length;
const result = [...arr];
for (let i = 0; i < n - 1; i++) {
for (let j = 0; j < n - i - 1; j++) {
if (result[j] > result[j + 1]) {
const temp = result[j];
result[j] = result[j + 1];
result[j + 1] = temp;
}
}
}
return result;
}
|
https://github.com/salehelper/algorithm_arkts.git/blob/61af15272038646775a4745fca98a48ba89e1f4e/entry/src/main/ets/sorting/BubbleSort.ets#L10-L28
|
79b8dd55902bf865ca0661cf04cfa4c689aec7b1
|
github
|
vhall/VHLive_SDK_Harmony
|
29c820e5301e17ae01bc6bdcc393a4437b518e7c
|
watchKit/src/main/ets/util/ChatTools.ets
|
arkts
|
getLocalUserUid
|
返回本地用户UID.
@returns local uid
|
static getLocalUserUid(): string | undefined {
// return ClientCoreSDK.getInstance().currentLoginInfo?.loginUserId
return "";
}
|
AST#method_declaration#Left static getLocalUserUid AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { // return ClientCoreSDK.getInstance().currentLoginInfo?.loginUserId AST#statement#Left AST#return_statement#Left return AST#expression#Left "" AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static getLocalUserUid(): string | undefined {
return "";
}
|
https://github.com/vhall/VHLive_SDK_Harmony/blob/29c820e5301e17ae01bc6bdcc393a4437b518e7c/watchKit/src/main/ets/util/ChatTools.ets#L86-L89
|
b0bd4756c17f2f62400f12d9cb94d9ce03b7c77e
|
gitee
|
XiangRui_FuZi/harmony-oscourse
|
da885f9a777a1eace7a07e1cd81137746687974b
|
class1/entry/src/main/ets/view/Side.ets
|
arkts
|
changeLikeCount
|
The callback function for the click event of the like button.
@param isAdd
|
private changeLikeCount(isAdd: boolean) {
let likeCountNum = Number(this.likeCount);
if(isAdd) {
likeCountNum++;
} else {
likeCountNum--;
}
this.likeCount = '' + likeCountNum;
animateTo({ duration: Const.DURATION, curve: Curve.EaseInOut }, () => {
this.isLike = !this.isLike;
})
}
|
AST#method_declaration#Left private changeLikeCount AST#parameter_list#Left ( AST#parameter#Left isAdd : 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#variable_declaration#Left let AST#variable_declarator#Left likeCountNum = AST#expression#Left AST#call_expression#Left AST#expression#Left Number AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . likeCount AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left isAdd AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#update_expression#Left AST#expression#Left likeCountNum 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#update_expression#Left AST#expression#Left likeCountNum 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 this AST#expression#Right . likeCount AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left '' AST#expression#Right + AST#expression#Left likeCountNum 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#call_expression#Left AST#expression#Left animateTo AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . DURATION AST#member_expression#Right 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#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 . isLike AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . isLike 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#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 changeLikeCount(isAdd: boolean) {
let likeCountNum = Number(this.likeCount);
if(isAdd) {
likeCountNum++;
} else {
likeCountNum--;
}
this.likeCount = '' + likeCountNum;
animateTo({ duration: Const.DURATION, curve: Curve.EaseInOut }, () => {
this.isLike = !this.isLike;
})
}
|
https://github.com/XiangRui_FuZi/harmony-oscourse/blob/da885f9a777a1eace7a07e1cd81137746687974b/class1/entry/src/main/ets/view/Side.ets#L21-L32
|
6cc40172892184308fb136de66dd012736d5b665
|
gitee
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/publishmultimediaupdates/src/main/ets/constants/ListConstants.ets
|
arkts
|
Copyright (c) 2024 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
export class ListConstants {
// 自动分配剩余空间
static readonly LAYOUT_WEIGHT: number = 1;
// 列表默认间隔
static readonly LIST_SPACE: number = 10;
}
|
AST#export_declaration#Left export AST#class_declaration#Left class ListConstants AST#class_body#Left { // 自动分配剩余空间 AST#property_declaration#Left static readonly LAYOUT_WEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1 AST#expression#Right ; AST#property_declaration#Right // 列表默认间隔 AST#property_declaration#Left static readonly LIST_SPACE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 10 AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class ListConstants {
static readonly LAYOUT_WEIGHT: number = 1;
static readonly LIST_SPACE: number = 10;
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/publishmultimediaupdates/src/main/ets/constants/ListConstants.ets#L16-L21
|
4ccdf1e501e27300c4ccf08154881a470a699632
|
gitee
|
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
UseSendable/entry/src/main/ets/entryability/EntryAbility.ets
|
arkts
|
immersionFuc
|
Page immersion.
|
immersionFuc(windowStage: window.WindowStage): void {
try {
let windowClass: window.Window = windowStage.getMainWindowSync();
windowClass.setWindowLayoutFullScreen(true);
let navigationBarArea: window.AvoidArea =
windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR);
let area: window.AvoidArea = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM);
AppStorage.setOrCreate<number>('naviIndicatorHeight',
windowClass.getUIContext().px2vp(navigationBarArea.bottomRect.height));
AppStorage.setOrCreate<number>('statusBarHeight', windowClass.getUIContext().px2vp(area.topRect.height));
AppStorage.setOrCreate<window.Window>('windowClass', windowClass);
} catch (error) {
hilog.info(DOMAIN, TAG, FORMAT, `immersionFuc failed, error code=${error.code}, message=${error.message}`);
}
}
|
AST#method_declaration#Left immersionFuc AST#parameter_list#Left ( AST#parameter#Left windowStage : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . WindowStage AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left windowClass : AST#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#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowStage AST#expression#Right . getMainWindowSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right 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 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 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left navigationBarArea : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . AvoidArea AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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_NAVIGATION_INDICATOR AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left area : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . AvoidArea AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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_SYSTEM AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left 'naviIndicatorHeight' 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 windowClass AST#expression#Right . getUIContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . px2vp 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 navigationBarArea AST#expression#Right . bottomRect AST#member_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left 'statusBarHeight' 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 windowClass AST#expression#Right . getUIContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . px2vp 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 area AST#expression#Right . topRect AST#member_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#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 'windowClass' AST#expression#Right , AST#expression#Left windowClass AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left TAG AST#expression#Right , AST#expression#Left FORMAT AST#expression#Right , AST#expression#Left AST#template_literal#Left ` immersionFuc failed, error code= AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , message= AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
immersionFuc(windowStage: window.WindowStage): void {
try {
let windowClass: window.Window = windowStage.getMainWindowSync();
windowClass.setWindowLayoutFullScreen(true);
let navigationBarArea: window.AvoidArea =
windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR);
let area: window.AvoidArea = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM);
AppStorage.setOrCreate<number>('naviIndicatorHeight',
windowClass.getUIContext().px2vp(navigationBarArea.bottomRect.height));
AppStorage.setOrCreate<number>('statusBarHeight', windowClass.getUIContext().px2vp(area.topRect.height));
AppStorage.setOrCreate<window.Window>('windowClass', windowClass);
} catch (error) {
hilog.info(DOMAIN, TAG, FORMAT, `immersionFuc failed, error code=${error.code}, message=${error.message}`);
}
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/UseSendable/entry/src/main/ets/entryability/EntryAbility.ets#L66-L80
|
1155e2c483fff8dc3eb6401a72102b8d06c1ccd6
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/pages/GreetingsPage.ets
|
arkts
|
buildFilterChip
|
构建筛选标签
|
@Builder
buildFilterChip(label: string, value: string, count: number) {
Button(`${label}(${count})`)
.type(ButtonType.Capsule)
.fontSize(14)
.fontColor(this.selectedOccasion === value || (value === 'all' && this.selectedOccasion === 'all') ? '#ffffff' : '#666666')
.backgroundColor(this.selectedOccasion === value || (value === 'all' && this.selectedOccasion === 'all') ? '#007AFF' : '#f0f0f0')
.height('32vp')
.constraintSize({ minWidth: 60 })
.padding({ left: 12, right: 12 })
.onClick(() => {
this.onFilterChange('occasion', value === 'custom' ? 'all' : value);
})
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildFilterChip AST#parameter_list#Left ( AST#parameter#Left label : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left count : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_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 label AST#expression#Right } AST#template_substitution#Right ( AST#template_substitution#Left $ { AST#expression#Left count AST#expression#Right } AST#template_substitution#Right ) ` AST#template_literal#Right 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 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedOccasion AST#member_expression#Right AST#expression#Right === AST#expression#Left value AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left value AST#expression#Right === AST#expression#Left 'all' AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . selectedOccasion AST#member_expression#Right AST#expression#Right === AST#expression#Left 'all' 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 '#ffffff' AST#expression#Right : AST#expression#Left '#666666' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedOccasion AST#member_expression#Right AST#expression#Right === AST#expression#Left value AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left value AST#expression#Right === AST#expression#Left 'all' AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . selectedOccasion AST#member_expression#Right AST#expression#Right === AST#expression#Left 'all' 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 '#007AFF' AST#expression#Right : AST#expression#Left '#f0f0f0' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '32vp' AST#expression#Right ) AST#modifier_chain_expression#Left . constraintSize ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left minWidth 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#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#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 . onFilterChange AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'occasion' AST#expression#Right , AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left value AST#expression#Right === AST#expression#Left 'custom' AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 'all' AST#expression#Right : AST#expression#Left value AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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
buildFilterChip(label: string, value: string, count: number) {
Button(`${label}(${count})`)
.type(ButtonType.Capsule)
.fontSize(14)
.fontColor(this.selectedOccasion === value || (value === 'all' && this.selectedOccasion === 'all') ? '#ffffff' : '#666666')
.backgroundColor(this.selectedOccasion === value || (value === 'all' && this.selectedOccasion === 'all') ? '#007AFF' : '#f0f0f0')
.height('32vp')
.constraintSize({ minWidth: 60 })
.padding({ left: 12, right: 12 })
.onClick(() => {
this.onFilterChange('occasion', value === 'custom' ? 'all' : value);
})
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/GreetingsPage.ets#L269-L282
|
fe30ba8be6e21482c9631c594970e5b60aaffdd0
|
github
|
openharmony/interface_sdk-js
|
c349adc73e2ec1f61f6fca489b5af059e3ed6999
|
api/@ohos.multimedia.avInputCastPicker.d.ets
|
arkts
|
AVInputCastPicker
|
A picker view to show availale input device list.
@struct { AVInputCastPicker }
@syscap SystemCapability.Multimedia.AVSession.AVInputCast
@atomicservice
@since 20
|
@Component
export declare struct AVInputCastPicker {
/**
* Set the custom builder for the picker appearance.
* If not set, system will show the default appearance for different device type.
* @type { ? CustomBuilder }
* @syscap SystemCapability.Multimedia.AVSession.AVInputCast
* @atomicservice
* @since 20
*/
@Prop
customPicker?: CustomBuilder;
/**
* Picker state change callback.
* @type { ?OnPickerStateCallback }
* @syscap SystemCapability.Multimedia.AVSession.AVInputCast
* @atomicservice
* @since 20
*/
onStateChange?: OnPickerStateCallback;
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export AST#ERROR#Left declare AST#ERROR#Right struct AVInputCastPicker AST#component_body#Left { /**
* Set the custom builder for the picker appearance.
* If not set, system will show the default appearance for different device type.
* @type { ? CustomBuilder }
* @syscap SystemCapability.Multimedia.AVSession.AVInputCast
* @atomicservice
* @since 20
*/ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right customPicker ? : AST#type_annotation#Left AST#primary_type#Left CustomBuilder AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Picker state change callback.
* @type { ?OnPickerStateCallback }
* @syscap SystemCapability.Multimedia.AVSession.AVInputCast
* @atomicservice
* @since 20
*/ AST#property_declaration#Left onStateChange ? : AST#type_annotation#Left AST#primary_type#Left OnPickerStateCallback AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export declare struct AVInputCastPicker {
@Prop
customPicker?: CustomBuilder;
onStateChange?: OnPickerStateCallback;
}
|
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.multimedia.avInputCastPicker.d.ets#L30-L52
|
e52eddc83a7cf38494152413d109762afec598bf
|
gitee
|
openharmony/interface_sdk-js
|
c349adc73e2ec1f61f6fca489b5af059e3ed6999
|
api/@system.app.d.ets
|
arkts
|
Defines the option of RequestFullWindow interface.
@interface RequestFullWindowOptions
@syscap SystemCapability.ArkUI.ArkUI.Full
@since 3
Defines the option of RequestFullWindow interface.
@interface RequestFullWindowOptions
@syscap SystemCapability.ArkUI.ArkUI.Full
@atomicservice
@since 11
|
export interface RequestFullWindowOptions {
/**
* Defines the number of animation options.
*
* @type { number }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 3
*/
/**
* Defines the number of animation options.
*
* @type { number }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/
duration: number;
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface RequestFullWindowOptions AST#object_type#Left { /**
* Defines the number of animation options.
*
* @type { number }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 3
*/ /**
* Defines the number of animation options.
*
* @type { number }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/ AST#type_member#Left duration : 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 RequestFullWindowOptions {
duration: number;
}
|
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@system.app.d.ets#L206-L223
|
879167fbfb4250072ed6a39254a27e95fb2e2925
|
gitee
|
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/app/views/BgCardShape.ets
|
arkts
|
@Local settings: UserSettings = PersistenceV2.connect(UserSettings, GlobalKey.kUserSettings)!
|
build() {
// if (this.settings.isListOneCircle) {
// // 圆形卡片
// Circle()
// .width('100%')
// .height('100%')
// .fill(Color.White)
// .borderRadius('100%')
// .shadow({
// radius: 10,
// color: Color.Gray,
// offsetX: 10,
// offsetY: 10
// })
// } else {
// 方形卡片
Stack(){
Rect()
.width('100%')
.height('100%')
.fill(Color.White)
.borderRadius(16)
.radius(16)
.shadow({
radius: 10,
color: Color.Gray,
offsetX: 10,
offsetY: 10
})
// CardBorderView({hasPinyin: false})
// .margin(20)
}
// }
}
|
AST#build_method#Left build ( ) AST#build_body#Left { // if (this.settings.isListOneCircle) { // // 圆形卡片 // Circle() // .width('100%') // .height('100%') // .fill(Color.White) // .borderRadius('100%') // .shadow({ // radius: 10, // color: Color.Gray, // offsetX: 10, // offsetY: 10 // }) // } else { // 方形卡片 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Stack ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Rect ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . fill ( 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 16 AST#expression#Right ) AST#modifier_chain_expression#Left . radius ( AST#expression#Left 16 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 10 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Gray AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetX AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetY AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 // CardBorderView({hasPinyin: false}) // .margin(20) } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // } } AST#build_body#Right AST#build_method#Right
|
build() {
Stack(){
Rect()
.width('100%')
.height('100%')
.fill(Color.White)
.borderRadius(16)
.radius(16)
.shadow({
radius: 10,
color: Color.Gray,
offsetX: 10,
offsetY: 10
})
}
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/app/views/BgCardShape.ets#L10-L53
|
3dd1d341c18568a886290b6dc4199d6798747c0c
|
github
|
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/chinesetopinyin/src/main/ets/pages/ChineseToPinyin.ets
|
arkts
|
UserItemView
|
列表组件
|
@Component
export struct UserItemView {
// 列表项
@ObjectLink text: ListConstruction;
build() {
Row() {
Text(this.text.title)
.fontSize($r('app.integer.pinyin_list_title_size'))
.fontColor($r('app.color.pinyin_list_title_color'))
.width($r('app.integer.pinyin_setting_title_width'))
.lineHeight($r('app.integer.pinyin_list_line_height'))
Text(this.text.content)
.fontSize($r('app.integer.pinyin_list_content_size'))
.layoutWeight(LAYOUT_WEIGHT)
.fontColor($r('app.color.pinyin_list_content_color'))
.lineHeight($r('app.integer.pinyin_list_line_height'))
.textOverflow({
overflow: TextOverflow.MARQUEE
})
.maxLines(MAX_LINE)
.textAlign(TextAlign.End)
}
.width($r('app.string.pinyin_list_width'))
.height($r('app.integer.pinyin_setting_item_height'))
.padding({
left: $r('app.integer.pinyin_setting_item_padding_left'),
right: $r('app.integer.pinyin_setting_item_padding_right')
})
.alignItems(VerticalAlign.Center)
.width($r('app.string.pinyin_list_width'))
.alignSelf(ItemAlign.Center)
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct UserItemView AST#component_body#Left { // 列表项 AST#property_declaration#Left AST#decorator#Left @ ObjectLink AST#decorator#Right text : AST#type_annotation#Left AST#primary_type#Left ListConstruction AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . text AST#member_expression#Right AST#expression#Right . title AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.pinyin_list_title_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.pinyin_list_title_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.pinyin_setting_title_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . lineHeight ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.pinyin_list_line_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 . text AST#member_expression#Right AST#expression#Right . content AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.pinyin_list_content_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left LAYOUT_WEIGHT AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.pinyin_list_content_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . lineHeight ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.pinyin_list_line_height' AST#expression#Right ) AST#resource_expression#Right 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 . MARQUEE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . maxLines ( AST#expression#Left MAX_LINE AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . End AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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.pinyin_list_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.pinyin_setting_item_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.pinyin_setting_item_padding_left' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.pinyin_setting_item_padding_right' 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 . 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 . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.pinyin_list_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign 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#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 UserItemView {
@ObjectLink text: ListConstruction;
build() {
Row() {
Text(this.text.title)
.fontSize($r('app.integer.pinyin_list_title_size'))
.fontColor($r('app.color.pinyin_list_title_color'))
.width($r('app.integer.pinyin_setting_title_width'))
.lineHeight($r('app.integer.pinyin_list_line_height'))
Text(this.text.content)
.fontSize($r('app.integer.pinyin_list_content_size'))
.layoutWeight(LAYOUT_WEIGHT)
.fontColor($r('app.color.pinyin_list_content_color'))
.lineHeight($r('app.integer.pinyin_list_line_height'))
.textOverflow({
overflow: TextOverflow.MARQUEE
})
.maxLines(MAX_LINE)
.textAlign(TextAlign.End)
}
.width($r('app.string.pinyin_list_width'))
.height($r('app.integer.pinyin_setting_item_height'))
.padding({
left: $r('app.integer.pinyin_setting_item_padding_left'),
right: $r('app.integer.pinyin_setting_item_padding_right')
})
.alignItems(VerticalAlign.Center)
.width($r('app.string.pinyin_list_width'))
.alignSelf(ItemAlign.Center)
}
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/chinesetopinyin/src/main/ets/pages/ChineseToPinyin.ets#L185-L218
|
2978d9e6b5d1a644f36d973dc1212d129d09d5c9
|
gitee
|
Joker-x-dev/CoolMallArkTS.git
|
9f3fabf89fb277692cb82daf734c220c7282919c
|
feature/goods/src/main/ets/view/GoodsCategoryPage.ets
|
arkts
|
构建商品分类页面
@returns {void} 无返回值
|
build() {
AppNavDestination({
title: "商品分类",
viewModel: this.vm
}) {
this.GoodsCategoryContent();
}
}
|
AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left AppNavDestination ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left "商品分类" AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left viewModel : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . GoodsCategoryContent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right
|
build() {
AppNavDestination({
title: "商品分类",
viewModel: this.vm
}) {
this.GoodsCategoryContent();
}
}
|
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/goods/src/main/ets/view/GoodsCategoryPage.ets#L20-L27
|
e2f4a582b51c6f350b66c21001fd0ddd56788d23
|
github
|
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/DocsSample/Media/Image/PixelMap/entry/src/main/ets/pages/Index.ets
|
arkts
|
bitmapOperationAll
|
位图操作所有像素
|
private async bitmapOperationAll() {
if (this.pixelMap != undefined) {
// [Start pixelmap_get_pixelmap_info]
// 获取图像像素的总字节数
let pixelBytesNumber: number = this.pixelMap.getPixelBytesNumber();
Logger.info('pixelBytesNumber:', pixelBytesNumber.toString());
// 获取图像像素每行字节数
let rowCount: number = this.pixelMap.getBytesNumberPerRow();
Logger.info('rowCount:', rowCount.toString());
// 获取当前图像像素密度。像素密度是指每英寸图片所拥有的像素数量。像素密度越大,图片越精细。
let getDensity: number = this.pixelMap.getDensity();
Logger.info('getDensity:', getDensity.toString());
// [End pixelmap_get_pixelmap_info]
// [Start pixelmap_bitmap_operation_all]
// 场景一:将读取的整张图像像素数据结果写入ArrayBuffer中
const buffer = new ArrayBuffer(pixelBytesNumber);
await this.pixelMap.readPixelsToBuffer(buffer).then(() => {
Logger.info('Succeeded in reading image pixel data.');
}).catch((error: BusinessError) => {
Logger.error('Failed to read image pixel data. And the error is: ' + String(error));
})
// [StartExclude pixelmap_bitmap_operation_all]
let bufferArr: Uint8Array = new Uint8Array(buffer);
// RGBA_8888格式下,一个像素点由4个字节组成,分别表示Red、Green、Blue、Alpha四个通道的值。
for (let i = 0; i < bufferArr.length; i++) {
switch (i % 4) {
case 0:
bufferArr[i] = MAX_RGB_VALUE;
break;
case 1:
bufferArr[i] = MAX_RGB_VALUE;
break;
case 2:
bufferArr[i] = MIN_RGB_VALUE;
break;
case 3:
bufferArr[i] = MAX_OPACITY;
break;
default:
break;
}
}
// [EndExclude pixelmap_bitmap_operation_all]
this.pixelMap!.writeBufferToPixels(buffer).then(() => {
Logger.info('Succeeded in writing image pixel data.');
this.updateImageInfo();
}).catch((error : BusinessError) => {
Logger.error('Failed to write image pixel data. And the error is: ' + String(error));
})
// [End pixelmap_bitmap_operation_all]
}
|
AST#method_declaration#Left private async bitmapOperationAll AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . pixelMap 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 { // [Start pixelmap_get_pixelmap_info] // 获取图像像素的总字节数 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left pixelBytesNumber : 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 this AST#expression#Right . pixelMap AST#member_expression#Right AST#expression#Right . getPixelBytesNumber AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'pixelBytesNumber:' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left pixelBytesNumber AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 获取图像像素每行字节数 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left rowCount : 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 this AST#expression#Right . pixelMap AST#member_expression#Right AST#expression#Right . getBytesNumberPerRow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'rowCount:' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left rowCount AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 获取当前图像像素密度。像素密度是指每英寸图片所拥有的像素数量。像素密度越大,图片越精细。 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left getDensity : 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 this AST#expression#Right . pixelMap AST#member_expression#Right 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#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 Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'getDensity:' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left getDensity AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // [End pixelmap_get_pixelmap_info] // [Start pixelmap_bitmap_operation_all] // 场景一:将读取的整张图像像素数据结果写入ArrayBuffer中 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left buffer = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ArrayBuffer AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left pixelBytesNumber AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#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 . pixelMap AST#member_expression#Right AST#expression#Right . readPixelsToBuffer AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left buffer AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Succeeded in reading image pixel data.' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'Failed to read image pixel data. And the error is: ' AST#expression#Right + AST#expression#Left String AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // [StartExclude pixelmap_bitmap_operation_all] AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left bufferArr : AST#type_annotation#Left AST#primary_type#Left Uint8Array 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 Uint8Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left buffer 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 // RGBA_8888格式下,一个像素点由4个字节组成,分别表示Red、Green、Blue、Alpha四个通道的值。 AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left bufferArr AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left switch AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right % AST#expression#Left 4 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left { AST#property_assignment#Left AST#property_name#Left case AST#property_name#Right AST#ERROR#Left 0 AST#ERROR#Right : AST#expression#Left AST#subscript_expression#Left AST#expression#Left bufferArr AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#property_assignment#Right = MAX_RGB_VALUE ; AST#ERROR#Right AST#statement#Left AST#break_statement#Left break ; AST#break_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left 1 AST#expression#Right AST#ERROR#Left : bufferArr AST#ERROR#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left = MAX_RGB_VALUE AST#ERROR#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#break_statement#Left break ; AST#break_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left 2 AST#expression#Right AST#ERROR#Left : bufferArr AST#ERROR#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left = MIN_RGB_VALUE AST#ERROR#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#break_statement#Left break ; AST#break_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left 3 AST#expression#Right AST#ERROR#Left : bufferArr AST#ERROR#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left = MAX_OPACITY AST#ERROR#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#break_statement#Left break ; AST#break_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left default AST#expression#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left break AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // [EndExclude pixelmap_bitmap_operation_all] AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . pixelMap AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . writeBufferToPixels AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left buffer AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Succeeded in writing image pixel data.' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . updateImageInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'Failed to write image pixel data. And the error is: ' AST#expression#Right + AST#expression#Left String AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // [End pixelmap_bitmap_operation_all] } AST#block_statement#Right AST#method_declaration#Right
|
private async bitmapOperationAll() {
if (this.pixelMap != undefined) {
let pixelBytesNumber: number = this.pixelMap.getPixelBytesNumber();
Logger.info('pixelBytesNumber:', pixelBytesNumber.toString());
let rowCount: number = this.pixelMap.getBytesNumberPerRow();
Logger.info('rowCount:', rowCount.toString());
let getDensity: number = this.pixelMap.getDensity();
Logger.info('getDensity:', getDensity.toString());
const buffer = new ArrayBuffer(pixelBytesNumber);
await this.pixelMap.readPixelsToBuffer(buffer).then(() => {
Logger.info('Succeeded in reading image pixel data.');
}).catch((error: BusinessError) => {
Logger.error('Failed to read image pixel data. And the error is: ' + String(error));
})
let bufferArr: Uint8Array = new Uint8Array(buffer);
for (let i = 0; i < bufferArr.length; i++) {
switch (i % 4) {
case 0:
bufferArr[i] = MAX_RGB_VALUE;
break;
case 1:
bufferArr[i] = MAX_RGB_VALUE;
break;
case 2:
bufferArr[i] = MIN_RGB_VALUE;
break;
case 3:
bufferArr[i] = MAX_OPACITY;
break;
default:
break;
}
}
this.pixelMap!.writeBufferToPixels(buffer).then(() => {
Logger.info('Succeeded in writing image pixel data.');
this.updateImageInfo();
}).catch((error : BusinessError) => {
Logger.error('Failed to write image pixel data. And the error is: ' + String(error));
})
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/Media/Image/PixelMap/entry/src/main/ets/pages/Index.ets#L322-L373
|
3927c6469bbb97faa81ae2a4649590ab86e4a681
|
gitee
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
ETSUI/OHLayoutAlign/entry/src/main/ets/viewmodel/AttributeModuleData.ets
|
arkts
|
Get Module List Data in Column
|
export function getColumnModuleList(): Array<ContainerModuleItem> {
let columnModuleArray: Array<ContainerModuleItem> = []
COLUMN_MODULE.forEach((item: ContainerModuleItem) => {
columnModuleArray.push(item);
})
return columnModuleArray;
}
|
AST#export_declaration#Left export AST#function_declaration#Left function getColumnModuleList 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 ContainerModuleItem 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 columnModuleArray : 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 ContainerModuleItem AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#ERROR#Left COLUMN_MODULE AST#ERROR#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left ContainerModuleItem AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left columnModuleArray AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left item AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left columnModuleArray AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export function getColumnModuleList(): Array<ContainerModuleItem> {
let columnModuleArray: Array<ContainerModuleItem> = []
COLUMN_MODULE.forEach((item: ContainerModuleItem) => {
columnModuleArray.push(item);
})
return columnModuleArray;
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/ETSUI/OHLayoutAlign/entry/src/main/ets/viewmodel/AttributeModuleData.ets#L33-L39
|
bc2a99922f618881030954acdb5d8704aa06f80e
|
gitee
|
|
wangjinyuan/JS-TS-ArkTS-database.git
|
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
|
npm/alprazolamdiv/11.5.1/package/src/client/voice/opus/OpusScriptEngine.ets
|
arkts
|
encode
|
应用约束10:添加buffer类型和返回类型
|
encode(buffer: Uint8Array): Uint8Array {
super.encode(buffer);
return this.encoder.encode(buffer, 960);
}
|
AST#method_declaration#Left encode AST#parameter_list#Left ( AST#parameter#Left buffer : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left super AST#expression#Right . encode AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left buffer AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . encoder AST#member_expression#Right AST#expression#Right . encode AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left buffer AST#expression#Right , AST#expression#Left 960 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
|
encode(buffer: Uint8Array): Uint8Array {
super.encode(buffer);
return this.encoder.encode(buffer, 960);
}
|
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/client/voice/opus/OpusScriptEngine.ets#L40-L43
|
cacb9b5fd9483be0b20c8fede5222f56d1017474
|
github
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Ability/StageAbility/entry/src/main/ets/model/ButtonClickMethod.ets
|
arkts
|
terminateSecondAbilityForResult
|
Stop SecondAbility itself and return the result.
@param context Context of SecondAbility.
|
terminateSecondAbilityForResult(context: common.UIAbilityContext) {
let abilityResult: common.AbilityResult = {
resultCode: CommonConstants.RESULT_CODE,
want: {
'deviceId': '',
'bundleName': CommonConstants.BUNDLE_NAME,
'abilityName': CommonConstants.SECOND_ABILITY_NAME,
'moduleName': CommonConstants.DEVICE_MODULE_NAME,
'parameters': {
src: returnMessage,
count: CommonConstants.RESULT_NUM_VALUE
}
}
};
// Stop SecondAbility itself and return abilityResult to the startAbilityForResult interface caller
context.terminateSelfWithResult(abilityResult).then(() => {
Logger.info(CommonConstants.TAG, `terminate second ability self succeed with ${JSON.stringify(abilityResult)}`);
}).catch((error: Error) => {
Logger.error(CommonConstants.TAG, `terminate second ability self failed with ${error}`);
});
}
|
AST#method_declaration#Left terminateSecondAbilityForResult AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left abilityResult : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . AbilityResult AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left resultCode AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . RESULT_CODE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left want AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left 'deviceId' AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'bundleName' AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . BUNDLE_NAME AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'abilityName' AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . SECOND_ABILITY_NAME AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'moduleName' AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DEVICE_MODULE_NAME AST#member_expression#Right 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#property_assignment#Left AST#property_name#Left src AST#property_name#Right : AST#expression#Left returnMessage AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left count AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . RESULT_NUM_VALUE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // Stop SecondAbility itself and return abilityResult to the startAbilityForResult interface caller AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . terminateSelfWithResult AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left abilityResult AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` terminate second ability self succeed with 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 abilityResult AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` terminate second ability self failed with 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#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
terminateSecondAbilityForResult(context: common.UIAbilityContext) {
let abilityResult: common.AbilityResult = {
resultCode: CommonConstants.RESULT_CODE,
want: {
'deviceId': '',
'bundleName': CommonConstants.BUNDLE_NAME,
'abilityName': CommonConstants.SECOND_ABILITY_NAME,
'moduleName': CommonConstants.DEVICE_MODULE_NAME,
'parameters': {
src: returnMessage,
count: CommonConstants.RESULT_NUM_VALUE
}
}
};
context.terminateSelfWithResult(abilityResult).then(() => {
Logger.info(CommonConstants.TAG, `terminate second ability self succeed with ${JSON.stringify(abilityResult)}`);
}).catch((error: Error) => {
Logger.error(CommonConstants.TAG, `terminate second ability self failed with ${error}`);
});
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Ability/StageAbility/entry/src/main/ets/model/ButtonClickMethod.ets#L119-L140
|
dd1f1ea8f2a457f4021774bc2bfc253acb1ca66e
|
gitee
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
ef_crypto/src/main/ets/crypto/util/CryptoSyncUtil.ets
|
arkts
|
decodeECB
|
解密-ECB模式
@param str 加密的字符串
@param key 给定秘钥规格密钥
@param symAlgName 秘钥规格
@param symEncryptName 加密规格
@param keyName 密钥长度
@param keyCoding 密钥编码方式(utf8/hex/base64)
@param dataCoding 入参字符串编码方式(hex/base64)
|
static decodeECB(str: string, sm4Key: string, symAlgName: string, symEncryptName: string,
keyName: number, keyCoding: buffer.BufferEncoding, dataCoding: buffer.BufferEncoding): string {
//转换密钥
let symKey = CryptoSyncUtil.convertKeyFromStr(sm4Key, symAlgName, keyName, keyCoding);
// 初始化加解密操作环境:开始解密
let mode = crypto.CryptoMode.DECRYPT_MODE;
//创建解密器
let cipher = crypto.createCipher(symEncryptName);
//初始化解密
cipher.initSync(mode, symKey, null);
//解密
let updateOutput = cipher.doFinalSync({ data: StrAndUintUtil.strContent2Uint8Array(str, dataCoding) });
return StrAndUintUtil.unitArray2StrCoding(updateOutput.data, 'utf8');
}
|
AST#method_declaration#Left static decodeECB AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left sm4Key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left symAlgName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left symEncryptName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left keyName : AST#type_annotation#Left AST#primary_type#Left number 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#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 symKey = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CryptoSyncUtil AST#expression#Right . convertKeyFromStr AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sm4Key AST#expression#Right , AST#expression#Left symAlgName AST#expression#Right , AST#expression#Left keyName AST#expression#Right , AST#expression#Left keyCoding 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 mode = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left crypto AST#expression#Right . CryptoMode AST#member_expression#Right AST#expression#Right . DECRYPT_MODE 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 cipher = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left crypto AST#expression#Right . createCipher AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left symEncryptName AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //初始化解密 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cipher AST#expression#Right . initSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left mode 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#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 updateOutput = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cipher AST#expression#Right . doFinalSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left data AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StrAndUintUtil AST#expression#Right . strContent2Uint8Array AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left dataCoding AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right 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 StrAndUintUtil AST#expression#Right . unitArray2StrCoding AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left updateOutput AST#expression#Right . data AST#member_expression#Right AST#expression#Right , AST#expression#Left 'utf8' 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 decodeECB(str: string, sm4Key: string, symAlgName: string, symEncryptName: string,
keyName: number, keyCoding: buffer.BufferEncoding, dataCoding: buffer.BufferEncoding): string {
let symKey = CryptoSyncUtil.convertKeyFromStr(sm4Key, symAlgName, keyName, keyCoding);
let mode = crypto.CryptoMode.DECRYPT_MODE;
let cipher = crypto.createCipher(symEncryptName);
cipher.initSync(mode, symKey, null);
let updateOutput = cipher.doFinalSync({ data: StrAndUintUtil.strContent2Uint8Array(str, dataCoding) });
return StrAndUintUtil.unitArray2StrCoding(updateOutput.data, 'utf8');
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto/src/main/ets/crypto/util/CryptoSyncUtil.ets#L241-L254
|
459502327a1df41b9186e32f1dc49fe2a24da670
|
gitee
|
jjjjjjava/ffmpeg_tools.git
|
6c73f7540bc7ca3f0d5b3edd7a6c10cb84a26161
|
src/main/ets/ffmpeg/FFmpegCommandBuilder.ets
|
arkts
|
format
|
设置输出格式
|
public format(fmt: string): FFmpegCommandBuilder {
this.formatValue = fmt;
return this;
}
|
AST#method_declaration#Left public format AST#parameter_list#Left ( AST#parameter#Left fmt : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left FFmpegCommandBuilder AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . formatValue AST#member_expression#Right = AST#expression#Left fmt AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left this AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public format(fmt: string): FFmpegCommandBuilder {
this.formatValue = fmt;
return this;
}
|
https://github.com/jjjjjjava/ffmpeg_tools.git/blob/6c73f7540bc7ca3f0d5b3edd7a6c10cb84a26161/src/main/ets/ffmpeg/FFmpegCommandBuilder.ets#L117-L120
|
f6f18651b1c550baaf61a5b1e3ca26463a3cad05
|
github
|
liuchao0739/arkTS_universal_starter.git
|
0ca845f5ae0e78db439dc09f712d100c0dd46ed3
|
entry/src/main/ets/core/crash/CrashReporter.ets
|
arkts
|
init
|
初始化崩溃收集
|
private init(): void {
// 加载本地缓存的崩溃日志
this.loadCachedCrashes();
}
|
AST#method_declaration#Left private init AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { // 加载本地缓存的崩溃日志 AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . loadCachedCrashes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
private init(): void {
this.loadCachedCrashes();
}
|
https://github.com/liuchao0739/arkTS_universal_starter.git/blob/0ca845f5ae0e78db439dc09f712d100c0dd46ed3/entry/src/main/ets/core/crash/CrashReporter.ets#L43-L46
|
804e1fecdbc2aa42a82fe5df8b81a4d44d9575e4
|
github
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/common/types/SettingsTypes.ets
|
arkts
|
同步配置接口
|
export interface SyncConfig {
enabled: boolean;
provider: SyncProvider;
lastSyncTime?: string;
autoSync: boolean;
syncInterval: number; // 小时
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface SyncConfig AST#object_type#Left { AST#type_member#Left enabled : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left provider : AST#type_annotation#Left AST#primary_type#Left SyncProvider AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left lastSyncTime ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left autoSync : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left syncInterval : 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 SyncConfig {
enabled: boolean;
provider: SyncProvider;
lastSyncTime?: string;
autoSync: boolean;
syncInterval: number;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/SettingsTypes.ets#L106-L112
|
54282ac2513cd8a2784b26776afda4c892fa1273
|
github
|
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/styledtext/src/main/ets/model/DataSource.ets
|
arkts
|
getData
|
获取索引对应的数据
@param index 数组索引
|
public getData(index: number): CustomMessage {
return this.messageList[index];
}
|
AST#method_declaration#Left public 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 CustomMessage 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 . messageList 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: number): CustomMessage {
return this.messageList[index];
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/styledtext/src/main/ets/model/DataSource.ets#L33-L35
|
2430771d0066d617c6147c7403338712cf4d69ed
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/ai/ModelConfigService.ets
|
arkts
|
getDefaultEndpoint
|
获取默认API端点
|
public getDefaultEndpoint(provider: ModelProvider): string {
return this.defaultEndpoints[provider];
}
|
AST#method_declaration#Left public getDefaultEndpoint AST#parameter_list#Left ( AST#parameter#Left provider : AST#type_annotation#Left AST#primary_type#Left ModelProvider 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#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . defaultEndpoints AST#member_expression#Right AST#expression#Right [ AST#expression#Left provider 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 getDefaultEndpoint(provider: ModelProvider): string {
return this.defaultEndpoints[provider];
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/ai/ModelConfigService.ets#L377-L379
|
4619211462ef39dda5bf3b696e0e2a2b06c15028
|
github
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/miniplayeranimation/src/main/ets/model/DetailsPage.ets
|
arkts
|
playComponent
|
顶部状态栏高度 自定义播放组件。仅用于UX展示
|
@Builder
playComponent() {
Column() {
Row() {
Text($r('app.string.mini_player_animation_playback_duration'))
.fontSize($r('app.float.mini_player_animation_font_size'))
.opacity($r('app.float.mini_player_animation_time_opacity'))
.fontColor(Color.White)
Slider({
value: Constants.SLIDER_CURRENT_VA,
min: Constants.SLIDER_MIN_VAL,
max: Constants.SLIDER_MAX_VAL,
style: SliderStyle.OutSet
})
.width($r('app.string.mini_player_animation_slider_width'))
.enabled(false) // 仅用于ux展示,不使能slider
.trackColor($r('app.color.mini_player_animation_track_color'))
.selectedColor($r('app.color.mini_player_animation_selected_color'))
.trackThickness($r('app.float.mini_player_animation_track_thickness'))
.onClick(() => {
AlertDialog.show({
message: $r('app.string.mini_player_animation_prompt_info'),
alignment: DialogAlignment.Center
});
})
Text($r('app.string.mini_player_animation_total_playback_duration'))
.fontSize($r('app.float.mini_player_animation_font_size'))
.opacity($r('app.float.mini_player_animation_time_opacity'))
.fontColor(Color.White)
}
.justifyContent(FlexAlign.SpaceEvenly)
.width($r('app.string.mini_player_animation_row_width'))
.margin({
top: $r('app.float.mini_player_animation_margin'),
bottom: $r('app.float.mini_player_animation_margin')
})
Row() {
Image($r('app.media.miniplayeranimation_single_play'))
.size({
width: $r('app.float.mini_player_animation_size'),
height: $r('app.float.mini_player_animation_size')
})
Image($r('app.media.miniplayeranimation_play_previous'))
.size({
width: $r('app.float.mini_player_animation_play_size'),
height: $r('app.float.mini_player_animation_play_size')
})
Image($r('app.media.miniplayeranimation_play'))
.size({
width: $r('app.float.mini_player_animation_big_play_size'),
height: $r('app.float.mini_player_animation_big_play_size')
})
Image($r('app.media.miniplayeranimation_play_next'))
.size({
width: $r('app.float.mini_player_animation_play_size'),
height: $r('app.float.mini_player_animation_play_size')
})
Image($r('app.media.miniplayeranimation_collect'))
.size({
width: $r('app.float.mini_player_animation_size'),
height: $r('app.float.mini_player_animation_size')
})
}
.justifyContent(FlexAlign.SpaceEvenly)
.width($r('app.string.mini_player_animation_full_size'))
}.layoutWeight(Constants.LAYOUT_WEIGHT)
.onClick(() => {
AlertDialog.show({
message: $r('app.string.mini_player_animation_prompt_info'),
alignment: DialogAlignment.Center
});
})
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right playComponent AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.mini_player_animation_playback_duration' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.mini_player_animation_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.mini_player_animation_time_opacity' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Slider ( AST#component_parameters#Left { AST#component_parameter#Left value : AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . SLIDER_CURRENT_VA AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left min : AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . SLIDER_MIN_VAL AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left max : AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . SLIDER_MAX_VAL AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left style : AST#expression#Left AST#member_expression#Left AST#expression#Left SliderStyle AST#expression#Right . OutSet AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.mini_player_animation_slider_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . enabled ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) // 仅用于ux展示,不使能slider AST#modifier_chain_expression#Left . trackColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.mini_player_animation_track_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . selectedColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.mini_player_animation_selected_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . trackThickness ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.mini_player_animation_track_thickness' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AlertDialog AST#expression#Right . show AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.mini_player_animation_prompt_info' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left alignment AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left DialogAlignment AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#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 Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.mini_player_animation_total_playback_duration' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.mini_player_animation_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.mini_player_animation_time_opacity' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceEvenly AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.mini_player_animation_row_width' 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 top AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.mini_player_animation_margin' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.mini_player_animation_margin' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.miniplayeranimation_single_play' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . size ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.mini_player_animation_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.mini_player_animation_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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.miniplayeranimation_play_previous' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . size ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.mini_player_animation_play_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.mini_player_animation_play_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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.miniplayeranimation_play' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . size ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.mini_player_animation_big_play_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.mini_player_animation_big_play_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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.miniplayeranimation_play_next' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . size ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.mini_player_animation_play_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.mini_player_animation_play_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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.miniplayeranimation_collect' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . size ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.mini_player_animation_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.mini_player_animation_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#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 . SpaceEvenly AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.mini_player_animation_full_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . LAYOUT_WEIGHT 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 AlertDialog AST#expression#Right . show AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.mini_player_animation_prompt_info' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left alignment AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left DialogAlignment AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
playComponent() {
Column() {
Row() {
Text($r('app.string.mini_player_animation_playback_duration'))
.fontSize($r('app.float.mini_player_animation_font_size'))
.opacity($r('app.float.mini_player_animation_time_opacity'))
.fontColor(Color.White)
Slider({
value: Constants.SLIDER_CURRENT_VA,
min: Constants.SLIDER_MIN_VAL,
max: Constants.SLIDER_MAX_VAL,
style: SliderStyle.OutSet
})
.width($r('app.string.mini_player_animation_slider_width'))
.enabled(false)
.trackColor($r('app.color.mini_player_animation_track_color'))
.selectedColor($r('app.color.mini_player_animation_selected_color'))
.trackThickness($r('app.float.mini_player_animation_track_thickness'))
.onClick(() => {
AlertDialog.show({
message: $r('app.string.mini_player_animation_prompt_info'),
alignment: DialogAlignment.Center
});
})
Text($r('app.string.mini_player_animation_total_playback_duration'))
.fontSize($r('app.float.mini_player_animation_font_size'))
.opacity($r('app.float.mini_player_animation_time_opacity'))
.fontColor(Color.White)
}
.justifyContent(FlexAlign.SpaceEvenly)
.width($r('app.string.mini_player_animation_row_width'))
.margin({
top: $r('app.float.mini_player_animation_margin'),
bottom: $r('app.float.mini_player_animation_margin')
})
Row() {
Image($r('app.media.miniplayeranimation_single_play'))
.size({
width: $r('app.float.mini_player_animation_size'),
height: $r('app.float.mini_player_animation_size')
})
Image($r('app.media.miniplayeranimation_play_previous'))
.size({
width: $r('app.float.mini_player_animation_play_size'),
height: $r('app.float.mini_player_animation_play_size')
})
Image($r('app.media.miniplayeranimation_play'))
.size({
width: $r('app.float.mini_player_animation_big_play_size'),
height: $r('app.float.mini_player_animation_big_play_size')
})
Image($r('app.media.miniplayeranimation_play_next'))
.size({
width: $r('app.float.mini_player_animation_play_size'),
height: $r('app.float.mini_player_animation_play_size')
})
Image($r('app.media.miniplayeranimation_collect'))
.size({
width: $r('app.float.mini_player_animation_size'),
height: $r('app.float.mini_player_animation_size')
})
}
.justifyContent(FlexAlign.SpaceEvenly)
.width($r('app.string.mini_player_animation_full_size'))
}.layoutWeight(Constants.LAYOUT_WEIGHT)
.onClick(() => {
AlertDialog.show({
message: $r('app.string.mini_player_animation_prompt_info'),
alignment: DialogAlignment.Center
});
})
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/miniplayeranimation/src/main/ets/model/DetailsPage.ets#L39-L116
|
ef2da58e8b91451a78d0e12f85a284f904a2a238
|
gitee
|
openharmony/developtools_profiler
|
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
|
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/utils/Transformer.ets
|
arkts
|
generateTransformedValuesLine
|
Transforms an List of Entry into a float array containing the x and
y values transformed with all matrices for the LINECHART.
@param data
@return
|
public generateTransformedValuesLine(
data: ILineDataSet,
phaseX: number,
phaseY: number,
min: number,
max: number
): number[] {
const count: number = ((max - min) * phaseX + 1) * 2;
if (this.valuePointsForGenerateTransformedValuesLine.length != count) {
this.valuePointsForGenerateTransformedValuesLine = new Array<number>(count);
}
var valuePoints: number[] = this.valuePointsForGenerateTransformedValuesLine;
for (var j = 0; j < count; j += 2) {
var e: Entry = data.getEntryForIndex(j / 2 + min);
if (e != null) {
valuePoints[j] = e.getX();
valuePoints[j + 1] = e.getY() * phaseY;
} else {
valuePoints[j] = 0;
valuePoints[j + 1] = 0;
}
}
this.getValueToPixelMatrix().mapPoints(valuePoints);
return valuePoints;
}
|
AST#method_declaration#Left public generateTransformedValuesLine AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left ILineDataSet AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left phaseX : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left phaseY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left min : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left max : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] 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 count : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left max AST#expression#Right - AST#expression#Left min AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left phaseX 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 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . valuePointsForGenerateTransformedValuesLine AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right != AST#expression#Left count 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 . valuePointsForGenerateTransformedValuesLine AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left count AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left var AST#variable_declarator#Left valuePoints : 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#member_expression#Left AST#expression#Left this AST#expression#Right . valuePointsForGenerateTransformedValuesLine AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left var AST#variable_declarator#Left j = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#binary_expression#Left AST#expression#Left j AST#expression#Right < AST#expression#Left count AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#expression#Left AST#assignment_expression#Left j += AST#expression#Left 2 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left var AST#variable_declarator#Left e : AST#type_annotation#Left AST#primary_type#Left Entry 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 data AST#expression#Right . getEntryForIndex 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 j AST#expression#Right / AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left min AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 e AST#expression#Right != AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left valuePoints AST#expression#Right [ AST#expression#Left j AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left = e AST#ERROR#Right . getX 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#binary_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 valuePoints AST#expression#Right [ AST#expression#Left AST#binary_expression#Left AST#expression#Left j AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left = e AST#ERROR#Right . getY 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 phaseY AST#expression#Right AST#binary_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#subscript_expression#Left AST#expression#Left valuePoints AST#expression#Right [ AST#expression#Left j 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 0 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 valuePoints AST#expression#Right [ AST#expression#Left AST#binary_expression#Left AST#expression#Left j AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_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 0 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getValueToPixelMatrix AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . mapPoints AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left valuePoints 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 valuePoints AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public generateTransformedValuesLine(
data: ILineDataSet,
phaseX: number,
phaseY: number,
min: number,
max: number
): number[] {
const count: number = ((max - min) * phaseX + 1) * 2;
if (this.valuePointsForGenerateTransformedValuesLine.length != count) {
this.valuePointsForGenerateTransformedValuesLine = new Array<number>(count);
}
var valuePoints: number[] = this.valuePointsForGenerateTransformedValuesLine;
for (var j = 0; j < count; j += 2) {
var e: Entry = data.getEntryForIndex(j / 2 + min);
if (e != null) {
valuePoints[j] = e.getX();
valuePoints[j + 1] = e.getY() * phaseY;
} else {
valuePoints[j] = 0;
valuePoints[j + 1] = 0;
}
}
this.getValueToPixelMatrix().mapPoints(valuePoints);
return valuePoints;
}
|
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/utils/Transformer.ets#L177-L206
|
d714d3976240a6fcc6ddd92da100d5b61e48d84b
|
gitee
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/expandtitle/src/main/ets/utils/TitleExpansion.ets
|
arkts
|
animateToThrottle
|
节流器:如果短时间内多次触发了同一事件,那么在函数执行一次后,在一个限期内不再执行
@param {Callback<void>} fn: 动画函数
@param {number} delay: 同一事件触发间隔
@returns
|
animateToThrottle(fn: Callback<void>, delay: number): void {
if (this.throttleStatus) {
// TODO: 性能知识点:播放动画时,系统需要在一个刷新周期内完成动画变化曲线的计算,完成组件布局绘制等操作。建议使用系统提供的动画接口,
// 只需设置曲线类型、终点位置、时长等信息,就能够满足常用的动画功能,减少UI主线程的负载。参考资料:
// https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/arkts-attribute-animation-apis-0000001820879805
animateTo({
duration: this.animationDuration, curve: Curve.FastOutLinearIn
}, fn)
this.throttleStatus = false;
setTimeout(() => {
this.throttleStatus = true;
}, delay)
}
|
AST#method_declaration#Left animateToThrottle AST#parameter_list#Left ( AST#parameter#Left fn : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left delay : 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#member_expression#Left AST#expression#Left this AST#expression#Right . throttleStatus AST#member_expression#Right AST#expression#Right AST#ERROR#Left ) { // TODO: 性能知识点:播放动画时,系统需要在一个刷新周期内完成动画变化曲线的计算,完成组件布局绘制等操作。建议使用系统提供的动画接口, // 只需设置曲线类型、终点位置、时长等信息,就能够满足常用的动画功能,减少UI主线程的负载。参考资料: // https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/arkts-attribute-animation-apis-0000001820879805 AST#property_assignment#Left animateTo AST#property_assignment#Right AST#ERROR#Left ( AST#component_parameters#Left { AST#component_parameter#Left duration : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . animationDuration AST#member_expression#Right 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 . FastOutLinearIn AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right AST#ERROR#Right , AST#property_name#Left fn AST#property_name#Right AST#ERROR#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 . throttleStatus AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left setTimeout AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#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 . throttleStatus AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right , AST#expression#Left delay 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
|
animateToThrottle(fn: Callback<void>, delay: number): void {
if (this.throttleStatus) {
animateTo({
duration: this.animationDuration, curve: Curve.FastOutLinearIn
}, fn)
this.throttleStatus = false;
setTimeout(() => {
this.throttleStatus = true;
}, delay)
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/expandtitle/src/main/ets/utils/TitleExpansion.ets#L237-L249
|
cf7c9e0d491579b81c4492b7f842dc44daac530e
|
gitee
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
UseSendable/entry/src/main/ets/pages/InterThreadCommunication3.ets
|
arkts
|
initSingleton
|
[EndExclude taskpool]
|
@Concurrent
function initSingleton(): void {
let demo = Demo.getInstance();
demo.init();
hilog.info(0x0000, 'InterThreadCommunication3', '%{public}s', `initSingleton success`);
// Notify the main thread that initialization is complete
}
|
AST#decorated_function_declaration#Left AST#decorator#Left @ Concurrent AST#decorator#Right function initSingleton AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left demo = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Demo 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 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 demo AST#expression#Right . init AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#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 'InterThreadCommunication3' AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` initSingleton success ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // Notify the main thread that initialization is complete } AST#block_statement#Right AST#decorated_function_declaration#Right
|
@Concurrent
function initSingleton(): void {
let demo = Demo.getInstance();
demo.init();
hilog.info(0x0000, 'InterThreadCommunication3', '%{public}s', `initSingleton success`);
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/UseSendable/entry/src/main/ets/pages/InterThreadCommunication3.ets#L29-L35
|
f2ea858e16c42e6341974782526c9575a22df53d
|
gitee
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.