nwo
stringclasses 304
values | sha
stringclasses 304
values | path
stringlengths 9
214
| language
stringclasses 1
value | identifier
stringlengths 0
49
| docstring
stringlengths 1
34.2k
| function
stringlengths 8
59.4k
| ast_function
stringlengths 71
497k
| obf_function
stringlengths 8
39.4k
| url
stringlengths 102
324
| function_sha
stringlengths 40
40
| source
stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
Joker-x-dev/CoolMallArkTS.git
|
9f3fabf89fb277692cb82daf734c220c7282919c
|
core/navigation/src/main/ets/common/CommonNavigator.ets
|
arkts
|
toUserAgreement
|
跳转到用户协议
@returns {void} 无返回值
|
static toUserAgreement(): void {
navigateTo(CommonRoutes.UserAgreement);
}
|
AST#method_declaration#Left static toUserAgreement AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_custom_component_statement#Left navigateTo ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonRoutes AST#expression#Right . UserAgreement AST#member_expression#Right AST#expression#Right ) ; AST#ui_custom_component_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
static toUserAgreement(): void {
navigateTo(CommonRoutes.UserAgreement);
}
|
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/navigation/src/main/ets/common/CommonNavigator.ets#L30-L32
|
3e5b6decd0bef394c883e5534a344914f17d2a97
|
github
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/common/utils/LunarCalendar.ets
|
arkts
|
formatLunarDate
|
格式化农历日期为字符串
@param lunarDate 农历日期
@returns 格式化的农历日期字符串
|
static formatLunarDate(lunarDate: LunarDate): string {
const festival = LunarCalendar.getLunarFestival(lunarDate.month, lunarDate.day, lunarDate.isLeapMonth);
if (festival) {
return festival;
}
return `${lunarDate.monthName}${lunarDate.dayName}`;
}
|
AST#method_declaration#Left static formatLunarDate AST#parameter_list#Left ( AST#parameter#Left lunarDate : AST#type_annotation#Left AST#primary_type#Left LunarDate 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 festival = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LunarCalendar AST#expression#Right . getLunarFestival AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left lunarDate AST#expression#Right . month AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left lunarDate AST#expression#Right . day AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left lunarDate AST#expression#Right . isLeapMonth 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 festival AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left festival 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#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left lunarDate AST#expression#Right . monthName 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 lunarDate AST#expression#Right . dayName AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static formatLunarDate(lunarDate: LunarDate): string {
const festival = LunarCalendar.getLunarFestival(lunarDate.month, lunarDate.day, lunarDate.isLeapMonth);
if (festival) {
return festival;
}
return `${lunarDate.monthName}${lunarDate.dayName}`;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/utils/LunarCalendar.ets#L512-L519
|
ed96b66eaa6149375877bc0ad28b9b01ec43a9a2
|
github
|
openharmony/xts_acts
|
5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686
|
arkui/ace_ets_module_ui/ace_ets_module_scroll/ace_ets_module_scroll_nowear_api13/entry/src/main/ets/MainAbility/pages/WaterFlow/WaterFlowDataSource.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 WaterFlowDataSource implements IDataSource {
private dataArray: number[] = []
private listeners: DataChangeListener[] = []
constructor
|
AST#export_declaration#Left export AST#ERROR#Left class WaterFlowDataSource AST#implements_clause#Left implements IDataSource AST#implements_clause#Right { AST#property_declaration#Left private dataArray : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#property_declaration#Right private listeners : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left DataChangeListener [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#ERROR#Right AST#variable_declaration#Left const AST#variable_declarator#Left ructor AST#variable_declarator#Right AST#variable_declaration#Right AST#export_declaration#Right
|
export class WaterFlowDataSource implements IDataSource {
private dataArray: number[] = []
private listeners: DataChangeListener[] = []
constructor
|
https://github.com/openharmony/xts_acts/blob/5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686/arkui/ace_ets_module_ui/ace_ets_module_scroll/ace_ets_module_scroll_nowear_api13/entry/src/main/ets/MainAbility/pages/WaterFlow/WaterFlowDataSource.ets#L15-L19
|
a4abc4339f49df2eff78052c28acda662e11cdf9
|
gitee
|
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/common/types/CommonTypes.ets
|
arkts
|
备份位置枚举
|
export enum BackupLocation {
LOCAL = 'local',
ICLOUD = 'icloud',
GOOGLE_DRIVE = 'google_drive',
CUSTOM = 'custom'
}
|
AST#export_declaration#Left export AST#enum_declaration#Left enum BackupLocation AST#enum_body#Left { AST#enum_member#Left LOCAL = AST#expression#Left 'local' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left ICLOUD = AST#expression#Left 'icloud' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left GOOGLE_DRIVE = AST#expression#Left 'google_drive' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left CUSTOM = AST#expression#Left 'custom' AST#expression#Right AST#enum_member#Right } AST#enum_body#Right AST#enum_declaration#Right AST#export_declaration#Right
|
export enum BackupLocation {
LOCAL = 'local',
ICLOUD = 'icloud',
GOOGLE_DRIVE = 'google_drive',
CUSTOM = 'custom'
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/CommonTypes.ets#L307-L312
|
fadac7a711c24d7b3939dce84df6802a1d0cfbb4
|
github
|
|
JackJiang2011/harmonychat.git
|
bca3f3e1ce54d763720510f99acf595a49e37879
|
entry/src/main/ets/pages/model/MessagesProvider.ets
|
arkts
|
clear
|
清空所有消息。
|
clear(): void {
this.messages = [];
}
|
AST#method_declaration#Left clear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#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 . messages 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#builder_function_body#Right AST#method_declaration#Right
|
clear(): void {
this.messages = [];
}
|
https://github.com/JackJiang2011/harmonychat.git/blob/bca3f3e1ce54d763720510f99acf595a49e37879/entry/src/main/ets/pages/model/MessagesProvider.ets#L130-L132
|
4d2f3ff8943b1b62d76ddec585a2e8c3f7130da6
|
github
|
Joker-x-dev/CoolMallArkTS.git
|
9f3fabf89fb277692cb82daf734c220c7282919c
|
core/network/src/main/ets/datasource/order/OrderNetworkDataSourceImpl.ets
|
arkts
|
getOrderInfo
|
获取订单详情
@param {number} id - 订单 ID
@returns {Promise<NetworkResponse<Order>>} 订单详情
|
async getOrderInfo(id: number): Promise<NetworkResponse<Order>> {
const resp: AxiosResponse<NetworkResponse<Order>> =
await NetworkClient.http.get("order/info/info", { params: { id } });
return resp.data;
}
|
AST#method_declaration#Left async getOrderInfo AST#parameter_list#Left ( AST#parameter#Left id : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left NetworkResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Order AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left resp : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left AxiosResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left NetworkResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Order AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left NetworkClient AST#expression#Right AST#await_expression#Right AST#expression#Right . http AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "order/info/info" AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left params AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left id AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left resp AST#expression#Right . data AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async getOrderInfo(id: number): Promise<NetworkResponse<Order>> {
const resp: AxiosResponse<NetworkResponse<Order>> =
await NetworkClient.http.get("order/info/info", { params: { id } });
return resp.data;
}
|
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/network/src/main/ets/datasource/order/OrderNetworkDataSourceImpl.ets#L114-L118
|
e310427c3c9823c3ac358ca5cbf4dc360b0a4029
|
github
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/BasicFeature/Security/KeyManager/entry/src/main/ets/server/LocalMockServer.ets
|
arkts
|
createKey
|
生成证书
|
async createKey() {
sendProcessMessage("模拟服务端开始生成证书", MessagePosition.Left);
let rsaKey: RsaKey | undefined = await generateRsaKey()
if (rsaKey) {
this.publicKey = rsaKey.publicKey;
this.privateKey = rsaKey.privateKey;
sendProcessMessage("模拟服务端生成证书成功,公钥:" + this.publicKey, MessagePosition.Left);
}
}
|
AST#method_declaration#Left async createKey AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_custom_component_statement#Left sendProcessMessage ( AST#expression#Left "模拟服务端开始生成证书" AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left MessagePosition AST#expression#Right . Left AST#member_expression#Right AST#expression#Right ) ; AST#ui_custom_component_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 rsaKey AST#ERROR#Left : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left RsaKey AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#ERROR#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left generateRsaKey AST#expression#Right AST#await_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left rsaKey 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 . publicKey AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left rsaKey AST#expression#Right . publicKey AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . privateKey AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left rsaKey AST#expression#Right . privateKey AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left sendProcessMessage ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left "模拟服务端生成证书成功,公钥:" AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . publicKey AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left MessagePosition AST#expression#Right . Left AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
async createKey() {
sendProcessMessage("模拟服务端开始生成证书", MessagePosition.Left);
let rsaKey: RsaKey | undefined = await generateRsaKey()
if (rsaKey) {
this.publicKey = rsaKey.publicKey;
this.privateKey = rsaKey.privateKey;
sendProcessMessage("模拟服务端生成证书成功,公钥:" + this.publicKey, MessagePosition.Left);
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/BasicFeature/Security/KeyManager/entry/src/main/ets/server/LocalMockServer.ets#L39-L47
|
684c2767626b0973659cbb57127fe2be6677facf
|
gitee
|
queyun123/weatherApp-ArkTS.git
|
6beee6640db32ae70c342866b24fc643a9c512bf
|
entry/src/main/ets/utils/HttpUtil.ets
|
arkts
|
get
|
===================== 基础GET请求(优化版) =====================
|
static async get<T>(url: string): Promise<BaseResponse<T> | null> {
console.log('HTTP GET 请求URL:', url);
const httpRequest = http.createHttp();
try {
const response = await httpRequest.request(url, {
method: http.RequestMethod.GET,
connectTimeout: 10000, // 10秒连接超时
readTimeout: 10000 // 10秒读取超时
});
// 状态码非200直接返回null
if (response.responseCode !== 200) {
console.error('HTTP请求失败,状态码:', response.responseCode);
return null;
}
// 解析JSON响应
const result = JSON.parse(response.result.toString()) as BaseResponse<T>;
console.log('HTTP响应数据:', result);
return result;
} catch (error) {
console.error('HTTP请求异常:', JSON.stringify(error));
return null;
} finally {
// 销毁请求实例,释放资源
httpRequest.destroy();
}
}
|
AST#method_declaration#Left static async get AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left url : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#generic_type#Left BaseResponse 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#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'HTTP GET 请求URL:' AST#expression#Right , AST#expression#Left url AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left httpRequest = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . createHttp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left response = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left httpRequest AST#expression#Right AST#await_expression#Right AST#expression#Right . request AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left url AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left method AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . RequestMethod AST#member_expression#Right AST#expression#Right . GET AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left connectTimeout AST#property_name#Right : AST#expression#Left 10000 AST#expression#Right AST#property_assignment#Right , // 10秒连接超时 AST#property_assignment#Left AST#property_name#Left readTimeout AST#property_name#Right : AST#expression#Left 10000 AST#expression#Right AST#property_assignment#Right // 10秒读取超时 } 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 // 状态码非200直接返回null AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . responseCode AST#member_expression#Right AST#expression#Right !== AST#expression#Left 200 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'HTTP请求失败,状态码:' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . responseCode AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 解析JSON响应 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left result = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . result AST#member_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left BaseResponse 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#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'HTTP响应数据:' AST#expression#Right , AST#expression#Left result AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'HTTP请求异常:' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#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#finally_clause#Left finally AST#block_statement#Left { // 销毁请求实例,释放资源 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left httpRequest AST#expression#Right . destroy AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#finally_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static async get<T>(url: string): Promise<BaseResponse<T> | null> {
console.log('HTTP GET 请求URL:', url);
const httpRequest = http.createHttp();
try {
const response = await httpRequest.request(url, {
method: http.RequestMethod.GET,
connectTimeout: 10000,
readTimeout: 10000
});
if (response.responseCode !== 200) {
console.error('HTTP请求失败,状态码:', response.responseCode);
return null;
}
const result = JSON.parse(response.result.toString()) as BaseResponse<T>;
console.log('HTTP响应数据:', result);
return result;
} catch (error) {
console.error('HTTP请求异常:', JSON.stringify(error));
return null;
} finally {
httpRequest.destroy();
}
}
|
https://github.com/queyun123/weatherApp-ArkTS.git/blob/6beee6640db32ae70c342866b24fc643a9c512bf/entry/src/main/ets/utils/HttpUtil.ets#L21-L49
|
edb8ac5eee382ba022076abbc73dcf2756625c84
|
github
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/common/types/CommonTypes.ets
|
arkts
|
语言枚举
|
export enum Language {
ZH_CN = 'zh_CN',
EN_US = 'en_US'
}
|
AST#export_declaration#Left export AST#enum_declaration#Left enum Language AST#enum_body#Left { AST#enum_member#Left ZH_CN = AST#expression#Left 'zh_CN' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left EN_US = AST#expression#Left 'en_US' AST#expression#Right AST#enum_member#Right } AST#enum_body#Right AST#enum_declaration#Right AST#export_declaration#Right
|
export enum Language {
ZH_CN = 'zh_CN',
EN_US = 'en_US'
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/CommonTypes.ets#L45-L48
|
f20d27751ca44ea0964778b704e0f140d723be4e
|
github
|
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/skeletondiagram/src/main/ets/view/ListView.ets
|
arkts
|
刚加载完成无选中状态
|
build() {
Column() {
List({ space: CommonConstants.SPACE_12 }) {
LazyForEach(this.listData, (item: Model) => {
ListItem() {
ItemView({ item: item, isSelected: this.selectedId === item.id })
}
.onClick(() => {
this.selectedId = item.id;
promptAction.showToast({ message: $r('app.string.ske_prompt_text') });
})
}, (item: Model) => item.id.toString())
}
.id('skeleton_list')
.padding({
left: $r("app.float.ske_md_padding_margin"),
right: $r("app.float.ske_md_padding_margin")
})
.width(CommonConstants.FULL_PERCENT)
.height(CommonConstants.FULL_PERCENT)
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
}
}
|
AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left List ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . SPACE_12 AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#lazy_for_each_statement#Left LazyForEach ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . listData AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left Model 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 ListItem ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ItemView ( AST#component_parameters#Left { AST#component_parameter#Left item : AST#expression#Left item AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left isSelected : 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 . selectedId AST#member_expression#Right AST#expression#Right === AST#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . 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 . selectedId AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . id 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 promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.ske_prompt_text' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left Model AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . id AST#member_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#lazy_for_each_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . id ( AST#expression#Left 'skeleton_list' 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.float.ske_md_padding_margin" 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.float.ske_md_padding_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 . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FULL_PERCENT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FULL_PERCENT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . expandSafeArea ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left SafeAreaType AST#expression#Right . SYSTEM AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left SafeAreaEdge AST#expression#Right . BOTTOM AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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#build_body#Right AST#build_method#Right
|
build() {
Column() {
List({ space: CommonConstants.SPACE_12 }) {
LazyForEach(this.listData, (item: Model) => {
ListItem() {
ItemView({ item: item, isSelected: this.selectedId === item.id })
}
.onClick(() => {
this.selectedId = item.id;
promptAction.showToast({ message: $r('app.string.ske_prompt_text') });
})
}, (item: Model) => item.id.toString())
}
.id('skeleton_list')
.padding({
left: $r("app.float.ske_md_padding_margin"),
right: $r("app.float.ske_md_padding_margin")
})
.width(CommonConstants.FULL_PERCENT)
.height(CommonConstants.FULL_PERCENT)
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
}
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/skeletondiagram/src/main/ets/view/ListView.ets#L27-L49
|
074b509416a432063a1d6a7f679ae83b52e3aaf4
|
gitee
|
|
openharmony-tpc-incubate/photo-deal-demo
|
01382ce30b1785f8fc8bc14f6b94f0a670a5b50b
|
library/src/main/ets/controller/EditController.ets
|
arkts
|
addRecord
|
添加一条记录
@param record 操作记录
|
addRecord(record: OperateRecord): void {
this.operateRecords.push(record);
this.onRecordsChanged();
}
|
AST#method_declaration#Left addRecord AST#parameter_list#Left ( AST#parameter#Left record : AST#type_annotation#Left AST#primary_type#Left OperateRecord AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . operateRecords AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left record 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 . onRecordsChanged 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
|
addRecord(record: OperateRecord): void {
this.operateRecords.push(record);
this.onRecordsChanged();
}
|
https://github.com/openharmony-tpc-incubate/photo-deal-demo/blob/01382ce30b1785f8fc8bc14f6b94f0a670a5b50b/library/src/main/ets/controller/EditController.ets#L144-L147
|
6bf54a456ac9086444fc15ed440f831bb83c1442
|
gitee
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Media/ImageEdit/entry/src/main/ets/utils/DrawingUtils.ets
|
arkts
|
drawLineButton
|
Draw line.
@param ctx
@param crop
@param vp3
@param padding
@param cornerLength
|
private static drawLineButton(ctx: CanvasRenderingContext2D, crop: RectF,
vp3: number, padding: number, cornerLength: number) {
vp3 = vp3 / 2;
// top button
let startX = crop.getCenterX() - cornerLength / 2;
let startY = crop.top - vp3;
let stopX = startX + cornerLength;
let stopY = startY;
DrawingUtils.drawLine(ctx, startX, startY, stopX, stopY);
// bottom button
startX = crop.getCenterX() - cornerLength / 2;
startY = crop.bottom + vp3;
stopX = startX + cornerLength;
stopY = startY;
DrawingUtils.drawLine(ctx, startX, startY, stopX, stopY);
// left button
startX = crop.left - vp3;
startY = crop.getCenterY() - cornerLength / 2;
stopX = startX;
stopY = startY + cornerLength;
DrawingUtils.drawLine(ctx, startX, startY, stopX, stopY);
// right button
startX = crop.right + vp3;
startY = crop.getCenterY() - cornerLength / 2;
stopX = startX;
stopY = startY + cornerLength;
DrawingUtils.drawLine(ctx, startX, startY, stopX, stopY);
}
|
AST#method_declaration#Left private static drawLineButton AST#parameter_list#Left ( AST#parameter#Left ctx : AST#type_annotation#Left AST#primary_type#Left CanvasRenderingContext2D AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left crop : AST#type_annotation#Left AST#primary_type#Left RectF AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left vp3 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left padding : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left cornerLength : 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 vp3 = AST#expression#Left AST#binary_expression#Left AST#expression#Left vp3 AST#expression#Right / AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // top button AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left startX = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left crop AST#expression#Right . getCenterX 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 cornerLength 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#variable_declaration#Left let AST#variable_declarator#Left startY = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left crop AST#expression#Right . top AST#member_expression#Right AST#expression#Right - AST#expression#Left vp3 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left stopX = AST#expression#Left AST#binary_expression#Left AST#expression#Left startX AST#expression#Right + AST#expression#Left cornerLength AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left stopY = AST#expression#Left startY 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 DrawingUtils AST#expression#Right . drawLine AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left ctx AST#expression#Right , AST#expression#Left startX AST#expression#Right , AST#expression#Left startY AST#expression#Right , AST#expression#Left stopX AST#expression#Right , AST#expression#Left stopY AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // bottom button AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left startX = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left crop AST#expression#Right . getCenterX 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 cornerLength 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#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 startY = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left crop AST#expression#Right . bottom AST#member_expression#Right AST#expression#Right + AST#expression#Left vp3 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 stopX = AST#expression#Left AST#binary_expression#Left AST#expression#Left startX AST#expression#Right + AST#expression#Left cornerLength 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 stopY = AST#expression#Left startY 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 DrawingUtils AST#expression#Right . drawLine AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left ctx AST#expression#Right , AST#expression#Left startX AST#expression#Right , AST#expression#Left startY AST#expression#Right , AST#expression#Left stopX AST#expression#Right , AST#expression#Left stopY AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // left button AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left startX = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left crop AST#expression#Right . left AST#member_expression#Right AST#expression#Right - AST#expression#Left vp3 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 startY = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left crop AST#expression#Right . getCenterY 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 cornerLength 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#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 stopX = AST#expression#Left startX 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 stopY = AST#expression#Left AST#binary_expression#Left AST#expression#Left startY AST#expression#Right + AST#expression#Left cornerLength 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 AST#member_expression#Left AST#expression#Left DrawingUtils AST#expression#Right . drawLine AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left ctx AST#expression#Right , AST#expression#Left startX AST#expression#Right , AST#expression#Left startY AST#expression#Right , AST#expression#Left stopX AST#expression#Right , AST#expression#Left stopY AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // right button AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left startX = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left crop AST#expression#Right . right AST#member_expression#Right AST#expression#Right + AST#expression#Left vp3 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 startY = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left crop AST#expression#Right . getCenterY 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 cornerLength 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#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 stopX = AST#expression#Left startX 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 stopY = AST#expression#Left AST#binary_expression#Left AST#expression#Left startY AST#expression#Right + AST#expression#Left cornerLength 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 AST#member_expression#Left AST#expression#Left DrawingUtils AST#expression#Right . drawLine AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left ctx AST#expression#Right , AST#expression#Left startX AST#expression#Right , AST#expression#Left startY AST#expression#Right , AST#expression#Left stopX AST#expression#Right , AST#expression#Left stopY 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 static drawLineButton(ctx: CanvasRenderingContext2D, crop: RectF,
vp3: number, padding: number, cornerLength: number) {
vp3 = vp3 / 2;
let startX = crop.getCenterX() - cornerLength / 2;
let startY = crop.top - vp3;
let stopX = startX + cornerLength;
let stopY = startY;
DrawingUtils.drawLine(ctx, startX, startY, stopX, stopY);
startX = crop.getCenterX() - cornerLength / 2;
startY = crop.bottom + vp3;
stopX = startX + cornerLength;
stopY = startY;
DrawingUtils.drawLine(ctx, startX, startY, stopX, stopY);
startX = crop.left - vp3;
startY = crop.getCenterY() - cornerLength / 2;
stopX = startX;
stopY = startY + cornerLength;
DrawingUtils.drawLine(ctx, startX, startY, stopX, stopY);
startX = crop.right + vp3;
startY = crop.getCenterY() - cornerLength / 2;
stopX = startX;
stopY = startY + cornerLength;
DrawingUtils.drawLine(ctx, startX, startY, stopX, stopY);
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Media/ImageEdit/entry/src/main/ets/utils/DrawingUtils.ets#L178-L208
|
cdcac6ac6480fbf73de0c170ff506ae7d545582b
|
gitee
|
fengmingdev/protobuf-arkts-generator.git
|
75888d404fd6ce52a046cba2a94807ecf1350147
|
runtime/arkpb/util.ets
|
arkts
|
Decode base64 string to bytes; throws on invalid length/alphabet
|
export function decodeBase64(str: string): Uint8Array {
const s = str.replace(/\s+/g, '')
if (s.length % 4 !== 0) throw new Error('invalid base64')
const len = s.endsWith('==') ? (s.length / 4) * 3 - 2 : s.endsWith('=') ? (s.length / 4) * 3 - 1 : (s.length / 4) * 3
const out = new Uint8Array(len)
let o = 0
for (let i = 0; i < s.length; i += 4) {
const c0 = s.charAt(i), c1 = s.charAt(i+1), c2 = s.charAt(i+2), c3 = s.charAt(i+3)
const v0 = b64lookup[c0], v1 = b64lookup[c1]
const v2 = c2 === '=' ? 0 : b64lookup[c2]
const v3 = c3 === '=' ? 0 : b64lookup[c3]
const b0 = (v0 << 2) | (v1 >> 4)
out[o++] = b0 & 0xFF
if (c2 !== '=') {
const b1 = ((v1 & 0x0F) << 2) | (v2 >> 4)
out[o++] = b1 & 0xFF
}
if (c3 !== '=') {
const b2 = ((v2 & 0x0F) << 6) | v3
out[o++] = b2 & 0xFF
}
}
return out
}
|
AST#export_declaration#Left export AST#function_declaration#Left function decodeBase64 AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#ERROR#Left const AST#variable_declarator#Left s = 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 str AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#argument_list#Right AST#call_expression#Right AST#expression#Right / AST#ERROR#Left \s AST#ERROR#Right AST#expression#Left AST#unary_expression#Left + AST#expression#Left AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right / AST#expression#Left g AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right , '' ) AST#ERROR#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left s AST#expression#Right . length AST#member_expression#Right AST#expression#Right % AST#expression#Left 4 AST#expression#Right AST#binary_expression#Right AST#expression#Right !== AST#expression#Left 0 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 'invalid base64' 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#variable_declaration#Left const AST#variable_declarator#Left len = AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left s AST#expression#Right . endsWith AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '==' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ? AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left s AST#expression#Right . length AST#member_expression#Right AST#expression#Right / AST#expression#Left 4 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left 3 AST#expression#Right AST#binary_expression#Right AST#expression#Right - AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right : AST#expression#Left s AST#expression#Right AST#conditional_expression#Right AST#expression#Right . endsWith AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '=' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ? AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left s AST#expression#Right . length AST#member_expression#Right AST#expression#Right / AST#expression#Left 4 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left 3 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#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 s AST#expression#Right . length AST#member_expression#Right AST#expression#Right / AST#expression#Left 4 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left 3 AST#expression#Right AST#binary_expression#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#variable_declaration#Left const AST#variable_declarator#Left out = 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 len 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 o = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left s AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#assignment_expression#Left i += AST#expression#Left 4 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left c0 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left s AST#expression#Right . charAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left i AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right , AST#variable_declarator#Left c1 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left s AST#expression#Right . charAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right , AST#variable_declarator#Left c2 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left s AST#expression#Right . charAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right + AST#expression#Left 2 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_declarator#Left c3 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left s AST#expression#Right . charAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right + AST#expression#Left 3 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 v0 = AST#expression#Left AST#subscript_expression#Left AST#expression#Left b64lookup AST#expression#Right [ AST#expression#Left c0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right , AST#variable_declarator#Left v1 = AST#expression#Left AST#subscript_expression#Left AST#expression#Left b64lookup AST#expression#Right [ AST#expression#Left c1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left v2 = AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left c2 AST#expression#Right === AST#expression#Left '=' AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 0 AST#expression#Right : AST#expression#Left AST#subscript_expression#Left AST#expression#Left b64lookup AST#expression#Right [ AST#expression#Left c2 AST#expression#Right ] AST#subscript_expression#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#variable_declaration#Left const AST#variable_declarator#Left v3 = AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left c3 AST#expression#Right === AST#expression#Left '=' AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 0 AST#expression#Right : AST#expression#Left AST#subscript_expression#Left AST#expression#Left b64lookup AST#expression#Right [ AST#expression#Left c3 AST#expression#Right ] AST#subscript_expression#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#variable_declaration#Left const AST#variable_declarator#Left b0 AST#ERROR#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 v0 AST#expression#Right << AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right | AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left v1 AST#expression#Right >> AST#expression#Left 4 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#ERROR#Left out AST#ERROR#Right [ AST#expression#Left AST#update_expression#Left AST#expression#Left o AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#ERROR#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left b0 AST#expression#Right & AST#expression#Left 0xFF 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 c2 AST#expression#Right !== AST#expression#Left '=' 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 b1 AST#ERROR#Left = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left v1 AST#expression#Right & AST#expression#Left 0x0F AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right << AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right | AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left v2 AST#expression#Right >> AST#expression#Left 4 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#ERROR#Left out AST#ERROR#Right [ AST#expression#Left AST#update_expression#Left AST#expression#Left o AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#ERROR#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left b1 AST#expression#Right & AST#expression#Left 0xFF AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left c3 AST#expression#Right !== AST#expression#Left '=' 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 b2 AST#ERROR#Left = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left v2 AST#expression#Right & AST#expression#Left 0x0F AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right << AST#expression#Left 6 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right | AST#expression#Left AST#subscript_expression#Left AST#expression#Left v3 AST#expression#Right AST#ERROR#Left out AST#ERROR#Right [ AST#expression#Left AST#update_expression#Left AST#expression#Left o AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#ERROR#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left b2 AST#expression#Right & AST#expression#Left 0xFF AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left out AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export function decodeBase64(str: string): Uint8Array {
const s = str.replace(/\s+/g, '')
if (s.length % 4 !== 0) throw new Error('invalid base64')
const len = s.endsWith('==') ? (s.length / 4) * 3 - 2 : s.endsWith('=') ? (s.length / 4) * 3 - 1 : (s.length / 4) * 3
const out = new Uint8Array(len)
let o = 0
for (let i = 0; i < s.length; i += 4) {
const c0 = s.charAt(i), c1 = s.charAt(i+1), c2 = s.charAt(i+2), c3 = s.charAt(i+3)
const v0 = b64lookup[c0], v1 = b64lookup[c1]
const v2 = c2 === '=' ? 0 : b64lookup[c2]
const v3 = c3 === '=' ? 0 : b64lookup[c3]
const b0 = (v0 << 2) | (v1 >> 4)
out[o++] = b0 & 0xFF
if (c2 !== '=') {
const b1 = ((v1 & 0x0F) << 2) | (v2 >> 4)
out[o++] = b1 & 0xFF
}
if (c3 !== '=') {
const b2 = ((v2 & 0x0F) << 6) | v3
out[o++] = b2 & 0xFF
}
}
return out
}
|
https://github.com/fengmingdev/protobuf-arkts-generator.git/blob/75888d404fd6ce52a046cba2a94807ecf1350147/runtime/arkpb/util.ets#L86-L109
|
015f79340e5a2bd7eca19b136346b119b5dcb139
|
github
|
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/common/types/SettingsTypes.ets
|
arkts
|
主题设置接口(为ThemeSettings别名)
|
export interface ThemeSettings extends ThemeConfig {
// 继承ThemeConfig的所有属性
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface ThemeSettings AST#extends_clause#Left extends ThemeConfig AST#extends_clause#Right AST#object_type#Left { // 继承ThemeConfig的所有属性 } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
|
export interface ThemeSettings extends ThemeConfig {
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/SettingsTypes.ets#L41-L43
|
e3344d2c737532762ae8f35c273ff955aa727ad3
|
github
|
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/Solutions/IM/Chat/features/chatlist/src/main/ets/viewmodel/ChatListDataSource.ets
|
arkts
|
deleteDataByIndex
|
删除列表中处于index位置的对象
|
public deleteDataByIndex(index: number): void {
Logger.info(TAG, `delete data , index = ${index}}`);
this.chatList.splice(index, 1);
this.notifyDataDelete(index);
}
|
AST#method_declaration#Left public deleteDataByIndex AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 ` delete data , index = AST#template_substitution#Left $ { AST#expression#Left index AST#expression#Right } AST#template_substitution#Right } ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . chatList AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . notifyDataDelete AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
public deleteDataByIndex(index: number): void {
Logger.info(TAG, `delete data , index = ${index}}`);
this.chatList.splice(index, 1);
this.notifyDataDelete(index);
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Solutions/IM/Chat/features/chatlist/src/main/ets/viewmodel/ChatListDataSource.ets#L49-L53
|
a5bcd3c0d4670783377670cfe38a737596cd7c78
|
gitee
|
openharmony/developtools_profiler
|
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
|
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/data/BaseEntry.ets
|
arkts
|
getY
|
Returns the y value of this Entry.
@return
|
public getY(): number {
return this.y;
}
|
AST#method_declaration#Left public getY AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . y AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public getY(): number {
return this.y;
}
|
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/data/BaseEntry.ets#L42-L44
|
436a370706a18e18d87163215e88ca98e1617e0c
|
gitee
|
RedRackham-R/WanAndroidHarmoney.git
|
0bb2a7c8d7b49194a96e42a380d43b7e106cdb22
|
entry/src/main/ets/global/viewmodel/GlobalCollectViewModel.ets
|
arkts
|
subscribeCollectUrlEvent
|
收藏Url事件
@param key
@param callback
|
subscribeCollectUrlEvent(key: string, callback: (eventData: emitter.EventData) => void) {
EventBus.getInstance().regist(WanEventId.EVENT_COLLECT_URL, key, callback)
}
|
AST#method_declaration#Left subscribeCollectUrlEvent AST#parameter_list#Left ( AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left callback : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left eventData : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left emitter . EventData 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#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left EventBus 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 . regist AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left WanEventId AST#expression#Right . EVENT_COLLECT_URL AST#member_expression#Right AST#expression#Right , AST#expression#Left key AST#expression#Right , AST#expression#Left callback AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
subscribeCollectUrlEvent(key: string, callback: (eventData: emitter.EventData) => void) {
EventBus.getInstance().regist(WanEventId.EVENT_COLLECT_URL, key, callback)
}
|
https://github.com/RedRackham-R/WanAndroidHarmoney.git/blob/0bb2a7c8d7b49194a96e42a380d43b7e106cdb22/entry/src/main/ets/global/viewmodel/GlobalCollectViewModel.ets#L112-L114
|
57106c4eab38b65cad2ff9fb5f5cd2744c46f020
|
github
|
XiangRui_FuZi/harmony-oscourse
|
da885f9a777a1eace7a07e1cd81137746687974b
|
class1/entry/src/main/ets/view/TopArea.ets
|
arkts
|
TopArea
|
Top area.
|
@Component
export struct TopArea {
@State isEdit: boolean = false;
build() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
Row() {
Row() {
Image($r('app.media.ic_public_cancel'))
.width($r('app.integer.cancel_icon_size'))
.height($r('app.integer.cancel_icon_size'))
.onClick(() => {
let context = getContext() as common.UIAbilityContext;
context.terminateSelf();
})
}
.justifyContent(FlexAlign.Center)
.margin({ right: $r('app.integer.cancel_icon_right') })
.width($r('app.integer.top_area_size'))
.height($r('app.integer.top_area_size'))
.backgroundColor($r('app.color.background_color4'))
.borderRadius($r('app.integer.top_area_radius'))
Text($r('app.string.text_posts'))
.fontSize($r('app.integer.text_size_headline8'))
.fontWeight(FontWeight.Bold)
}
Row() {
Text($r('app.string.text_publish'))
.fontSize($r('app.integer.text_size_body3'))
.textAlign(TextAlign.Center)
.fontColor($r('app.color.default_white_background'))
}
.justifyContent(FlexAlign.Center)
.borderRadius($r('app.integer.border_radius5'))
.width($r('app.integer.text_publish_width'))
.height($r('app.integer.text_publish_height'))
.backgroundColor(this.isEdit ? $r('app.color.background_color2') : $r('app.color.background_color3'))
.onClick(() => {
this.isEdit = !this.isEdit;
})
}
.width(CommonConstants.FULL_PERCENT)
.height($r('app.integer.top_area_height'))
.padding({
right: $r('app.integer.comm_padding_margin'),
left: $r('app.integer.comm_padding_margin')
})
.margin({
top: $r('app.integer.comm_padding_margin'),
bottom: $r('app.integer.comm_padding_margin')
})
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct TopArea AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right isEdit : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Flex ( AST#component_parameters#Left { AST#component_parameter#Left justifyContent : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceBetween AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left alignItems : AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) 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.ic_public_cancel' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.cancel_icon_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.cancel_icon_size' 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#variable_declaration#Left let AST#variable_declarator#Left context = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . terminateSelf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.cancel_icon_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 . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.top_area_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.top_area_size' 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.background_color4' 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.top_area_radius' 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#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.text_posts' 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.text_size_headline8' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#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 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.text_publish' 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.text_size_body3' 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#resource_expression#Left $r ( AST#expression#Left 'app.color.default_white_background' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.border_radius5' 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.text_publish_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.text_publish_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isEdit AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.background_color2' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.background_color3' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_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 . isEdit 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 . isEdit AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#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#member_expression#Left AST#expression#Left CommonConstants 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.top_area_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 right AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.comm_padding_margin' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.comm_padding_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 . 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.comm_padding_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.integer.comm_padding_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#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct TopArea {
@State isEdit: boolean = false;
build() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
Row() {
Row() {
Image($r('app.media.ic_public_cancel'))
.width($r('app.integer.cancel_icon_size'))
.height($r('app.integer.cancel_icon_size'))
.onClick(() => {
let context = getContext() as common.UIAbilityContext;
context.terminateSelf();
})
}
.justifyContent(FlexAlign.Center)
.margin({ right: $r('app.integer.cancel_icon_right') })
.width($r('app.integer.top_area_size'))
.height($r('app.integer.top_area_size'))
.backgroundColor($r('app.color.background_color4'))
.borderRadius($r('app.integer.top_area_radius'))
Text($r('app.string.text_posts'))
.fontSize($r('app.integer.text_size_headline8'))
.fontWeight(FontWeight.Bold)
}
Row() {
Text($r('app.string.text_publish'))
.fontSize($r('app.integer.text_size_body3'))
.textAlign(TextAlign.Center)
.fontColor($r('app.color.default_white_background'))
}
.justifyContent(FlexAlign.Center)
.borderRadius($r('app.integer.border_radius5'))
.width($r('app.integer.text_publish_width'))
.height($r('app.integer.text_publish_height'))
.backgroundColor(this.isEdit ? $r('app.color.background_color2') : $r('app.color.background_color3'))
.onClick(() => {
this.isEdit = !this.isEdit;
})
}
.width(CommonConstants.FULL_PERCENT)
.height($r('app.integer.top_area_height'))
.padding({
right: $r('app.integer.comm_padding_margin'),
left: $r('app.integer.comm_padding_margin')
})
.margin({
top: $r('app.integer.comm_padding_margin'),
bottom: $r('app.integer.comm_padding_margin')
})
}
}
|
https://github.com/XiangRui_FuZi/harmony-oscourse/blob/da885f9a777a1eace7a07e1cd81137746687974b/class1/entry/src/main/ets/view/TopArea.ets#L22-L76
|
b20c8feff6b21515417084d278d045407a5cc129
|
gitee
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
UseSendable/entry/src/main/ets/pages/ConcurrentTaskManagement3.ets
|
arkts
|
ConcurrentTaskManagement3
|
[End image_processing]
|
@Component
export struct ConcurrentTaskManagement3 {
@Styles
buttonStyles() {
.width('100%')
.height(40)
}
build() {
NavDestination() {
Column() {
Button($r('app.string.task_set_title'))
.buttonStyles()
.margin({
bottom: 16
})
.onClick(() => {
histogramStatistic(new ArrayBuffer(32));
})
}
.width('100%')
.height('100%')
.justifyContent(FlexAlign.End)
.padding({
right: 24,
bottom: 16,
left: 24
})
}
.title($r('app.string.task_set_title'))
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ConcurrentTaskManagement3 AST#component_body#Left { AST#method_declaration#Left AST#decorator#Left @ Styles AST#decorator#Right buttonStyles AST#parameter_list#Left ( ) AST#parameter_list#Right AST#extend_function_body#Left { AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right } AST#extend_function_body#Right AST#method_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left NavDestination ( ) 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 Button ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.task_set_title' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . buttonStyles ( ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left histogramStatistic 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 ArrayBuffer AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 32 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#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . End AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 24 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 24 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#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 . title ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.task_set_title' 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#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct ConcurrentTaskManagement3 {
@Styles
buttonStyles() {
.width('100%')
.height(40)
}
build() {
NavDestination() {
Column() {
Button($r('app.string.task_set_title'))
.buttonStyles()
.margin({
bottom: 16
})
.onClick(() => {
histogramStatistic(new ArrayBuffer(32));
})
}
.width('100%')
.height('100%')
.justifyContent(FlexAlign.End)
.padding({
right: 24,
bottom: 16,
left: 24
})
}
.title($r('app.string.task_set_title'))
}
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/UseSendable/entry/src/main/ets/pages/ConcurrentTaskManagement3.ets#L66-L97
|
d942afb1fe5e55cd36491e61cdb3ffc43baf6cc2
|
gitee
|
Application-Security-Automation/Arktan.git
|
3ad9cb05235e38b00cd5828476aa59a345afa1c0
|
dataset/completeness/function_call/library_function/string_lib_func_010_F.ets
|
arkts
|
Introduction 库函数-string_slice
|
export function string_lib_func_010_F(taint_src : string) {
let clean = "clean";
let t = clean.slice(0,1);
taint.Sink(t);
}
|
AST#export_declaration#Left export AST#function_declaration#Left function string_lib_func_010_F AST#parameter_list#Left ( AST#parameter#Left taint_src : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left clean = AST#expression#Left "clean" AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left t = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left clean AST#expression#Right . slice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left taint AST#expression#Right . Sink AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left t AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export function string_lib_func_010_F(taint_src : string) {
let clean = "clean";
let t = clean.slice(0,1);
taint.Sink(t);
}
|
https://github.com/Application-Security-Automation/Arktan.git/blob/3ad9cb05235e38b00cd5828476aa59a345afa1c0/dataset/completeness/function_call/library_function/string_lib_func_010_F.ets#L7-L11
|
f7f85f6ef861d22a07cff52fee86762b991e96aa
|
github
|
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/Performance/PerformanceLibrary/feature/DFXStateManagement/Index.ets
|
arkts
|
DFXStateManagementHome
|
Copyright (c) 2023 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
export { DFXStateManagementHome } from './src/main/ets/view/DFXStateManagementHome'
|
AST#export_declaration#Left export { DFXStateManagementHome } from './src/main/ets/view/DFXStateManagementHome' AST#export_declaration#Right
|
export { DFXStateManagementHome } from './src/main/ets/view/DFXStateManagementHome'
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Performance/PerformanceLibrary/feature/DFXStateManagement/Index.ets#L16-L16
|
9df3a63ed66deb957a979c444e0b697b96918e9c
|
gitee
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/events/customEventSample/CustomScrollingEvent.ets
|
arkts
|
aboutToAppear
|
0代表滚动到List顶部,1代表中间值,2代表滚动到List底部。
|
aboutToAppear() {
for (let i = 1; i <= 30; i++) {
let file: string = "file" + i.toString();
this.files.push(file);
}
}
|
AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 1 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 30 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#variable_declaration#Left let AST#variable_declarator#Left file : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left "file" AST#expression#Right + AST#expression#Left i AST#expression#Right AST#binary_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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . files AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left file AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
aboutToAppear() {
for (let i = 1; i <= 30; i++) {
let file: string = "file" + i.toString();
this.files.push(file);
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/events/customEventSample/CustomScrollingEvent.ets#L33-L38
|
ef336daafbc9801a07d552af1d859a736b09d69f
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
harmonyos/src/main/ets/pages/GreetingsPage.ets
|
arkts
|
buildFilterMenu
|
构建筛选菜单
|
@Builder
buildFilterMenu() {
Column() {
// 背景遮罩
Row()
.width('100%')
.layoutWeight(1)
.backgroundColor('rgba(0,0,0,0.3)')
.onClick(() => {
this.showFilterMenu = false;
})
// 菜单内容
Column({ space: 16 }) {
// 样式筛选
Column({ space: 8 }) {
Text('祝福语样式')
.fontSize(16)
.fontWeight(FontWeight.Medium)
.fontColor('#333333')
.alignSelf(ItemAlign.Start)
Flex({ wrap: FlexWrap.Wrap, space: { main: 8, cross: 8 } }) {
this.buildFilterOption('全部', 'all', 'style')
this.buildFilterOption('温馨', GreetingStyle.WARM, 'style')
this.buildFilterOption('正式', GreetingStyle.FORMAL, 'style')
this.buildFilterOption('幽默', GreetingStyle.HUMOROUS, 'style')
this.buildFilterOption('诗意', GreetingStyle.POETIC, 'style')
this.buildFilterOption('简洁', GreetingStyle.SIMPLE, 'style')
}
}
// 场合筛选
Column({ space: 8 }) {
Text('祝福场合')
.fontSize(16)
.fontWeight(FontWeight.Medium)
.fontColor('#333333')
.alignSelf(ItemAlign.Start)
Flex({ wrap: FlexWrap.Wrap, space: { main: 8, cross: 8 } }) {
this.buildFilterOption('全部', 'all', 'occasion')
this.buildFilterOption('生日', GreetingOccasion.BIRTHDAY, 'occasion')
this.buildFilterOption('节日', GreetingOccasion.HOLIDAY, 'occasion')
this.buildFilterOption('纪念日', GreetingOccasion.ANNIVERSARY, 'occasion')
this.buildFilterOption('毕业', GreetingOccasion.GRADUATION, 'occasion')
this.buildFilterOption('其他', GreetingOccasion.OTHER, 'occasion')
}
}
// 确定按钮
Button('确定')
.width('100%')
.height(44)
.backgroundColor('#007AFF')
.fontColor('#ffffff')
.fontSize(16)
.onClick(() => {
this.showFilterMenu = false;
})
}
.width('100%')
.padding(16)
.backgroundColor('#ffffff')
.borderRadius({ topLeft: 16, topRight: 16 })
}
.width('100%')
.height('100%')
.position({ x: 0, y: 0 })
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildFilterMenu 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#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 'rgba(0,0,0,0.3)' 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 . showFilterMenu 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#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 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 Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 8 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '祝福语样式' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#333333' AST#expression#Right ) AST#modifier_chain_expression#Left . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Flex ( AST#component_parameters#Left { AST#component_parameter#Left wrap : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexWrap AST#expression#Right . Wrap AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left space : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left main AST#property_name#Right : AST#expression#Left 8 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left cross AST#property_name#Right : AST#expression#Left 8 AST#expression#Right AST#property_assignment#Right } AST#object_literal#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 . buildFilterOption AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '全部' AST#expression#Right , AST#expression#Left 'all' AST#expression#Right , AST#expression#Left 'style' 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 . buildFilterOption AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '温馨' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left GreetingStyle AST#expression#Right . WARM AST#member_expression#Right AST#expression#Right , AST#expression#Left 'style' 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 . buildFilterOption AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '正式' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left GreetingStyle AST#expression#Right . FORMAL AST#member_expression#Right AST#expression#Right , AST#expression#Left 'style' 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 . buildFilterOption AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '幽默' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left GreetingStyle AST#expression#Right . HUMOROUS AST#member_expression#Right AST#expression#Right , AST#expression#Left 'style' 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 . buildFilterOption AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '诗意' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left GreetingStyle AST#expression#Right . POETIC AST#member_expression#Right AST#expression#Right , AST#expression#Left 'style' 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 . buildFilterOption AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '简洁' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left GreetingStyle AST#expression#Right . SIMPLE AST#member_expression#Right AST#expression#Right , AST#expression#Left 'style' 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#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 场合筛选 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 8 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '祝福场合' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#333333' AST#expression#Right ) AST#modifier_chain_expression#Left . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Flex ( AST#component_parameters#Left { AST#component_parameter#Left wrap : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexWrap AST#expression#Right . Wrap AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left space : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left main AST#property_name#Right : AST#expression#Left 8 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left cross AST#property_name#Right : AST#expression#Left 8 AST#expression#Right AST#property_assignment#Right } AST#object_literal#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 . buildFilterOption AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '全部' AST#expression#Right , AST#expression#Left 'all' AST#expression#Right , AST#expression#Left 'occasion' 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 . buildFilterOption AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '生日' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left GreetingOccasion AST#expression#Right . BIRTHDAY AST#member_expression#Right AST#expression#Right , AST#expression#Left 'occasion' 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 . buildFilterOption AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '节日' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left GreetingOccasion AST#expression#Right . HOLIDAY AST#member_expression#Right AST#expression#Right , AST#expression#Left 'occasion' 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 . buildFilterOption AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '纪念日' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left GreetingOccasion AST#expression#Right . ANNIVERSARY AST#member_expression#Right AST#expression#Right , AST#expression#Left 'occasion' 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 . buildFilterOption AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '毕业' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left GreetingOccasion AST#expression#Right . GRADUATION AST#member_expression#Right AST#expression#Right , AST#expression#Left 'occasion' 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 . buildFilterOption AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '其他' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left GreetingOccasion AST#expression#Right . OTHER AST#member_expression#Right AST#expression#Right , AST#expression#Left 'occasion' 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#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 Button ( AST#expression#Left '确定' AST#expression#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 44 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#007AFF' AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#ffffff' AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 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 . showFilterMenu 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 . padding ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#ffffff' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left topLeft AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left topRight AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 . position ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
buildFilterMenu() {
Column() {
Row()
.width('100%')
.layoutWeight(1)
.backgroundColor('rgba(0,0,0,0.3)')
.onClick(() => {
this.showFilterMenu = false;
})
Column({ space: 16 }) {
Column({ space: 8 }) {
Text('祝福语样式')
.fontSize(16)
.fontWeight(FontWeight.Medium)
.fontColor('#333333')
.alignSelf(ItemAlign.Start)
Flex({ wrap: FlexWrap.Wrap, space: { main: 8, cross: 8 } }) {
this.buildFilterOption('全部', 'all', 'style')
this.buildFilterOption('温馨', GreetingStyle.WARM, 'style')
this.buildFilterOption('正式', GreetingStyle.FORMAL, 'style')
this.buildFilterOption('幽默', GreetingStyle.HUMOROUS, 'style')
this.buildFilterOption('诗意', GreetingStyle.POETIC, 'style')
this.buildFilterOption('简洁', GreetingStyle.SIMPLE, 'style')
}
}
Column({ space: 8 }) {
Text('祝福场合')
.fontSize(16)
.fontWeight(FontWeight.Medium)
.fontColor('#333333')
.alignSelf(ItemAlign.Start)
Flex({ wrap: FlexWrap.Wrap, space: { main: 8, cross: 8 } }) {
this.buildFilterOption('全部', 'all', 'occasion')
this.buildFilterOption('生日', GreetingOccasion.BIRTHDAY, 'occasion')
this.buildFilterOption('节日', GreetingOccasion.HOLIDAY, 'occasion')
this.buildFilterOption('纪念日', GreetingOccasion.ANNIVERSARY, 'occasion')
this.buildFilterOption('毕业', GreetingOccasion.GRADUATION, 'occasion')
this.buildFilterOption('其他', GreetingOccasion.OTHER, 'occasion')
}
}
Button('确定')
.width('100%')
.height(44)
.backgroundColor('#007AFF')
.fontColor('#ffffff')
.fontSize(16)
.onClick(() => {
this.showFilterMenu = false;
})
}
.width('100%')
.padding(16)
.backgroundColor('#ffffff')
.borderRadius({ topLeft: 16, topRight: 16 })
}
.width('100%')
.height('100%')
.position({ x: 0, y: 0 })
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/pages/GreetingsPage.ets#L486-L555
|
7fd0f2dc3a8360217c227a991157b3f4ba1c015b
|
github
|
Piagari/arkts_example.git
|
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
|
hmos_app-main/hmos_app-main/DriverLicenseExam-master/products/entry/src/main/ets/pages/mine/QuickLoginPage.ets
|
arkts
|
handleLoginWithHuaweiIDButton
|
Method that processes a tap on the one-tap sign-in button.
|
handleLoginWithHuaweiIDButton(error: BusinessError | undefined, response: loginComponentManager.HuaweiIDCredential) {
this.enableStatus = false;
if (error) {
hilog.error(this.domainId, this.logTag,
`Failed to login with LoginWithHuaweiIDButton. errCode is ${error.code}, errMessage is ${error.message}`);
if (error.code === ErrorCode.ERROR_CODE_AGREEMENT_STATUS_NOT_ACCEPTED) {
// If the agreements are not accepted, a pop-up message is displayed.
this.showPopUp = true;
} else {
showToast(error);
}
this.enableStatus = true;
return;
}
try {
if (this.isSelected) {
if (response) {
hilog.info(this.domainId, this.logTag, 'Succeeded in clicking LoginWithHuaweiIDButton.');
const authCode = response.authorizationCode;
const openID = response.openID;
const unionID = response.unionID;
const idToken = response.idToken;
AccountUtil.getAccountInfo().openID = openID;
AccountUtil.getAccountInfo().unionID = unionID;
AccountUtil.getAccountInfo().idToken = idToken;
AccountUtil.getAccountInfo().authorizationCode = authCode;
AccountUtil.getUserInfo().nickname = $r('app.string.huawei_user')
// todo 待实现
this.vm.navStack.pop();
}
} else {
// If the agreements are not accepted, a pop-up message is displayed.
this.showPopUp = true;
}
} catch (error) {
hilog.error(this.domainId, this.logTag,
`Failed to login with LoginWithHuaweiIDButton. errCode is ${error.code}, errMessage is ${error.message}`);
showToast(error as BusinessError);
} finally {
this.enableStatus = true;
}
}
|
AST#method_declaration#Left handleLoginWithHuaweiIDButton AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left BusinessError AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left response : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left loginComponentManager . HuaweiIDCredential AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . enableStatus AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left error AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 this AST#expression#Right . domainId AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . logTag AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to login with LoginWithHuaweiIDButton. errCode is 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 , errMessage is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . code AST#member_expression#Right AST#expression#Right === AST#expression#Left ErrorCode AST#expression#Right AST#binary_expression#Right AST#expression#Right . ERROR_CODE_AGREEMENT_STATUS_NOT_ACCEPTED AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { // If the agreements are not accepted, a pop-up message is displayed. 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 . showPopUp AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left showToast AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . enableStatus AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#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 . isSelected AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left response 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . domainId AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . logTag AST#member_expression#Right AST#expression#Right , AST#expression#Left 'Succeeded in clicking LoginWithHuaweiIDButton.' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left authCode = AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . authorizationCode 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 openID = AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . openID 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 unionID = AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . unionID 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 idToken = AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . idToken AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AccountUtil AST#expression#Right . getAccountInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . openID AST#member_expression#Right = AST#expression#Left openID 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AccountUtil AST#expression#Right . getAccountInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . unionID AST#member_expression#Right = AST#expression#Left unionID 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AccountUtil AST#expression#Right . getAccountInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . idToken AST#member_expression#Right = AST#expression#Left idToken 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AccountUtil AST#expression#Right . getAccountInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . authorizationCode AST#member_expression#Right = AST#expression#Left authCode 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AccountUtil 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#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.huawei_user' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // todo 待实现 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . navStack AST#member_expression#Right AST#expression#Right . pop AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { // If the agreements are not accepted, a pop-up message is displayed. 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 . showPopUp 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#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 this AST#expression#Right . domainId AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . logTag AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to login with LoginWithHuaweiIDButton. errCode is 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 , errMessage is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left showToast AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#finally_clause#Left finally AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . enableStatus 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#finally_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
handleLoginWithHuaweiIDButton(error: BusinessError | undefined, response: loginComponentManager.HuaweiIDCredential) {
this.enableStatus = false;
if (error) {
hilog.error(this.domainId, this.logTag,
`Failed to login with LoginWithHuaweiIDButton. errCode is ${error.code}, errMessage is ${error.message}`);
if (error.code === ErrorCode.ERROR_CODE_AGREEMENT_STATUS_NOT_ACCEPTED) {
this.showPopUp = true;
} else {
showToast(error);
}
this.enableStatus = true;
return;
}
try {
if (this.isSelected) {
if (response) {
hilog.info(this.domainId, this.logTag, 'Succeeded in clicking LoginWithHuaweiIDButton.');
const authCode = response.authorizationCode;
const openID = response.openID;
const unionID = response.unionID;
const idToken = response.idToken;
AccountUtil.getAccountInfo().openID = openID;
AccountUtil.getAccountInfo().unionID = unionID;
AccountUtil.getAccountInfo().idToken = idToken;
AccountUtil.getAccountInfo().authorizationCode = authCode;
AccountUtil.getUserInfo().nickname = $r('app.string.huawei_user')
this.vm.navStack.pop();
}
} else {
this.showPopUp = true;
}
} catch (error) {
hilog.error(this.domainId, this.logTag,
`Failed to login with LoginWithHuaweiIDButton. errCode is ${error.code}, errMessage is ${error.message}`);
showToast(error as BusinessError);
} finally {
this.enableStatus = true;
}
}
|
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/DriverLicenseExam-master/products/entry/src/main/ets/pages/mine/QuickLoginPage.ets#L95-L136
|
e2443e768e236c9c615253e7579ec83843fd81a9
|
github
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_UIAbilityComponentsBasicUsage.ets
|
arkts
|
页面展示
|
build() {
Column() {
Row() {
Text($r('app.string.UIAbilityComponentsBasicUsage'))
.fontSize(24)
.fontWeight(700)
.textAlign(TextAlign.Start)
.margin({ top: 12, bottom: 11, right: 24, left: 24 })
}
.width('100%')
.height(56)
.justifyContent(FlexAlign.Start)
Image($r('app.media.pic_empty'))
.width(120)
.height(120)
.margin({ top: 224 })
Text($r('app.string.NoContentAvailable'))
.fontSize(14)
.margin({ top: 8, bottom: 317, right: 152, left: 152 })
.fontColor($r('app.color.text_color'))
.opacity(0.4)
.fontWeight(400)
}
.width('100%')
.height('100%')
.backgroundColor($r('app.color.backGrounding'))
}
|
AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.UIAbilityComponentsBasicUsage' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left 700 AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 11 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 24 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 24 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 56 AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.pic_empty' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 120 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 120 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 224 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.NoContentAvailable' AST#expression#Right ) AST#resource_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 . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 8 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 317 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 152 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 152 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left 0.4 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left 400 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.backGrounding' 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
|
build() {
Column() {
Row() {
Text($r('app.string.UIAbilityComponentsBasicUsage'))
.fontSize(24)
.fontWeight(700)
.textAlign(TextAlign.Start)
.margin({ top: 12, bottom: 11, right: 24, left: 24 })
}
.width('100%')
.height(56)
.justifyContent(FlexAlign.Start)
Image($r('app.media.pic_empty'))
.width(120)
.height(120)
.margin({ top: 224 })
Text($r('app.string.NoContentAvailable'))
.fontSize(14)
.margin({ top: 8, bottom: 317, right: 152, left: 152 })
.fontColor($r('app.color.text_color'))
.opacity(0.4)
.fontWeight(400)
}
.width('100%')
.height('100%')
.backgroundColor($r('app.color.backGrounding'))
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ApplicationModels/StageModelAbilityDevelop/entry/src/main/ets/pages/Page_UIAbilityComponentsBasicUsage.ets#L60-L88
|
a54362b1c8a97a7b58de8ad46da4f17f5e406531
|
gitee
|
|
Piagari/arkts_example.git
|
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
|
hmos_app-main/hmos_app-main/legado-Harmony-master/entry/src/main/ets/pages/view/myCenter/MyCenter.ets
|
arkts
|
night_onclick
|
切换夜间模式
|
night_onclick(){
}
|
AST#method_declaration#Left night_onclick AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { } AST#builder_function_body#Right AST#method_declaration#Right
|
night_onclick(){
}
|
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/MyCenter.ets#L161-L163
|
7bf6843e07bfbda76f774e4101dcfb696c2eef86
|
github
|
openharmony-tpc/ohos_mpchart
|
4fb43a7137320ef2fee2634598f53d93975dfb4a
|
library/src/main/ets/components/formatter/DefaultValueFormatter.ets
|
arkts
|
Constructor that specifies to how many digits the value should be
formatted.
@param digits
|
constructor(digits: number) {
this.setup(digits);
}
|
AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left digits : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . setup AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left digits 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(digits: number) {
this.setup(digits);
}
|
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/formatter/DefaultValueFormatter.ets#L40-L42
|
3ace9cf48dcd9760361189f9483204d144b2d86a
|
gitee
|
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/common/types/GreetingTypes.ets
|
arkts
|
祝福语统计接口
|
export interface GreetingStats {
totalGenerated: number;
totalFavorited: number;
averageRating: number;
mostUsedStyle: GreetingStyle;
styleDistribution: Record<GreetingStyle, number>;
occasionDistribution: Record<GreetingOccasion, number>;
monthlyTrend: MonthlyGreetingStats[];
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface GreetingStats AST#object_type#Left { AST#type_member#Left totalGenerated : 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 totalFavorited : 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 averageRating : 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 mostUsedStyle : AST#type_annotation#Left AST#primary_type#Left GreetingStyle AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left styleDistribution : 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 GreetingStyle 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#type_member#Right ; AST#type_member#Left occasionDistribution : 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 GreetingOccasion 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#type_member#Right ; AST#type_member#Left monthlyTrend : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left MonthlyGreetingStats [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
|
export interface GreetingStats {
totalGenerated: number;
totalFavorited: number;
averageRating: number;
mostUsedStyle: GreetingStyle;
styleDistribution: Record<GreetingStyle, number>;
occasionDistribution: Record<GreetingOccasion, number>;
monthlyTrend: MonthlyGreetingStats[];
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/GreetingTypes.ets#L617-L625
|
4d2e7dfa568fac3084222925c1de28941587fc91
|
github
|
|
BohanSu/LumosAgent-HarmonyOS.git
|
9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76
|
entry/src/main/ets/common/RdbHelper.ets
|
arkts
|
insertMemo
|
==================== MEMO OPERATIONS ====================
Insert a new memo
@param memo - Memo object to insert
@returns Row ID of inserted memo
|
async insertMemo(memo: Memo): Promise<number> {
if (!this.rdbStore) {
throw new Error('Database not initialized');
}
try {
const valueBucket: relationalStore.ValuesBucket = {
'content': memo.content,
'created_at': memo.createdAt
};
const rowId = await this.rdbStore.insert(Constants.TABLE_MEMOS, valueBucket);
console.info(`[RdbHelper] Memo inserted with ID: ${rowId}`);
return rowId;
} catch (error) {
const err = error as BusinessError;
console.error(`[RdbHelper] Failed to insert memo. Code: ${err.code}, message: ${err.message}`);
throw new Error(`Failed to insert memo: ${err.message}`);
}
}
|
AST#method_declaration#Left async insertMemo AST#parameter_list#Left ( AST#parameter#Left memo : AST#type_annotation#Left AST#primary_type#Left Memo AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . rdbStore AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#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 'Database not initialized' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#throw_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left valueBucket : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left relationalStore . ValuesBucket 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 'content' AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left memo AST#expression#Right . content AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'created_at' AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left memo AST#expression#Right . createdAt AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left rowId = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . rdbStore AST#member_expression#Right AST#expression#Right . insert AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . TABLE_MEMOS AST#member_expression#Right AST#expression#Right , AST#expression#Left valueBucket AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [RdbHelper] Memo inserted with ID: AST#template_substitution#Left $ { AST#expression#Left rowId 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 rowId 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 err = AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [RdbHelper] Failed to insert memo. 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#throw_statement#Left throw AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` Failed to insert memo: 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#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 insertMemo(memo: Memo): Promise<number> {
if (!this.rdbStore) {
throw new Error('Database not initialized');
}
try {
const valueBucket: relationalStore.ValuesBucket = {
'content': memo.content,
'created_at': memo.createdAt
};
const rowId = await this.rdbStore.insert(Constants.TABLE_MEMOS, valueBucket);
console.info(`[RdbHelper] Memo inserted with ID: ${rowId}`);
return rowId;
} catch (error) {
const err = error as BusinessError;
console.error(`[RdbHelper] Failed to insert memo. Code: ${err.code}, message: ${err.message}`);
throw new Error(`Failed to insert memo: ${err.message}`);
}
}
|
https://github.com/BohanSu/LumosAgent-HarmonyOS.git/blob/9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76/entry/src/main/ets/common/RdbHelper.ets#L325-L343
|
c2666cdfa559a903fffd844b001fdeb4c9cafd26
|
github
|
Joker-x-dev/CoolMallArkTS.git
|
9f3fabf89fb277692cb82daf734c220c7282919c
|
core/data/src/main/ets/repository/AuthRepository.ets
|
arkts
|
loginByQqApp
|
QQ APP 授权登录
@param {QQLoginRequest} params - QQ 授权参数
@returns {Promise<NetworkResponse<Auth>>} 认证结果
|
async loginByQqApp(params: QQLoginRequest): Promise<NetworkResponse<Auth>> {
return this.networkDataSource.loginByQqApp(params);
}
|
AST#method_declaration#Left async loginByQqApp AST#parameter_list#Left ( AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left QQLoginRequest AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left NetworkResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Auth AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . networkDataSource AST#member_expression#Right AST#expression#Right . loginByQqApp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left params AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async loginByQqApp(params: QQLoginRequest): Promise<NetworkResponse<Auth>> {
return this.networkDataSource.loginByQqApp(params);
}
|
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/data/src/main/ets/repository/AuthRepository.ets#L36-L38
|
466f33c06a59385ea42254c6b461840d81373584
|
github
|
open9527/OpenHarmony
|
fdea69ed722d426bf04e817ec05bff4002e81a4e
|
libs/core/src/main/ets/utils/PreferencesUtils.ets
|
arkts
|
has
|
检查缓存的Preferences实例中是否包含名为给定Key的存储键值对
@param key
@param preferenceName
@returns
|
static async has(key: string, preferenceName: string = defaultPreferenceName) {
let preferences = await PreferencesUtils.getPreferences(preferenceName) //获取实例
return await preferences.has(key)
}
|
AST#method_declaration#Left static async has AST#parameter_list#Left ( AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#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#variable_declaration#Left let AST#variable_declarator#Left preferences = 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 PreferencesUtils 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 preferenceName AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right //获取实例 AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left preferences AST#expression#Right AST#await_expression#Right AST#expression#Right . has AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static async has(key: string, preferenceName: string = defaultPreferenceName) {
let preferences = await PreferencesUtils.getPreferences(preferenceName)
return await preferences.has(key)
}
|
https://github.com/open9527/OpenHarmony/blob/fdea69ed722d426bf04e817ec05bff4002e81a4e/libs/core/src/main/ets/utils/PreferencesUtils.ets#L129-L132
|
ef2f956cb78cf72e9496211208cc87e5d67bfa98
|
gitee
|
openharmony/xts_acts
|
5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686
|
arkui/ace_ets_module_ui/ace_ets_module_picker/ace_ets_module_picker_api12/entry/src/main/ets/MainAbility/pages/Slider/XcomponentSlider/XcomponentSlider26.ets
|
arkts
|
buildSlider26
|
Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
@Builder function buildSlider26(config: SliderConfiguration) {
Row() {
Column({space: 30}) {
Button('增加').onClick(() => {
config.value = config.value + config.step
config.triggerChange(config.value, SliderChangeMode.Click)
})
.width(100)
.height(25)
.fontSize(10)
.enabled(config.value<config.max)
Button('减少').onClick(() => {
config.value=config.value-config.step
config.triggerChange(config.value, SliderChangeMode.Click)
})
.width(100)
.height(25)
.fontSize(10)
.enabled(config.value>config.min)
Slider({
value: config.value,
min: config.min,
max: config.max,
step:config.step,
})
.width(config.max)
.visibility((config.contentModifier as MySliderStyle26).showSlider?Visibility.Visible:Visibility.Hidden)
.showSteps(true)
.onChange((value: number, mode: SliderChangeMode) => {
config.triggerChange(undefined, undefined)
})
Text('当前状态:'+ ((config.contentModifier as MySliderStyle26).sliderChangeMode==0?'Begin'
:((config.contentModifier as MySliderStyle26).sliderChangeMode==1?'Moving'
:((config.contentModifier as MySliderStyle26).sliderChangeMode==2?'End'
:((config.contentModifier as MySliderStyle26).sliderChangeMode==3?'Click':'无')))))
.fontSize(10)
Text('进度值:'+ config.value)
.fontSize(10)
Text('最小值:'+ config.min)
.fontSize(10)
Text('最大值:'+ config.max)
.fontSize(10)
Text('步长:'+ config.step)
.fontSize(10)
}
.width('80%')
}
.width('100%')
}
|
AST#decorated_function_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right function buildSlider26 AST#parameter_list#Left ( AST#parameter#Left config : AST#type_annotation#Left AST#primary_type#Left SliderConfiguration AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 30 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left '增加' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . value AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . value AST#member_expression#Right AST#expression#Right + AST#expression#Left config AST#expression#Right AST#binary_expression#Right AST#expression#Right . step 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 config AST#expression#Right . triggerChange AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . value AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left SliderChangeMode AST#expression#Right . Click AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 100 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 10 AST#expression#Right ) AST#modifier_chain_expression#Left . enabled ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . value AST#member_expression#Right AST#expression#Right < AST#expression#Left config AST#expression#Right AST#binary_expression#Right AST#expression#Right . max AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left '减少' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . value AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . value AST#member_expression#Right AST#expression#Right - AST#expression#Left config AST#expression#Right AST#binary_expression#Right AST#expression#Right . step 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 config AST#expression#Right . triggerChange AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . value AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left SliderChangeMode AST#expression#Right . Click AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 100 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 10 AST#expression#Right ) AST#modifier_chain_expression#Left . enabled ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . value AST#member_expression#Right AST#expression#Right > AST#expression#Left config AST#expression#Right AST#binary_expression#Right AST#expression#Right . min AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Slider ( AST#component_parameters#Left { AST#component_parameter#Left value : AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . value 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 config AST#expression#Right . min 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 config AST#expression#Right . max AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left step : AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . step 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#member_expression#Left AST#expression#Left config AST#expression#Right . max AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . visibility ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . contentModifier AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left MySliderStyle26 AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . showSlider AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left Visibility AST#expression#Right . Visible AST#member_expression#Right AST#expression#Right : AST#expression#Left Visibility AST#expression#Right AST#conditional_expression#Right AST#expression#Right . Hidden AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . showSteps ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onChange ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left mode : AST#type_annotation#Left AST#primary_type#Left SliderChangeMode 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 config AST#expression#Right . triggerChange AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left undefined AST#expression#Right , AST#expression#Left undefined AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#binary_expression#Left AST#expression#Left '当前状态:' AST#expression#Right + AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . contentModifier AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left MySliderStyle26 AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . sliderChangeMode AST#member_expression#Right AST#expression#Right == AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 'Begin' AST#expression#Right : AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . contentModifier AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left MySliderStyle26 AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . sliderChangeMode AST#member_expression#Right AST#expression#Right == AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 'Moving' AST#expression#Right : AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . contentModifier AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left MySliderStyle26 AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . sliderChangeMode AST#member_expression#Right AST#expression#Right == AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 'End' AST#expression#Right : AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . contentModifier AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left MySliderStyle26 AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . sliderChangeMode AST#member_expression#Right AST#expression#Right == AST#expression#Left 3 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 'Click' AST#expression#Right : AST#expression#Left '无' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 10 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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '进度值:' AST#expression#Right + AST#expression#Left config AST#expression#Right AST#binary_expression#Right AST#expression#Right . value AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 10 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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '最小值:' AST#expression#Right + AST#expression#Left config AST#expression#Right AST#binary_expression#Right AST#expression#Right . min AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 10 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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '最大值:' AST#expression#Right + AST#expression#Left config AST#expression#Right AST#binary_expression#Right AST#expression#Right . max AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 10 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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '步长:' AST#expression#Right + AST#expression#Left config AST#expression#Right AST#binary_expression#Right AST#expression#Right . step AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 10 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 '80%' 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#builder_function_body#Right AST#decorated_function_declaration#Right
|
@Builder function buildSlider26(config: SliderConfiguration) {
Row() {
Column({space: 30}) {
Button('增加').onClick(() => {
config.value = config.value + config.step
config.triggerChange(config.value, SliderChangeMode.Click)
})
.width(100)
.height(25)
.fontSize(10)
.enabled(config.value<config.max)
Button('减少').onClick(() => {
config.value=config.value-config.step
config.triggerChange(config.value, SliderChangeMode.Click)
})
.width(100)
.height(25)
.fontSize(10)
.enabled(config.value>config.min)
Slider({
value: config.value,
min: config.min,
max: config.max,
step:config.step,
})
.width(config.max)
.visibility((config.contentModifier as MySliderStyle26).showSlider?Visibility.Visible:Visibility.Hidden)
.showSteps(true)
.onChange((value: number, mode: SliderChangeMode) => {
config.triggerChange(undefined, undefined)
})
Text('当前状态:'+ ((config.contentModifier as MySliderStyle26).sliderChangeMode==0?'Begin'
:((config.contentModifier as MySliderStyle26).sliderChangeMode==1?'Moving'
:((config.contentModifier as MySliderStyle26).sliderChangeMode==2?'End'
:((config.contentModifier as MySliderStyle26).sliderChangeMode==3?'Click':'无')))))
.fontSize(10)
Text('进度值:'+ config.value)
.fontSize(10)
Text('最小值:'+ config.min)
.fontSize(10)
Text('最大值:'+ config.max)
.fontSize(10)
Text('步长:'+ config.step)
.fontSize(10)
}
.width('80%')
}
.width('100%')
}
|
https://github.com/openharmony/xts_acts/blob/5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686/arkui/ace_ets_module_ui/ace_ets_module_picker/ace_ets_module_picker_api12/entry/src/main/ets/MainAbility/pages/Slider/XcomponentSlider/XcomponentSlider26.ets#L16-L67
|
42bc0526840e13424bd60d540450cc5cc973c3c3
|
gitee
|
chongzi/Lucky-ArkTs.git
|
84fc104d4a68def780a483e2543ebf9f53e793fd
|
entry/src/main/ets/mock/InterviewArticleMockData.ets
|
arkts
|
getAllArticles
|
获取所有文章
|
static getAllArticles(): InterviewArticleModel[] {
return InterviewArticleMockData.articles;
}
|
AST#method_declaration#Left static getAllArticles AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left InterviewArticleModel [ ] 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#member_expression#Left AST#expression#Left InterviewArticleMockData AST#expression#Right . articles AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static getAllArticles(): InterviewArticleModel[] {
return InterviewArticleMockData.articles;
}
|
https://github.com/chongzi/Lucky-ArkTs.git/blob/84fc104d4a68def780a483e2543ebf9f53e793fd/entry/src/main/ets/mock/InterviewArticleMockData.ets#L957-L959
|
a854575ce0659f7acaf7f244da059da43bff108b
|
github
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
harmonyos/src/main/ets/services/storage/PreferencesService.ets
|
arkts
|
getArray
|
获取数组值(从JSON字符串解析)
@param key 键
@param defaultValue 默认值
@returns 数组值
|
async getArray<T>(key: string, defaultValue: T[] = []): Promise<T[]> {
try {
const jsonString = await this.getString(key, '');
if (!jsonString) {
return defaultValue;
}
return JSON.parse(jsonString) as T[];
} catch (error) {
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to get array: ${error}`);
return defaultValue;
}
}
|
AST#method_declaration#Left async getArray AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left defaultValue : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left T [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left T [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left jsonString = 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 . getString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right , AST#expression#Left '' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left jsonString AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left defaultValue 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#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left jsonString AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left T [ ] AST#array_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#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 get array: AST#template_substitution#Left $ { AST#expression#Left error AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left defaultValue AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async getArray<T>(key: string, defaultValue: T[] = []): Promise<T[]> {
try {
const jsonString = await this.getString(key, '');
if (!jsonString) {
return defaultValue;
}
return JSON.parse(jsonString) as T[];
} catch (error) {
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to get array: ${error}`);
return defaultValue;
}
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/services/storage/PreferencesService.ets#L183-L194
|
8fadfd38b74c6c5bfbb70f16b1ef421cea1484bf
|
github
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
ef_core/src/main/ets/core/util/RandomUtil.ets
|
arkts
|
randomBoolean
|
获得随机Boolean值
@return true or false
|
static randomBoolean(): boolean {
return Math.random() < 0.5;
}
|
AST#method_declaration#Left static randomBoolean AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . random AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right < AST#expression#Left 0.5 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static randomBoolean(): boolean {
return Math.random() < 0.5;
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_core/src/main/ets/core/util/RandomUtil.ets#L32-L34
|
c994c68cf08aa7f357e97be3084a34eba08d21a5
|
gitee
|
ThePivotPoint/ArkTS-LSP-Server-Plugin.git
|
6231773905435f000d00d94b26504433082ba40b
|
packages/declarations/ets/api/@ohos.arkui.advanced.Popup.d.ets
|
arkts
|
Defines the popup options.
@syscap SystemCapability.ArkUI.ArkUI.Full
@crossplatform
@since 11
Defines the popup options.
@syscap SystemCapability.ArkUI.ArkUI.Full
@crossplatform
@atomicservice
@since 12
|
export interface PopupOptions {
/**
* The icon of Popup.
*
* @type { ?PopupIconOptions }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/
/**
* The icon of Popup.
*
* @type { ?PopupIconOptions }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
icon?: PopupIconOptions;
/**
* The title of Popup.
*
* @type { ?PopupTextOptions }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/
/**
* The title of Popup.
*
* @type { ?PopupTextOptions }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
title?: PopupTextOptions;
/**
* The message of Popup.
*
* @type { PopupTextOptions }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/
/**
* The message of Popup.
*
* @type { PopupTextOptions }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
message: PopupTextOptions;
/**
* The show close of Popup.
*
* @type { ?(boolean | Resource) }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/
/**
* The show close of Popup.
*
* @type { ?(boolean | Resource) }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
showClose?: boolean | Resource;
/**
* The close button callback of Popup.
*
* @type { ?() => void }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/
/**
* The close button callback of Popup.
*
* @type { ?() => void }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
onClose?: () => void;
/**
* The buttons of Popup.
*
* @type { ?[PopupButtonOptions?, PopupButtonOptions?] }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/
/**
* The buttons of Popup.
*
* @type { ?[PopupButtonOptions?, PopupButtonOptions?] }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
buttons?: [
PopupButtonOptions?,
PopupButtonOptions?
];
/**
* Indicates the attribute of the current popup direction.
*
* @type { ?Direction }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
direction?: Direction;
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface PopupOptions AST#object_type#Left { /**
* The icon of Popup.
*
* @type { ?PopupIconOptions }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/ /**
* The icon of Popup.
*
* @type { ?PopupIconOptions }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/ AST#type_member#Left icon ? : AST#type_annotation#Left AST#primary_type#Left PopupIconOptions AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /**
* The title of Popup.
*
* @type { ?PopupTextOptions }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/ /**
* The title of Popup.
*
* @type { ?PopupTextOptions }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/ AST#type_member#Left title ? : AST#type_annotation#Left AST#primary_type#Left PopupTextOptions AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /**
* The message of Popup.
*
* @type { PopupTextOptions }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/ /**
* The message of Popup.
*
* @type { PopupTextOptions }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/ AST#type_member#Left message : AST#type_annotation#Left AST#primary_type#Left PopupTextOptions AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /**
* The show close of Popup.
*
* @type { ?(boolean | Resource) }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/ /**
* The show close of Popup.
*
* @type { ?(boolean | Resource) }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/ AST#type_member#Left showClose ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left boolean AST#primary_type#Right | AST#primary_type#Left Resource AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#type_member#Right ; /**
* The close button callback of Popup.
*
* @type { ?() => void }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/ /**
* The close button callback of Popup.
*
* @type { ?() => void }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/ AST#type_member#Left onClose ? : 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#type_member#Right ; /**
* The buttons of Popup.
*
* @type { ?[PopupButtonOptions?, PopupButtonOptions?] }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/ /**
* The buttons of Popup.
*
* @type { ?[PopupButtonOptions?, PopupButtonOptions?] }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/ AST#type_member#Left buttons ? : AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ AST#type_annotation#Left AST#primary_type#Left PopupButtonOptions AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ? AST#ERROR#Right , AST#type_annotation#Left AST#primary_type#Left PopupButtonOptions AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ? AST#ERROR#Right ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /**
* Indicates the attribute of the current popup direction.
*
* @type { ?Direction }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/ AST#type_member#Left direction ? : AST#type_annotation#Left AST#primary_type#Left Direction 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 PopupOptions {
icon?: PopupIconOptions;
title?: PopupTextOptions;
message: PopupTextOptions;
showClose?: boolean | Resource;
onClose?: () => void;
buttons?: [
PopupButtonOptions?,
PopupButtonOptions?
];
direction?: Direction;
}
|
https://github.com/ThePivotPoint/ArkTS-LSP-Server-Plugin.git/blob/6231773905435f000d00d94b26504433082ba40b/packages/declarations/ets/api/@ohos.arkui.advanced.Popup.d.ets#L285-L407
|
17100a810da72211d4416fcfa956a55271329f35
|
github
|
|
BohanSu/LumosAgent-HarmonyOS.git
|
9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76
|
entry/src/main/ets/services/ConfigService.ets
|
arkts
|
hasUserConfig
|
检查是否有用户配置(区分于默认配置)
|
async hasUserConfig(): Promise<boolean> {
if (!this.dataPreferences) {
return false;
}
try {
return await this.dataPreferences.get(ConfigService.KEY_HAS_CONFIG, false) as boolean;
} catch (error) {
return false;
}
}
|
AST#method_declaration#Left async hasUserConfig AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#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 . dataPreferences AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left 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#try_statement#Left try 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 AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . dataPreferences AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left ConfigService AST#expression#Right . KEY_HAS_CONFIG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async hasUserConfig(): Promise<boolean> {
if (!this.dataPreferences) {
return false;
}
try {
return await this.dataPreferences.get(ConfigService.KEY_HAS_CONFIG, false) as boolean;
} catch (error) {
return false;
}
}
|
https://github.com/BohanSu/LumosAgent-HarmonyOS.git/blob/9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76/entry/src/main/ets/services/ConfigService.ets#L258-L268
|
b92449b1f2eb868be1a233cc4182d36de9139234
|
github
|
wangjinyuan/JS-TS-ArkTS-database.git
|
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
|
npm/alprazolamdiv/11.5.1/package/src/structures/PermissionOverwrites.ets
|
arkts
|
约束18:构造函数中不能声明字段,需在类中声明
|
constructor(guildChannel: any, data?: PermissionOverwriteData) { // 约束1:需替换any为具体类型
// 约束2:使用属性赋值替代Object.defineProperty
this.channel = guildChannel;
if (data) {
this.setup(data);
}
}
|
AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left guildChannel : AST#type_annotation#Left AST#primary_type#Left any AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left data ? : AST#type_annotation#Left AST#primary_type#Left PermissionOverwriteData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { // 约束1:需替换any为具体类型 // 约束2:使用属性赋值替代Object.defineProperty 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 . channel AST#member_expression#Right = AST#expression#Left guildChannel 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 data 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 . setup AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right
|
constructor(guildChannel: any, data?: PermissionOverwriteData) {
this.channel = guildChannel;
if (data) {
this.setup(data);
}
}
|
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/structures/PermissionOverwrites.ets#L26-L33
|
466b585ddfc9a4d5d6b42680aceaeab3be152ae3
|
github
|
|
liuchao0739/arkTS_universal_starter.git
|
0ca845f5ae0e78db439dc09f712d100c0dd46ed3
|
entry/src/main/ets/core/storage/StorageManager.ets
|
arkts
|
getBoolean
|
获取布尔值
|
static async getBoolean(key: string, defaultValue: boolean = false): Promise<boolean> {
const instance = StorageManager.getInstance();
if (!instance.dataPreferences) {
await instance.init();
if (!instance.dataPreferences) {
return defaultValue;
}
}
try {
const value = await instance.dataPreferences.get(key, defaultValue);
return Boolean(value);
} catch (e) {
Logger.error('StorageManager', `Failed to get boolean: ${String(e)}`);
return defaultValue;
}
}
|
AST#method_declaration#Left static async getBoolean AST#parameter_list#Left ( AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left defaultValue : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left instance = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StorageManager 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#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left instance AST#expression#Right AST#unary_expression#Right AST#expression#Right . dataPreferences 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 instance AST#expression#Right AST#await_expression#Right AST#expression#Right . init AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left instance AST#expression#Right AST#unary_expression#Right AST#expression#Right . dataPreferences AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left defaultValue AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left value = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left instance AST#expression#Right AST#await_expression#Right AST#expression#Right . dataPreferences AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right , AST#expression#Left defaultValue 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 Boolean 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#catch_clause#Left catch ( e ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'StorageManager' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to get boolean: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left String AST#expression#Right AST#argument_list#Left ( AST#expression#Left e 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 defaultValue AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static async getBoolean(key: string, defaultValue: boolean = false): Promise<boolean> {
const instance = StorageManager.getInstance();
if (!instance.dataPreferences) {
await instance.init();
if (!instance.dataPreferences) {
return defaultValue;
}
}
try {
const value = await instance.dataPreferences.get(key, defaultValue);
return Boolean(value);
} catch (e) {
Logger.error('StorageManager', `Failed to get boolean: ${String(e)}`);
return defaultValue;
}
}
|
https://github.com/liuchao0739/arkTS_universal_starter.git/blob/0ca845f5ae0e78db439dc09f712d100c0dd46ed3/entry/src/main/ets/core/storage/StorageManager.ets#L124-L139
|
25e753fad9bb42b40e9f1992e113f206e09ba1c8
|
github
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/Solutions/Social/GrapeSquare/feature/authorizedControl/src/main/ets/model/DataFactory.ets
|
arkts
|
加载动态列表数据,到参数传入的懒加载数据列表中
@param listData 懒加载数据列表
|
export async function makeDataLocal(listData: TrendsData): Promise<void> {
Logger.info(TAG, 'makeDataLocal');
for (let i = 0; i < trendsList[0].length; i++) {
listData.pushData(trendsList[0][i]);
}
}
|
AST#export_declaration#Left export AST#function_declaration#Left async function makeDataLocal AST#parameter_list#Left ( AST#parameter#Left listData : AST#type_annotation#Left AST#primary_type#Left TrendsData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left 'makeDataLocal' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left AST#subscript_expression#Left AST#expression#Left trendsList AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right 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 AST#member_expression#Left AST#expression#Left listData AST#expression#Right . pushData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left trendsList AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export async function makeDataLocal(listData: TrendsData): Promise<void> {
Logger.info(TAG, 'makeDataLocal');
for (let i = 0; i < trendsList[0].length; i++) {
listData.pushData(trendsList[0][i]);
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Solutions/Social/GrapeSquare/feature/authorizedControl/src/main/ets/model/DataFactory.ets#L28-L33
|
d14a988d93564f24d67257a1d06c34f01f889e7d
|
gitee
|
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/common/components/Sounds/Cloud/CSoundDbAccessor/CSoundDbAccessor.ets
|
arkts
|
deleteById
|
MARK: - 删除操作
|
async deleteById(idxx: number): Promise<void> {
if (!this.db) return;
const sql = `DELETE FROM ${Tables.CSound.name}
WHERE ${Tables.CSound.Col.idxx} = ?`;
await this.db.updateDb(sql, [idxx]);
}
|
AST#method_declaration#Left async deleteById AST#parameter_list#Left ( AST#parameter#Left idxx : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . db AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left sql = AST#expression#Left AST#template_literal#Left ` DELETE FROM AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right
WHERE AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . CSound AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . idxx AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right = ? ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . db AST#member_expression#Right AST#expression#Right . updateDb AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sql AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left idxx AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async deleteById(idxx: number): Promise<void> {
if (!this.db) return;
const sql = `DELETE FROM ${Tables.CSound.name}
WHERE ${Tables.CSound.Col.idxx} = ?`;
await this.db.updateDb(sql, [idxx]);
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/components/Sounds/Cloud/CSoundDbAccessor/CSoundDbAccessor.ets#L109-L116
|
5a6d1e8107fa184c2afffcda1261f03680134674
|
github
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/FileUtil.ets
|
arkts
|
access
|
检查文件是否存在,使用Promise异步回调。
@param path 文件应用沙箱路径。
@returns
|
static access(path: string): Promise<boolean> {
return fs.access(path);
}
|
AST#method_declaration#Left static access AST#parameter_list#Left ( AST#parameter#Left path : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fs AST#expression#Right . access AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left path AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static access(path: string): Promise<boolean> {
return fs.access(path);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/FileUtil.ets#L381-L383
|
21c53db6bd281bba9c2def24afe098d8c34ce2c5
|
gitee
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/pipwindow/src/main/ets/model/AVPlayer.ets
|
arkts
|
this
|
设置显示画面,当播放的资源为纯音频时无需设置
|
this.avPlayer.prepare();
|
AST#method_declaration#Left this AST#ERROR#Left . avPlayer . prepare AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right ; AST#method_declaration#Right
|
this.avPlayer.prepare();
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/pipwindow/src/main/ets/model/AVPlayer.ets#L208-L208
|
97d1dbc5153646cd1479389e7541b68cb9ab9445
|
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/utils/RegexUtil.ets
|
arkts
|
isMatch
|
给定内容是否匹配正则(配合RegexUtil里的正则常量一起使用)
@param content 内容
@param regex 正则
|
static isMatch(content: string, pattern: string): boolean {
if (content === undefined || content === null) {
return false;
} else {
return new RegExp(pattern).test(content);
}
}
|
AST#method_declaration#Left static isMatch AST#parameter_list#Left ( AST#parameter#Left content : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left pattern : 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#binary_expression#Left AST#expression#Left content AST#expression#Right === AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left content AST#expression#Right === AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left RegExp AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left pattern AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . test AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left content AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static isMatch(content: string, pattern: string): boolean {
if (content === undefined || content === null) {
return false;
} else {
return new RegExp(pattern).test(content);
}
}
|
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/utils/RegexUtil.ets#L197-L203
|
9d77a31b579303cba4b3ad9be45178f5aa04249f
|
github
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/bluetooth/src/main/ets/pages/BluetoothAdvertiser.ets
|
arkts
|
toggleAdvertiser
|
开启或关闭心率广播
|
toggleAdvertiser(): void {
Log.showInfo(TAG, `toggleAdvertiser: startAdvertiserState = ${this.startAdvertiserState}`)
if (this.startAdvertiserState) {
// TODO: 知识点 关闭蓝牙服务
advertiserBluetoothViewModel.stopAdvertiser();
this.toggleHeartRate(false);
this.startAdvertiserState = false;
} else {
// TODO: 知识点 开启蓝牙服务
let ret = advertiserBluetoothViewModel.startAdvertiser();
if (ret) {
this.localName = advertiserBluetoothViewModel.getLocalName();
// 模拟心率跳动
this.toggleHeartRate(true);
this.startAdvertiserState = true;
} else {
Log.showError(TAG, `toggleAdvertiser: ret = ${ret}`);
}
}
}
|
AST#method_declaration#Left toggleAdvertiser 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 Log AST#expression#Right . showInfo 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 ` toggleAdvertiser: startAdvertiserState = AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . startAdvertiserState 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#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . startAdvertiserState AST#member_expression#Right AST#expression#Right ) { // TODO: 知识点 关闭蓝牙服务 AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left advertiserBluetoothViewModel AST#expression#Right . stopAdvertiser 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 . toggleHeartRate 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . startAdvertiserState 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 } else { // TODO: 知识点 开启蓝牙服务 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 ret = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left advertiserBluetoothViewModel AST#expression#Right . startAdvertiser AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left ret 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 . localName AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left advertiserBluetoothViewModel AST#expression#Right . getLocalName 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . toggleHeartRate 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . startAdvertiserState 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 } else { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Log AST#expression#Right . showError 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 ` toggleAdvertiser: ret = AST#template_substitution#Left $ { AST#expression#Left ret 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_if_statement#Right AST#ui_control_flow#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
toggleAdvertiser(): void {
Log.showInfo(TAG, `toggleAdvertiser: startAdvertiserState = ${this.startAdvertiserState}`)
if (this.startAdvertiserState) {
advertiserBluetoothViewModel.stopAdvertiser();
this.toggleHeartRate(false);
this.startAdvertiserState = false;
} else {
let ret = advertiserBluetoothViewModel.startAdvertiser();
if (ret) {
this.localName = advertiserBluetoothViewModel.getLocalName();
this.toggleHeartRate(true);
this.startAdvertiserState = true;
} else {
Log.showError(TAG, `toggleAdvertiser: ret = ${ret}`);
}
}
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/bluetooth/src/main/ets/pages/BluetoothAdvertiser.ets#L86-L105
|
000b0b077ead1cc7528633562ff9096db98c09dc
|
gitee
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
LoadPerformanceInWeb/entry/src/main/ets/pages/common.ets
|
arkts
|
initWeb
|
This function is a user-defined function and can be used as an initialization function. Initialize builderNode through UIContext, and then initialize the contents in @Builder through the Build interface in BuilderNode.
|
initWeb(url: string, uiContext: UIContext, control: WebviewController): void {
if (this.rootNode != null) {
return;
}
// Bind the pre-created WebviewController
this.rootWebviewController = control;
// Creating a node requires uiContext.
this.rootNode = new BuilderNode(uiContext);
// Create dynamic Web components
this.rootNode.build(wrapBuilder<Data[]>(webBuilder), { url: url, controller: control });
}
|
AST#method_declaration#Left initWeb AST#parameter_list#Left ( AST#parameter#Left url : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left uiContext : AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left control : AST#type_annotation#Left AST#primary_type#Left WebviewController AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rootNode 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#block_statement#Left { AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // Bind the pre-created WebviewController 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 . rootWebviewController AST#member_expression#Right = AST#expression#Left control AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // Creating a node requires uiContext. 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 . rootNode AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left BuilderNode AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uiContext 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 // Create dynamic Web components 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 . rootNode AST#member_expression#Right AST#expression#Right . build AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left wrapBuilder AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Data [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left webBuilder AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left url AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left controller AST#property_name#Right : AST#expression#Left control 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#method_declaration#Right
|
initWeb(url: string, uiContext: UIContext, control: WebviewController): void {
if (this.rootNode != null) {
return;
}
this.rootWebviewController = control;
this.rootNode = new BuilderNode(uiContext);
this.rootNode.build(wrapBuilder<Data[]>(webBuilder), { url: url, controller: control });
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/LoadPerformanceInWeb/entry/src/main/ets/pages/common.ets#L80-L90
|
c5053bb3bcc55bf662e9fe4b19da41b96c7b249a
|
gitee
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
CommonEventAndNotification/AlarmClock/entry/src/main/ets/viewmodel/MainViewModel.ets
|
arkts
|
Declare class of main view model.
|
export default class MainViewModel {
static instant: MainViewModel = new MainViewModel();
private reminderService: ReminderService;
private alarms: Array<AlarmItem>;
private constructor() {
this.alarms = new Array();
this.reminderService = new ReminderService();
this.reminderService.openNotificationPermission();
}
/**
* Get instant in MainViewModel.
*/
// public static getInstant() {
// if (this.instant == null) {
// this.instant = new MainViewModel();
// }
// return this.instant;
// }
/**
* Querying alarm task database tables.
*
* @param callback (alarms: Array<AlarmItem>) => void
*/
private queryDatabaseAlarms(callback: (alarms: Array<AlarmItem>) => void) {
let preference = GlobalContext.getContext().getObject('preference') as PreferencesHandler;
preference.get(CommonConstants.ALARM_KEY).then((data: string) => {
if (!DataTypeUtils.isNull(data)) {
this.alarms = JSON.parse(data);
callback(this.alarms);
}
})
}
/**
* Refresh alarm task.
*
* @param callback (alarms: Array<AlarmItem>) => void
*/
public queryAlarmsTasker(callback: (alarms: Array<AlarmItem>) => void) {
let that = this;
that.queryDatabaseAlarms(callback);
let preference = GlobalContext.getContext().getObject('preference') as PreferencesHandler;
preference.addPreferencesListener({
onDataChanged() {
that.queryDatabaseAlarms(callback);
}
} as PreferencesListener)
}
/**
* Padding zeros for insufficient digits
*
* @param val number
* @return content string
*/
public fillZero(val: number): string{
return (val > MainConstant.DEFAULT_SINGLE_DIGIT_MAX
? val.toString()
: (MainConstant.DEFAULT_ZEROING + val));
}
/**
* Get noon content in MainViewModel.
*
* @param hour number
* @return content string
*/
public getNoonContent(hour: number): string{
return (hour < CommonConstants.DEFAULT_TOTAL_HOUR
? MainConstant.DEFAULT_STRING_MORNING
: MainConstant.DEFAULT_STRING_AFTERNOON);
}
/**
* Get task time content in MainViewModel.
*
* @param hour number
* @param minute number
* @return content string
*/
public getTaskTimeContent(hour: number, minute: number): string {
return (this.fillZero(hour > CommonConstants.DEFAULT_TOTAL_HOUR ? hour - CommonConstants.DEFAULT_TOTAL_HOUR : hour)
+ MainConstant.DEFAULT_STRING_COLON
+ this.fillZero(minute));
}
/**
* Get description content in MainViewModel.
*
* @param alarmItem AlarmItem
* @return content string
*/
public getDescContent(alarmItem: AlarmItem): string{
return (alarmItem.name + CommonConstants.DEFAULT_STRING_COMMA
+ (alarmItem.isRepeat
? this.getAlarmRepeatDayContent(alarmItem.repeatDays)
: CommonConstants.DEFAULT_STRING_NO_REPEAT));
}
/**
* Obtains the number of repetition days of an alarm task.
*
* @param repeatDays Array<number>
* @return content string
*/
public getAlarmRepeatDayContent(repeatDays: Array<number>): string{
let content = MainConstant.DEFAULT_STRING_NULL;
for (let i = 0; i < repeatDays.length; i++) {
let repeatDay = repeatDays[i];
let repeatContent: string = CommonConstants.DEFAULT_STRING_MONDAY;
switch (repeatDay) {
case WeekDays.DEFAULT_NUMBER_MONDAY:
repeatContent = CommonConstants.DEFAULT_STRING_MONDAY;
break;
case WeekDays.DEFAULT_NUMBER_TUESDAY:
repeatContent = CommonConstants.DEFAULT_STRING_TUESDAY;
break;
case WeekDays.DEFAULT_NUMBER_WEDNESDAY:
repeatContent = CommonConstants.DEFAULT_STRING_WEDNESDAY;
break;
case WeekDays.DEFAULT_NUMBER_THURSDAY:
repeatContent = CommonConstants.DEFAULT_STRING_THURSDAY;
break;
case WeekDays.DEFAULT_NUMBER_FRIDAY:
repeatContent = CommonConstants.DEFAULT_STRING_FRIDAY;
break;
case WeekDays.DEFAULT_NUMBER_SATURDAY:
repeatContent = CommonConstants.DEFAULT_STRING_SATURDAY;
break;
case WeekDays.DEFAULT_NUMBER_SUNDAY:
repeatContent = CommonConstants.DEFAULT_STRING_SUNDAY;
break;
default:
break;
}
|
AST#export_declaration#Left export default AST#class_declaration#Left class MainViewModel AST#class_body#Left { AST#property_declaration#Left static instant : AST#type_annotation#Left AST#primary_type#Left MainViewModel 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 MainViewModel AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private reminderService : AST#type_annotation#Left AST#primary_type#Left ReminderService AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left private alarms : 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 AlarmItem AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#constructor_declaration#Left private constructor AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . alarms 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#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . reminderService AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ReminderService AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#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 . reminderService AST#member_expression#Right AST#expression#Right . openNotificationPermission AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right /**
* Get instant in MainViewModel.
*/ // public static getInstant() { // if (this.instant == null) { // this.instant = new MainViewModel(); // } // return this.instant; // } /**
* Querying alarm task database tables.
*
* @param callback (alarms: Array<AlarmItem>) => void
*/ AST#method_declaration#Left private queryDatabaseAlarms AST#parameter_list#Left ( AST#parameter#Left callback : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left alarms : 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 AlarmItem AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left preference = 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 GlobalContext AST#expression#Right . getContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getObject AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'preference' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left PreferencesHandler 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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left preference AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . ALARM_KEY AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left DataTypeUtils AST#expression#Right AST#unary_expression#Right AST#expression#Right . isNull 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#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 . alarms AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left callback AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . alarms AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#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 /**
* Refresh alarm task.
*
* @param callback (alarms: Array<AlarmItem>) => void
*/ AST#method_declaration#Left public queryAlarmsTasker AST#parameter_list#Left ( AST#parameter#Left callback : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left alarms : 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 AlarmItem AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left that = AST#expression#Left this 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 that AST#expression#Right . queryDatabaseAlarms AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left callback AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left preference = 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 GlobalContext AST#expression#Right . getContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getObject AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'preference' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left PreferencesHandler 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 preference AST#expression#Right . addPreferencesListener AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left onDataChanged AST#property_name#Right AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . queryDatabaseAlarms AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left callback AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left PreferencesListener AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* Padding zeros for insufficient digits
*
* @param val number
* @return content string
*/ AST#method_declaration#Left public fillZero AST#parameter_list#Left ( AST#parameter#Left val : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left val AST#expression#Right > AST#expression#Left MainConstant AST#expression#Right AST#binary_expression#Right AST#expression#Right . DEFAULT_SINGLE_DIGIT_MAX AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left val AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left MainConstant AST#expression#Right . DEFAULT_ZEROING AST#member_expression#Right AST#expression#Right + AST#expression#Left val AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* Get noon content in MainViewModel.
*
* @param hour number
* @return content string
*/ AST#method_declaration#Left public getNoonContent AST#parameter_list#Left ( AST#parameter#Left hour : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left hour AST#expression#Right < AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . DEFAULT_TOTAL_HOUR AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left MainConstant AST#expression#Right . DEFAULT_STRING_MORNING AST#member_expression#Right AST#expression#Right : AST#expression#Left MainConstant AST#expression#Right AST#conditional_expression#Right AST#expression#Right . DEFAULT_STRING_AFTERNOON AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* Get task time content in MainViewModel.
*
* @param hour number
* @param minute number
* @return content string
*/ AST#method_declaration#Left public getTaskTimeContent AST#parameter_list#Left ( AST#parameter#Left hour : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left minute : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . fillZero AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left hour AST#expression#Right > AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . DEFAULT_TOTAL_HOUR AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left hour AST#expression#Right - AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . DEFAULT_TOTAL_HOUR AST#member_expression#Right AST#expression#Right : AST#expression#Left hour AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left MainConstant AST#expression#Right AST#binary_expression#Right AST#expression#Right . DEFAULT_STRING_COLON AST#member_expression#Right AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . fillZero AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left minute AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* Get description content in MainViewModel.
*
* @param alarmItem AlarmItem
* @return content string
*/ AST#method_declaration#Left public getDescContent AST#parameter_list#Left ( AST#parameter#Left alarmItem : AST#type_annotation#Left AST#primary_type#Left AlarmItem 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#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left alarmItem AST#expression#Right . name AST#member_expression#Right AST#expression#Right + AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . DEFAULT_STRING_COMMA 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#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left alarmItem AST#expression#Right . isRepeat AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getAlarmRepeatDayContent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left alarmItem AST#expression#Right . repeatDays AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left CommonConstants AST#expression#Right AST#conditional_expression#Right AST#expression#Right . DEFAULT_STRING_NO_REPEAT AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* Obtains the number of repetition days of an alarm task.
*
* @param repeatDays Array<number>
* @return content string
*/ AST#property_declaration#Left public getAlarmRepeatDayContent AST#ERROR#Left AST#parameter_list#Left ( AST#parameter#Left repeatDays : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left content = AST#expression#Left AST#member_expression#Left AST#expression#Left MainConstant AST#expression#Right . DEFAULT_STRING_NULL AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left repeatDays AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#member_expression#Left AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right AST#ERROR#Left ) { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left repeatDay = AST#expression#Left AST#subscript_expression#Left AST#expression#Left repeatDays AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left repeatContent : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DEFAULT_STRING_MONDAY AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left switch AST#expression#Right AST#argument_list#Left ( AST#expression#Left repeatDay AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right { AST#property_name#Left case AST#property_name#Right WeekDays AST#ERROR#Right . DEFAULT_NUMBER_MONDAY AST#member_expression#Right AST#expression#Right AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left repeatContent AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DEFAULT_STRING_MONDAY AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left break ; AST#property_declaration#Right AST#property_declaration#Left case AST#ERROR#Left WeekDays . DEFAULT_NUMBER_TUESDAY AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left repeatContent AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DEFAULT_STRING_TUESDAY AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left break ; AST#property_declaration#Right AST#property_declaration#Left case AST#ERROR#Left WeekDays . DEFAULT_NUMBER_WEDNESDAY AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left repeatContent AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DEFAULT_STRING_WEDNESDAY AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left break ; AST#property_declaration#Right AST#property_declaration#Left case AST#ERROR#Left WeekDays . DEFAULT_NUMBER_THURSDAY AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left repeatContent AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DEFAULT_STRING_THURSDAY AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left break ; AST#property_declaration#Right AST#property_declaration#Left case AST#ERROR#Left WeekDays . DEFAULT_NUMBER_FRIDAY AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left repeatContent AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DEFAULT_STRING_FRIDAY AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left break ; AST#property_declaration#Right AST#property_declaration#Left case AST#ERROR#Left WeekDays . DEFAULT_NUMBER_SATURDAY AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left repeatContent AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DEFAULT_STRING_SATURDAY AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left break ; AST#property_declaration#Right AST#property_declaration#Left case AST#ERROR#Left WeekDays . DEFAULT_NUMBER_SUNDAY AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left repeatContent AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DEFAULT_STRING_SUNDAY AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left break ; AST#property_declaration#Right AST#property_declaration#Left default : AST#type_annotation#Left AST#primary_type#Left break AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export default class MainViewModel {
static instant: MainViewModel = new MainViewModel();
private reminderService: ReminderService;
private alarms: Array<AlarmItem>;
private constructor() {
this.alarms = new Array();
this.reminderService = new ReminderService();
this.reminderService.openNotificationPermission();
}
private queryDatabaseAlarms(callback: (alarms: Array<AlarmItem>) => void) {
let preference = GlobalContext.getContext().getObject('preference') as PreferencesHandler;
preference.get(CommonConstants.ALARM_KEY).then((data: string) => {
if (!DataTypeUtils.isNull(data)) {
this.alarms = JSON.parse(data);
callback(this.alarms);
}
})
}
public queryAlarmsTasker(callback: (alarms: Array<AlarmItem>) => void) {
let that = this;
that.queryDatabaseAlarms(callback);
let preference = GlobalContext.getContext().getObject('preference') as PreferencesHandler;
preference.addPreferencesListener({
onDataChanged() {
that.queryDatabaseAlarms(callback);
}
} as PreferencesListener)
}
public fillZero(val: number): string{
return (val > MainConstant.DEFAULT_SINGLE_DIGIT_MAX
? val.toString()
: (MainConstant.DEFAULT_ZEROING + val));
}
public getNoonContent(hour: number): string{
return (hour < CommonConstants.DEFAULT_TOTAL_HOUR
? MainConstant.DEFAULT_STRING_MORNING
: MainConstant.DEFAULT_STRING_AFTERNOON);
}
public getTaskTimeContent(hour: number, minute: number): string {
return (this.fillZero(hour > CommonConstants.DEFAULT_TOTAL_HOUR ? hour - CommonConstants.DEFAULT_TOTAL_HOUR : hour)
+ MainConstant.DEFAULT_STRING_COLON
+ this.fillZero(minute));
}
public getDescContent(alarmItem: AlarmItem): string{
return (alarmItem.name + CommonConstants.DEFAULT_STRING_COMMA
+ (alarmItem.isRepeat
? this.getAlarmRepeatDayContent(alarmItem.repeatDays)
: CommonConstants.DEFAULT_STRING_NO_REPEAT));
}
public getAlarmRepeatDayContent(repeatDays: Array<number>): string{
let content = MainConstant.DEFAULT_STRING_NULL;
for (let i = 0; i < repeatDays.length; i++) {
let repeatDay = repeatDays[i];
let repeatContent: string = CommonConstants.DEFAULT_STRING_MONDAY;
switch (repeatDay) {
case WeekDays.DEFAULT_NUMBER_MONDAY:
repeatContent = CommonConstants.DEFAULT_STRING_MONDAY;
break;
case WeekDays.DEFAULT_NUMBER_TUESDAY:
repeatContent = CommonConstants.DEFAULT_STRING_TUESDAY;
break;
case WeekDays.DEFAULT_NUMBER_WEDNESDAY:
repeatContent = CommonConstants.DEFAULT_STRING_WEDNESDAY;
break;
case WeekDays.DEFAULT_NUMBER_THURSDAY:
repeatContent = CommonConstants.DEFAULT_STRING_THURSDAY;
break;
case WeekDays.DEFAULT_NUMBER_FRIDAY:
repeatContent = CommonConstants.DEFAULT_STRING_FRIDAY;
break;
case WeekDays.DEFAULT_NUMBER_SATURDAY:
repeatContent = CommonConstants.DEFAULT_STRING_SATURDAY;
break;
case WeekDays.DEFAULT_NUMBER_SUNDAY:
repeatContent = CommonConstants.DEFAULT_STRING_SUNDAY;
break;
default:
break;
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/CommonEventAndNotification/AlarmClock/entry/src/main/ets/viewmodel/MainViewModel.ets#L28-L165
|
24a5b836897693107ae3df6c3f7a555bfc9f3958
|
gitee
|
|
common-apps/ZRouter
|
5adc9c4bcca6ba7d9b323451ed464e1e9b47eee6
|
RouterApi/src/main/ets/api/Router.ets
|
arkts
|
redirectForResult2
|
@deprecated
@see {ZRouter.getInstance().redirectForResult2}
@param name
@param param
@param callback
|
public static redirectForResult2<T>(name: string, param?: ObjectOrNull, callback?: OnPopResultCallback<T>) {
ZRouter.getRouterMgr().redirectForResult2(name, param, callback)
}
|
AST#method_declaration#Left public static redirectForResult2 AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left param ? : AST#type_annotation#Left AST#primary_type#Left ObjectOrNull AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left callback ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left OnPopResultCallback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ZRouter AST#expression#Right . getRouterMgr AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . redirectForResult2 AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left name AST#expression#Right , AST#expression#Left param AST#expression#Right , AST#expression#Left callback AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
public static redirectForResult2<T>(name: string, param?: ObjectOrNull, callback?: OnPopResultCallback<T>) {
ZRouter.getRouterMgr().redirectForResult2(name, param, callback)
}
|
https://github.com/common-apps/ZRouter/blob/5adc9c4bcca6ba7d9b323451ed464e1e9b47eee6/RouterApi/src/main/ets/api/Router.ets#L418-L420
|
64d86fee449099e8c1546cbbd681897cd1c992ae
|
gitee
|
openharmony/interface_sdk-js
|
c349adc73e2ec1f61f6fca489b5af059e3ed6999
|
api/arkui/component/gesture.d.ets
|
arkts
|
onActionStart
|
Rotation gesture recognition success callback.
@param { Callback<GestureEvent> } event
@returns { RotationGesture }
@syscap SystemCapability.ArkUI.ArkUI.Full
@crossplatform
@atomicservice
@since 20
|
onActionStart(event: Callback<GestureEvent>): RotationGesture;
|
AST#method_declaration#Left onActionStart AST#parameter_list#Left ( AST#parameter#Left event : 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 GestureEvent 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 RotationGesture AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right
|
onActionStart(event: Callback<GestureEvent>): RotationGesture;
|
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/arkui/component/gesture.d.ets#L677-L677
|
043baa36e0cc1e10d2d542b1738bd5224296bc54
|
gitee
|
Application-Security-Automation/Arktan.git
|
3ad9cb05235e38b00cd5828476aa59a345afa1c0
|
dataset/completeness/datatype/function/function_002_F.ets
|
arkts
|
Introduction 函数类型
|
export function function_002_F(taint_src : Function) {
let _t = taint_src;
let _clean = f;
taint.Sink(_clean)
}
|
AST#export_declaration#Left export AST#function_declaration#Left function function_002_F AST#parameter_list#Left ( AST#parameter#Left taint_src : AST#type_annotation#Left AST#primary_type#Left Function AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left _t = AST#expression#Left taint_src AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left _clean = AST#expression#Left f AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left taint AST#expression#Right . Sink AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left _clean AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export function function_002_F(taint_src : Function) {
let _t = taint_src;
let _clean = f;
taint.Sink(_clean)
}
|
https://github.com/Application-Security-Automation/Arktan.git/blob/3ad9cb05235e38b00cd5828476aa59a345afa1c0/dataset/completeness/datatype/function/function_002_F.ets#L5-L9
|
637ba6809bb756b7412e98810e9aaa6b4a38de6a
|
github
|
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
ETSUI/AnimateRefresh/entry/src/main/ets/viewmodel/CardModel.ets
|
arkts
|
Card model.
|
export default class CardModel {
selectedIcon: Resource;
defaultIcon: Resource;
content: string;
constructor(selectedIcon: Resource, defaultIcon: Resource, content: string) {
this.selectedIcon = selectedIcon;
this.defaultIcon = defaultIcon;
this.content = content;
}
}
|
AST#export_declaration#Left export default AST#class_declaration#Left class CardModel AST#class_body#Left { AST#property_declaration#Left selectedIcon : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left defaultIcon : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left content : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left selectedIcon : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left defaultIcon : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left content : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#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 . selectedIcon AST#member_expression#Right = AST#expression#Left selectedIcon 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 . defaultIcon AST#member_expression#Right = AST#expression#Left defaultIcon 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 . content AST#member_expression#Right = AST#expression#Left content 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 default class CardModel {
selectedIcon: Resource;
defaultIcon: Resource;
content: string;
constructor(selectedIcon: Resource, defaultIcon: Resource, content: string) {
this.selectedIcon = selectedIcon;
this.defaultIcon = defaultIcon;
this.content = content;
}
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/ETSUI/AnimateRefresh/entry/src/main/ets/viewmodel/CardModel.ets#L19-L29
|
b1d09f6cde3deee67cacbbc6398806b3b935c3f4
|
gitee
|
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/game/InteractiveGameService.ets
|
arkts
|
getGameSession
|
获取游戏会话
|
getGameSession(sessionId: string): GameSession | null {
return this.activeSessions.get(sessionId) || null;
}
|
AST#method_declaration#Left getGameSession AST#parameter_list#Left ( AST#parameter#Left sessionId : 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 GameSession 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#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 . activeSessions AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sessionId AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
getGameSession(sessionId: string): GameSession | null {
return this.activeSessions.get(sessionId) || null;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/game/InteractiveGameService.ets#L354-L356
|
7bb657e2d1eaf81ae97c45db4c544434cd248047
|
github
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_dialog/src/main/ets/dialog/DialogHelper.ets
|
arkts
|
showBottomSheetDialog
|
显示动作面板
|
static showBottomSheetDialog(options: BottomSheetOptions): string {
ActionParameter.initBaseDefault(options);
ActionParameter.initBottomSheetDefault(options, true);
const dialogId = ActionBaseCore.getInstance().openCustomDialog(wrapBuilder(BottomSheetDialogBuilder), options);
return dialogId;
}
|
AST#method_declaration#Left static showBottomSheetDialog AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left BottomSheetOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ActionParameter AST#expression#Right . initBaseDefault AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left options AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ActionParameter AST#expression#Right . initBottomSheetDefault AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left options AST#expression#Right , AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left const AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left dialogId = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ActionBaseCore AST#expression#Right . getInstance AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . openCustomDialog AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left wrapBuilder AST#expression#Right AST#argument_list#Left ( AST#expression#Left BottomSheetDialogBuilder AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left options AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left dialogId AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
static showBottomSheetDialog(options: BottomSheetOptions): string {
ActionParameter.initBaseDefault(options);
ActionParameter.initBottomSheetDefault(options, true);
const dialogId = ActionBaseCore.getInstance().openCustomDialog(wrapBuilder(BottomSheetDialogBuilder), options);
return dialogId;
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_dialog/src/main/ets/dialog/DialogHelper.ets#L234-L239
|
ef7cd79cc625dacf62d8c92eb979ce2c81321e31
|
gitee
|
openharmony-tpc/ohos_mpchart
|
4fb43a7137320ef2fee2634598f53d93975dfb4a
|
library/src/main/ets/components/listener/ChartTouchListener.ets
|
arkts
|
startAction
|
Calls the OnChartGestureListener to do the start callback
@param me
|
public startAction(isTouchEvent: boolean, me: TouchEvent | GestureEvent) {
let l: OnChartGestureListener | null = this.mChart.getOnChartGestureListener();
if (l != null) {
l.onChartGestureStart(isTouchEvent, me, this.mLastGesture);
}
}
|
AST#method_declaration#Left public startAction AST#parameter_list#Left ( AST#parameter#Left isTouchEvent : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left me : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left TouchEvent AST#primary_type#Right | AST#primary_type#Left GestureEvent 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#variable_declaration#Left let AST#variable_declarator#Left l : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left OnChartGestureListener AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mChart AST#member_expression#Right AST#expression#Right . getOnChartGestureListener AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left l 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 l AST#expression#Right . onChartGestureStart AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left isTouchEvent AST#expression#Right , AST#expression#Left me AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mLastGesture AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public startAction(isTouchEvent: boolean, me: TouchEvent | GestureEvent) {
let l: OnChartGestureListener | null = this.mChart.getOnChartGestureListener();
if (l != null) {
l.onChartGestureStart(isTouchEvent, me, this.mLastGesture);
}
}
|
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/listener/ChartTouchListener.ets#L75-L82
|
f07d09b1b83185c72623da8c6b78913d35abea34
|
gitee
|
Piagari/arkts_example.git
|
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
|
hmos_app-main/hmos_app-main/DriverLicenseExam-master/commons/commonLib/src/main/ets/model/CommonModel.ets
|
arkts
|
requestPhoneNumber
|
绑定手机号
|
public requestPhoneNumber() {
RouterModule.openDialog(DialogMap.BIND_PHONE_DIALOG,);
}
|
AST#method_declaration#Left public requestPhoneNumber 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 RouterModule AST#expression#Right . openDialog AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left DialogMap AST#expression#Right . BIND_PHONE_DIALOG AST#member_expression#Right AST#expression#Right AST#ERROR#Left , AST#ERROR#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
public requestPhoneNumber() {
RouterModule.openDialog(DialogMap.BIND_PHONE_DIALOG,);
}
|
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/DriverLicenseExam-master/commons/commonLib/src/main/ets/model/CommonModel.ets#L61-L63
|
2a34a50c97b0459b37b376580a62027fd94990df
|
github
|
openharmony/arkui_ace_engine
|
30c7d1ee12fbedf0fabece54291d75897e2ad44f
|
advanced_ui_component/treeview/source/treeview.ets
|
arkts
|
getInstance
|
Get instance of treeListenerManager.
@return treeListenerManager instance.
@static
@syscap SystemCapability.ArkUI.ArkUI.Full
@since 10
Get instance of treeListenerManager.
@return treeListenerManager instance.
@static
@syscap SystemCapability.ArkUI.ArkUI.Full
@atomicservice
@since 11
|
static getInstance(): TreeListenerManager {
if (AppStorage.Get('app_key_event_bus') === undefined) {
AppStorage.SetOrCreate('app_key_event_bus', new TreeListenerManager())
}
return AppStorage.Get('app_key_event_bus') as TreeListenerManager;
}
|
AST#method_declaration#Left static getInstance AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left TreeListenerManager AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . Get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'app_key_event_bus' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right === AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . SetOrCreate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'app_key_event_bus' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left TreeListenerManager AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . Get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'app_key_event_bus' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left TreeListenerManager AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
static getInstance(): TreeListenerManager {
if (AppStorage.Get('app_key_event_bus') === undefined) {
AppStorage.SetOrCreate('app_key_event_bus', new TreeListenerManager())
}
return AppStorage.Get('app_key_event_bus') as TreeListenerManager;
}
|
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/advanced_ui_component/treeview/source/treeview.ets#L947-L952
|
d6b72a1ad52b3427deb80fdcf2831e3110f6b75f
|
gitee
|
zqaini002/YaoYaoLingXian.git
|
5095b12cbeea524a87c42d0824b1702978843d39
|
YaoYaoLingXian/entry/src/main/ets/entryability/EntryAbility.ets
|
arkts
|
用于存储UIAbility上下文的静态引用
|
export class AppContext {
private static context: common.Context | null = null;
// 设置上下文引用
static setContext(context: common.Context): void {
AppContext.context = context;
hilog.info(DOMAIN, TAG, 'AppContext: 已保存UIAbility上下文引用');
}
// 获取上下文引用
static getContext(): common.Context | null {
return AppContext.context;
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class AppContext AST#class_body#Left { AST#property_declaration#Left private static context : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#qualified_type#Left common . Context AST#qualified_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right // 设置上下文引用 AST#method_declaration#Left static setContext 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#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AppContext AST#expression#Right . context AST#member_expression#Right = AST#expression#Left context AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#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 'AppContext: 已保存UIAbility上下文引用' 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 static getContext AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#qualified_type#Left common . Context AST#qualified_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AppContext AST#expression#Right . context 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 AppContext {
private static context: common.Context | null = null;
static setContext(context: common.Context): void {
AppContext.context = context;
hilog.info(DOMAIN, TAG, 'AppContext: 已保存UIAbility上下文引用');
}
static getContext(): common.Context | null {
return AppContext.context;
}
}
|
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/entryability/EntryAbility.ets#L10-L23
|
c962635d5ed6617b92f8c4fee0930c7dc29e6d98
|
github
|
|
JinnyWang-Space/guanlanwenjuan.git
|
601c4aa6c427e643d7bf42bc21945f658738e38c
|
setting/src/main/ets/views/DotSheetBind.ets
|
arkts
|
languageChange
|
监听语言模式变化
|
@Monitor('appGeneralData.languageId')
languageChange() {
if (this.appGeneralData.languageId === 0) {
application.getApplicationContext().setLanguage(i18n.System.getSystemLanguage());
} else if (this.appGeneralData.languageId === 1) {
application.getApplicationContext().setLanguage('zh-Hans');
} else {
application.getApplicationContext().setLanguage('en-Latn-US');
}
}
|
AST#method_declaration#Left AST#decorator#Left @ Monitor ( AST#expression#Left 'appGeneralData.languageId' AST#expression#Right ) AST#decorator#Right languageChange 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . appGeneralData AST#member_expression#Right AST#expression#Right . languageId AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left application 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 . setLanguage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left i18n AST#expression#Right . System AST#member_expression#Right AST#expression#Right . getSystemLanguage 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 } else AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . appGeneralData AST#member_expression#Right AST#expression#Right . languageId AST#member_expression#Right AST#expression#Right === AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left application 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 . setLanguage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'zh-Hans' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } else { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left application 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 . setLanguage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'en-Latn-US' 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_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Monitor('appGeneralData.languageId')
languageChange() {
if (this.appGeneralData.languageId === 0) {
application.getApplicationContext().setLanguage(i18n.System.getSystemLanguage());
} else if (this.appGeneralData.languageId === 1) {
application.getApplicationContext().setLanguage('zh-Hans');
} else {
application.getApplicationContext().setLanguage('en-Latn-US');
}
}
|
https://github.com/JinnyWang-Space/guanlanwenjuan.git/blob/601c4aa6c427e643d7bf42bc21945f658738e38c/setting/src/main/ets/views/DotSheetBind.ets#L89-L98
|
576d4a76838fa32d9be581ef957dd7bfbd3b6caa
|
github
|
anhao0226/harmony-music-player.git
|
4bc1d8f9f5fdb573af387d3ba9ad333c9beb8073
|
entry/src/main/ets/models/CommentModel.ets
|
arkts
|
Comments
|
export interface CommentResponse {
code: number
data: CommentData
message: string
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface CommentResponse AST#object_type#Left { AST#type_member#Left code : 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 data : AST#type_annotation#Left AST#primary_type#Left CommentData AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right AST#type_member#Left message : 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 CommentResponse {
code: number
data: CommentData
message: string
}
|
https://github.com/anhao0226/harmony-music-player.git/blob/4bc1d8f9f5fdb573af387d3ba9ad333c9beb8073/entry/src/main/ets/models/CommentModel.ets#L4-L8
|
7cc507aac9c1dd115660d73eb50f8760dbe5f405
|
github
|
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/accessibility/AccessibilityService.ets
|
arkts
|
对比度级别
|
export enum ContrastLevel {
LOW = 'low',
NORMAL = 'normal',
HIGH = 'high',
MAXIMUM = 'maximum'
}
|
AST#export_declaration#Left export AST#enum_declaration#Left enum ContrastLevel AST#enum_body#Left { AST#enum_member#Left LOW = AST#expression#Left 'low' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left NORMAL = AST#expression#Left 'normal' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left HIGH = AST#expression#Left 'high' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left MAXIMUM = AST#expression#Left 'maximum' AST#expression#Right AST#enum_member#Right } AST#enum_body#Right AST#enum_declaration#Right AST#export_declaration#Right
|
export enum ContrastLevel {
LOW = 'low',
NORMAL = 'normal',
HIGH = 'high',
MAXIMUM = 'maximum'
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/accessibility/AccessibilityService.ets#L39-L44
|
8a6b5c7aeab162ce46337936f107688645451651
|
github
|
|
mayuanwei/harmonyOS_bilibili
|
8a36b68b1ddf4433e2e17ee10fee4993cce2a6c5
|
Q1/grammar/entry/src/main/ets/pages/LifeCycle1.ets
|
arkts
|
aboutToDisappear
|
组件析构销毁时触发: 删除 移出
|
aboutToDisappear() {
console.log('LifeCycle1_son....aboutToDisappear')
}
|
AST#method_declaration#Left aboutToDisappear 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 console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'LifeCycle1_son....aboutToDisappear' 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
|
aboutToDisappear() {
console.log('LifeCycle1_son....aboutToDisappear')
}
|
https://github.com/mayuanwei/harmonyOS_bilibili/blob/8a36b68b1ddf4433e2e17ee10fee4993cce2a6c5/Q1/grammar/entry/src/main/ets/pages/LifeCycle1.ets#L75-L77
|
4e89c13e71cb4cd76388e3396d48274c3c2a7b1f
|
gitee
|
xt1314520/IbestKnowTeach
|
61f0a7a3d328ad5a52de8fd699b9e1e94de0203b
|
entry/src/main/ets/api/MessageApi.type.ets
|
arkts
|
最新消息
|
export interface MessageInfoNew extends BaseTime {
/**
* 消息id
*/
id: number
/**
* 消息标题
*/
title: string
/**
* 消息内容
*/
content: string
/**
* 消息类型'1' 系统消息 '2' 通知公告
*/
type: string
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface MessageInfoNew AST#extends_clause#Left extends BaseTime AST#extends_clause#Right AST#object_type#Left { /**
* 消息id
*/ AST#type_member#Left id : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right /**
* 消息标题
*/ AST#type_member#Left title : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right /**
* 消息内容
*/ AST#type_member#Left content : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right /**
* 消息类型'1' 系统消息 '2' 通知公告
*/ AST#type_member#Left type : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
|
export interface MessageInfoNew extends BaseTime {
id: number
title: string
content: string
type: string
}
|
https://github.com/xt1314520/IbestKnowTeach/blob/61f0a7a3d328ad5a52de8fd699b9e1e94de0203b/entry/src/main/ets/api/MessageApi.type.ets#L4-L22
|
f6d45b0b4c6c003a9708d2a514e858dbf7d2086c
|
gitee
|
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/customaddresspicker/src/main/ets/customaddresspicker/view/CustomAddressPicker.ets
|
arkts
|
addressSelectPage
|
地址选择半模态弹窗页面
|
@Builder
addressSelectPage() {
Column() {
// 自定义TabBar
this.customTabBar()
Divider()
.width($r('app.string.custom_address_picker_percent_ninety'))
.strokeWidth(Constants.SIZE_ONE)
.color($r('app.color.custom_address_picker_area_name_divider_color'))
// 自定义Tabs
this.customTabs()
}
.width($r('app.string.custom_address_picker_full_size'))
.height($r('app.string.custom_address_picker_full_size'))
.backgroundColor(Color.White)
.padding({ bottom: this.bottomHeight + 'px' })
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right addressSelectPage 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 { // 自定义TabBar 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 . customTabBar 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 Divider ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.custom_address_picker_percent_ninety' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . strokeWidth ( AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . SIZE_ONE AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . color ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.custom_address_picker_area_name_divider_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 // 自定义Tabs 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 . customTabs 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 AST#resource_expression#Left $r ( AST#expression#Left 'app.string.custom_address_picker_full_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.custom_address_picker_full_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bottomHeight AST#member_expression#Right AST#expression#Right + AST#expression#Left 'px' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
addressSelectPage() {
Column() {
this.customTabBar()
Divider()
.width($r('app.string.custom_address_picker_percent_ninety'))
.strokeWidth(Constants.SIZE_ONE)
.color($r('app.color.custom_address_picker_area_name_divider_color'))
this.customTabs()
}
.width($r('app.string.custom_address_picker_full_size'))
.height($r('app.string.custom_address_picker_full_size'))
.backgroundColor(Color.White)
.padding({ bottom: this.bottomHeight + 'px' })
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/customaddresspicker/src/main/ets/customaddresspicker/view/CustomAddressPicker.ets#L511-L527
|
158f3bbb28be039be8942f7cc9195e5c50d5c5c8
|
gitee
|
from-north-to-north/OpenHarmony_p7885
|
f6ea526c039db535a7c958fa154ccfcb3668b37c
|
hap/easy_demo/tcp_demo/tcp/entry/src/main/ets/pages/Index.ets
|
arkts
|
resolveArrayBuffer
|
解析标准系统开发板接收到的 对端TCP socket设备发送的数据
|
resolveArrayBuffer(message: ArrayBuffer): string {
if (message instanceof ArrayBuffer) {
let dataView = new DataView(message)
console.info(`length ${dataView.byteLength}`)
let str = "";
for (let i = 0; i < dataView.byteLength; ++i) {
let c = String.fromCharCode(dataView.getUint8(i))
if (c !== "\n") {
str += c
}
}
console.info(`message array buffer:${str}`)
return str;
}
return ""; // 默认返回空字符串
}
|
AST#method_declaration#Left resolveArrayBuffer AST#parameter_list#Left ( AST#parameter#Left message : AST#type_annotation#Left AST#primary_type#Left ArrayBuffer 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left message AST#expression#Right instanceof AST#expression#Left ArrayBuffer AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left dataView = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left DataView AST#expression#Right AST#new_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#ERROR#Left console AST#ERROR#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` length AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left dataView AST#expression#Right . byteLength 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#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left str = AST#expression#Left "" AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left dataView AST#expression#Right AST#binary_expression#Right AST#expression#Right . byteLength 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 c = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left String AST#expression#Right . fromCharCode AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dataView AST#expression#Right . getUint8 AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left i AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left c AST#expression#Right !== AST#expression#Left "\n" 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 str += AST#expression#Left c 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#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 console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` message array buffer: AST#template_substitution#Left $ { AST#expression#Left str 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 str 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
|
resolveArrayBuffer(message: ArrayBuffer): string {
if (message instanceof ArrayBuffer) {
let dataView = new DataView(message)
console.info(`length ${dataView.byteLength}`)
let str = "";
for (let i = 0; i < dataView.byteLength; ++i) {
let c = String.fromCharCode(dataView.getUint8(i))
if (c !== "\n") {
str += c
}
}
console.info(`message array buffer:${str}`)
return str;
}
return "";
}
|
https://github.com/from-north-to-north/OpenHarmony_p7885/blob/f6ea526c039db535a7c958fa154ccfcb3668b37c/hap/easy_demo/tcp_demo/tcp/entry/src/main/ets/pages/Index.ets#L44-L59
|
a7bb183d4ac657ca826bf4715488f18d63638bbd
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/common/i18n/I18nManager.ets
|
arkts
|
loadLanguageTranslations
|
加载指定语言的翻译
|
private async loadLanguageTranslations(language: SupportedLanguage): Promise<void> {
try {
// TODO: 从资源文件或网络加载翻译
// 这里应该根据语言代码加载相应的翻译文件
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP,
`Loading translations for ${language}`);
} catch (error) {
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP,
`Failed to load translations for ${language}: ${error}`);
}
}
|
AST#method_declaration#Left private async loadLanguageTranslations AST#parameter_list#Left ( AST#parameter#Left language : AST#type_annotation#Left AST#primary_type#Left SupportedLanguage AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // TODO: 从资源文件或网络加载翻译 // 这里应该根据语言代码加载相应的翻译文件 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Loading translations for AST#template_substitution#Left $ { AST#expression#Left language 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 load translations for AST#template_substitution#Left $ { AST#expression#Left language AST#expression#Right } AST#template_substitution#Right : 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#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private async loadLanguageTranslations(language: SupportedLanguage): Promise<void> {
try {
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP,
`Loading translations for ${language}`);
} catch (error) {
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP,
`Failed to load translations for ${language}: ${error}`);
}
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/i18n/I18nManager.ets#L705-L715
|
0017c6b4adf1fd2e81792faeab59dcc02f4995f1
|
github
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_dialog/src/main/ets/model/ToastOptions.ets
|
arkts
|
TODO Toast基本参数类
author: 桃花镇童长老ᥫ᭡
since: 2024/08/18
|
export interface ToastOptions {
uiContext?: UIContext; //UIContext上下文
message?: string | Resource; //显示的文本信息。默认字体为'Harmony Sans',不支持设置其他字体。
duration?: number //默认值1500ms,取值区间:1500ms-10000ms。若小于1500ms则取默认值,若大于10000ms则取上限值10000ms。
fontColor?: ResourceColor; // 文本提示框文本颜色。默认值:Color.Black
bottom?: string | number; //设置弹窗底部边框距离导航条的高度,ToastShowMode.TOP_MOST模式下,软键盘拉起时,如果bottom值过小,toast要被软键盘遮挡时,会自动避让至距离软键盘80vp处。ToastShowMode.DEFAULT模式下,软键盘拉起时,会上移软键盘的高度。默认值:80vp。说明:当底部没有导航条时,bottom为设置弹窗底部边框距离窗口底部的高度。设置对齐方式alignment后,bottom不生效。
alignment?: Alignment; //对齐方式。默认值:undefined,默认底部偏上位置。
offset?: Offset; //在对齐方式上的偏移。默认值:{ dx: 0, dy: 0 },默认没有偏移。说明: 只支持设置px类型的数值,如需设置vp,可以将vp改成px传入。
backgroundColor?: ResourceColor; //文本提示框背板颜色,建议八位色值前两位为透明度。默认值:Color.Transparent。说明:当设置了backgroundColor为非透明色时,backgroundBlurStyle需要设置为BlurStyle.NONE,否则颜色显示将不符合预期效果。
backgroundBlurStyle?: BlurStyle; //文本提示框背板模糊材质。默认值:BlurStyle.COMPONENT_ULTRA_THICK。说明:设置为BlurStyle.NONE即可关闭背景虚化。当设置了backgroundBlurStyle为非NONE值时,则不要设置backgroundColor,否则颜色显示将不符合预期效果。
shadow?: ShadowOptions | ShadowStyle; //文本提示框背板阴影。默认值:ShadowStyle.OUTER_DEFAULT_MD
showMode?: promptAction.ToastShowMode; //设置弹窗是否显示在应用之上。默认值:ToastShowMode.DEFAULT,默认显示在应用内。
enableHoverMode?: boolean; //是否响应悬停态。默认值:false,默认不响应。<API14+>
hoverModeArea?: HoverModeAreaType; //响应悬停态时,弹窗的显示区域。默认值:HoverModeAreaType.BOTTOM_SCREEN,默认显示在下半屏。<API14+>
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface ToastOptions AST#object_type#Left { AST#type_member#Left uiContext ? : AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; //UIContext上下文 AST#type_member#Left message ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Resource AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#type_member#Right ; //显示的文本信息。默认字体为'Harmony Sans',不支持设置其他字体。 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 //默认值1500ms,取值区间:1500ms-10000ms。若小于1500ms则取默认值,若大于10000ms则取上限值10000ms。 AST#type_member#Left fontColor ? : AST#type_annotation#Left AST#primary_type#Left ResourceColor AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; // 文本提示框文本颜色。默认值:Color.Black AST#type_member#Left bottom ? : 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#type_member#Right ; //设置弹窗底部边框距离导航条的高度,ToastShowMode.TOP_MOST模式下,软键盘拉起时,如果bottom值过小,toast要被软键盘遮挡时,会自动避让至距离软键盘80vp处。ToastShowMode.DEFAULT模式下,软键盘拉起时,会上移软键盘的高度。默认值:80vp。说明:当底部没有导航条时,bottom为设置弹窗底部边框距离窗口底部的高度。设置对齐方式alignment后,bottom不生效。 AST#type_member#Left alignment ? : AST#type_annotation#Left AST#primary_type#Left Alignment AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; //对齐方式。默认值:undefined,默认底部偏上位置。 AST#type_member#Left offset ? : AST#type_annotation#Left AST#primary_type#Left Offset AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; //在对齐方式上的偏移。默认值:{ dx: 0, dy: 0 },默认没有偏移。说明: 只支持设置px类型的数值,如需设置vp,可以将vp改成px传入。 AST#type_member#Left backgroundColor ? : AST#type_annotation#Left AST#primary_type#Left ResourceColor AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; //文本提示框背板颜色,建议八位色值前两位为透明度。默认值:Color.Transparent。说明:当设置了backgroundColor为非透明色时,backgroundBlurStyle需要设置为BlurStyle.NONE,否则颜色显示将不符合预期效果。 AST#type_member#Left backgroundBlurStyle ? : AST#type_annotation#Left AST#primary_type#Left BlurStyle AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; //文本提示框背板模糊材质。默认值:BlurStyle.COMPONENT_ULTRA_THICK。说明:设置为BlurStyle.NONE即可关闭背景虚化。当设置了backgroundBlurStyle为非NONE值时,则不要设置backgroundColor,否则颜色显示将不符合预期效果。 AST#type_member#Left shadow ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ShadowOptions AST#primary_type#Right | AST#primary_type#Left ShadowStyle AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#type_member#Right ; //文本提示框背板阴影。默认值:ShadowStyle.OUTER_DEFAULT_MD AST#type_member#Left showMode ? : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left promptAction . ToastShowMode AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; //设置弹窗是否显示在应用之上。默认值:ToastShowMode.DEFAULT,默认显示在应用内。 AST#type_member#Left enableHoverMode ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; //是否响应悬停态。默认值:false,默认不响应。<API14+> AST#type_member#Left hoverModeArea ? : AST#type_annotation#Left AST#primary_type#Left HoverModeAreaType AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; //响应悬停态时,弹窗的显示区域。默认值:HoverModeAreaType.BOTTOM_SCREEN,默认显示在下半屏。<API14+> } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
|
export interface ToastOptions {
uiContext?: UIContext;
message?: string | Resource;
duration?: number
fontColor?: ResourceColor;
bottom?: string | number;
alignment?: Alignment;
offset?: Offset;
backgroundColor?: ResourceColor;
backgroundBlurStyle?: BlurStyle;
shadow?: ShadowOptions | ShadowStyle;
showMode?: promptAction.ToastShowMode;
enableHoverMode?: boolean;
hoverModeArea?: HoverModeAreaType;
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_dialog/src/main/ets/model/ToastOptions.ets#L23-L40
|
e60122d46b64f48d774356116ce12a2a602815fb
|
gitee
|
|
Piagari/arkts_example.git
|
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
|
hmos_app-main/hmos_app-main/MusicHome-master/features/musicList/src/main/ets/components/MusicControlComponent.ets
|
arkts
|
getImageColor
|
Get largest proportion color of an image.
|
getImageColor() {
if (!this.context) {
return;
}
this.context.resourceManager.getMediaContent(this.songList[this.selectIndex].label)
.then((value: Uint8Array) => {
let buffer = value.buffer as ArrayBuffer;
image.createImageSource(buffer).createPixelMap().then((pixelMap) => {
effectKit.createColorPicker(pixelMap, (error, colorPicker) => {
if (error) {
Logger.error('Failed to create color picker.');
} else {
let color = colorPicker.getLargestProportionColor();
let colorArr = ColorConversion.dealColor(color.red, color.green, color.blue);
this.imageColor = `rgba(${colorArr[0]}, ${colorArr[1]}, ${colorArr[2]}, 1)`;
}
});
let headFilter = effectKit.createEffect(pixelMap);
if (headFilter !== null) {
headFilter.blur(PlayerConstants.IMAGE_BLUR);
headFilter.getEffectPixelMap().then((value) => {
this.imageLabel = value;
});
}
})
.catch((error: BusinessError) => {
Logger.error(`${error.code} + ${error.message}`);
});
})
.catch((error: BusinessError) => {
Logger.error(`${error.code} + ${error.message}`);
});
}
|
AST#method_declaration#Left getImageColor AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . context AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#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#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right AST#expression#Right . resourceManager AST#member_expression#Right AST#expression#Right . getMediaContent AST#member_expression#Right AST#expression#Right AST#argument_list#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 . songList AST#member_expression#Right AST#expression#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectIndex AST#member_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . label AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left buffer = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left value AST#expression#Right . buffer AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left ArrayBuffer 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 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 image AST#expression#Right . createImageSource 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 . createPixelMap AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left pixelMap 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 effectKit AST#expression#Right . createColorPicker AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left pixelMap AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error AST#parameter#Right , AST#parameter#Left colorPicker AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left error AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Failed to create color picker.' 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#variable_declaration#Left let AST#variable_declarator#Left color = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left colorPicker AST#expression#Right . getLargestProportionColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left colorArr = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ColorConversion AST#expression#Right . dealColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left color AST#expression#Right . red AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left color AST#expression#Right . green AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left color AST#expression#Right . blue AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imageColor AST#member_expression#Right = AST#expression#Left AST#template_literal#Left ` rgba( AST#template_substitution#Left $ { AST#expression#Left AST#subscript_expression#Left AST#expression#Left colorArr AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right } AST#template_substitution#Right , AST#template_substitution#Left $ { AST#expression#Left AST#subscript_expression#Left AST#expression#Left colorArr AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right } AST#template_substitution#Right , AST#template_substitution#Left $ { AST#expression#Left AST#subscript_expression#Left AST#expression#Left colorArr AST#expression#Right [ AST#expression#Left 2 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right } AST#template_substitution#Right , 1) ` AST#template_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#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 headFilter = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left effectKit AST#expression#Right . createEffect AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left pixelMap 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 headFilter 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 headFilter AST#expression#Right . blur AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left PlayerConstants AST#expression#Right . IMAGE_BLUR AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left headFilter AST#expression#Right . getEffectPixelMap AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imageLabel AST#member_expression#Right = AST#expression#Left value AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#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 . 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#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right + AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left 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#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right + AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#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
|
getImageColor() {
if (!this.context) {
return;
}
this.context.resourceManager.getMediaContent(this.songList[this.selectIndex].label)
.then((value: Uint8Array) => {
let buffer = value.buffer as ArrayBuffer;
image.createImageSource(buffer).createPixelMap().then((pixelMap) => {
effectKit.createColorPicker(pixelMap, (error, colorPicker) => {
if (error) {
Logger.error('Failed to create color picker.');
} else {
let color = colorPicker.getLargestProportionColor();
let colorArr = ColorConversion.dealColor(color.red, color.green, color.blue);
this.imageColor = `rgba(${colorArr[0]}, ${colorArr[1]}, ${colorArr[2]}, 1)`;
}
});
let headFilter = effectKit.createEffect(pixelMap);
if (headFilter !== null) {
headFilter.blur(PlayerConstants.IMAGE_BLUR);
headFilter.getEffectPixelMap().then((value) => {
this.imageLabel = value;
});
}
})
.catch((error: BusinessError) => {
Logger.error(`${error.code} + ${error.message}`);
});
})
.catch((error: BusinessError) => {
Logger.error(`${error.code} + ${error.message}`);
});
}
|
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/MusicHome-master/features/musicList/src/main/ets/components/MusicControlComponent.ets#L252-L284
|
8030f3e0bc706d2f8e0e0f1e46f285fb4cee8bfa
|
github
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Media/SimpleVideo/entry/src/main/ets/viewmodel/HorizontalVideoItem.ets
|
arkts
|
HorizontalVideoItem
|
Horizontal picture class.
|
@Observed
export class HorizontalVideoItem {
id: number;
image: Resource;
name: string;
constructor(id: number, image: Resource, name: string) {
this.id = id;
this.image = image;
this.name = name;
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Observed AST#decorator#Right export class HorizontalVideoItem AST#class_body#Left { AST#property_declaration#Left id : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left image : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor 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 image : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . id AST#member_expression#Right = AST#expression#Left id AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . image AST#member_expression#Right = AST#expression#Left image 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 . name AST#member_expression#Right = AST#expression#Left name AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right } AST#class_body#Right AST#decorated_export_declaration#Right
|
@Observed
export class HorizontalVideoItem {
id: number;
image: Resource;
name: string;
constructor(id: number, image: Resource, name: string) {
this.id = id;
this.image = image;
this.name = name;
}
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Media/SimpleVideo/entry/src/main/ets/viewmodel/HorizontalVideoItem.ets#L19-L30
|
37a0e3cc46ade361bd5e15b9ca909be23a7e3f2f
|
gitee
|
harmonyos/samples
|
f5d967efaa7666550ee3252d118c3c73a77686f5
|
HarmonyOS_NEXT/Notification/CustomNotificationBadge/notification/src/main/ets/notification/NotificationContentUtil.ets
|
arkts
|
initBasicNotificationContent
|
init basic notification content
@param basicContent
@return return the created NotificationContent
|
initBasicNotificationContent(basicContent: notification.NotificationBasicContent) {
let result: NotificationContentUtilResultType = {
contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, // 通知内容类型
normal: basicContent // 基本类型通知内容
}
return result;
}
|
AST#method_declaration#Left initBasicNotificationContent AST#parameter_list#Left ( AST#parameter#Left basicContent : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left notification . NotificationBasicContent 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 result : AST#type_annotation#Left AST#primary_type#Left NotificationContentUtilResultType AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left contentType AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left notification AST#expression#Right . ContentType AST#member_expression#Right AST#expression#Right . NOTIFICATION_CONTENT_BASIC_TEXT AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 通知内容类型 AST#property_assignment#Left AST#property_name#Left normal AST#property_name#Right : AST#expression#Left basicContent AST#expression#Right AST#property_assignment#Right // 基本类型通知内容 } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
initBasicNotificationContent(basicContent: notification.NotificationBasicContent) {
let result: NotificationContentUtilResultType = {
contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: basicContent
}
return result;
}
|
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/HarmonyOS_NEXT/Notification/CustomNotificationBadge/notification/src/main/ets/notification/NotificationContentUtil.ets#L33-L39
|
2ae0c9dbcb1fb98e1beeac2046e286fe5002573a
|
gitee
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
ArkUI/StateManagement/entry/src/main/ets/segment/segment6.ets
|
arkts
|
getUserData
|
[EndExclude Case3_start] Getting server-side user information in a business class
|
getUserData(): void {
this.userAccountRepository.getUserData().then((data: UserData) => {
// 1.Storing user information data into AppStorage
AppStorage.setOrCreate('userData', data);
});
}
|
AST#method_declaration#Left getUserData AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . userAccountRepository AST#member_expression#Right AST#expression#Right . getUserData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left UserData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // 1.Storing user information data into AppStorage AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'userData' AST#expression#Right , 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#builder_function_body#Right AST#method_declaration#Right
|
getUserData(): void {
this.userAccountRepository.getUserData().then((data: UserData) => {
AppStorage.setOrCreate('userData', data);
});
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ArkUI/StateManagement/entry/src/main/ets/segment/segment6.ets#L42-L47
|
26a4f6f4384def64a49c45905f67664631427e3a
|
gitee
|
buqiuz/game-puzzle.git
|
605dc0fac0738466db308a8ba255b5e9094c52ac
|
entry/src/main/ets/model/PuzzleSolver.ets
|
arkts
|
manhattanDistance
|
计算曼哈顿距离
|
manhattanDistance(state: number[], goalPos: Map<number, [number, number]>): number {
let distance = 0;
for (let index = 0; index < state.length; index++) {
const value = state[index];
if (value !== 0) { // 空白块不计算距离
const goalPosition = goalPos.get(value)!;
const goalX = goalPosition[0];
const goalY = goalPosition[1];
const curX = Math.floor(index / this._splitSize);
const curY = index % this._splitSize;
distance += Math.abs(goalX - curX) + Math.abs(goalY - curY);
}
}
return distance;
}
|
AST#method_declaration#Left manhattanDistance AST#parameter_list#Left ( AST#parameter#Left state : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left goalPos : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Map AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left 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#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 distance = AST#expression#Left 0 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 index = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right < AST#expression#Left state AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left index AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left value = AST#expression#Left AST#subscript_expression#Left AST#expression#Left state AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left value 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 goalPosition = AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left goalPos AST#expression#Right . get 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#non_null_assertion_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 goalX = AST#expression#Left AST#subscript_expression#Left AST#expression#Left goalPosition AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left goalY = AST#expression#Left AST#subscript_expression#Left AST#expression#Left goalPosition AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left curX = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right / AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . _splitSize AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left curY = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right % AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . _splitSize AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left distance += AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . abs AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left goalX AST#expression#Right - AST#expression#Left curX AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left Math AST#expression#Right AST#binary_expression#Right AST#expression#Right . abs AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left goalY AST#expression#Right - AST#expression#Left curY AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left distance AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
manhattanDistance(state: number[], goalPos: Map<number, [number, number]>): number {
let distance = 0;
for (let index = 0; index < state.length; index++) {
const value = state[index];
if (value !== 0) {
const goalPosition = goalPos.get(value)!;
const goalX = goalPosition[0];
const goalY = goalPosition[1];
const curX = Math.floor(index / this._splitSize);
const curY = index % this._splitSize;
distance += Math.abs(goalX - curX) + Math.abs(goalY - curY);
}
}
return distance;
}
|
https://github.com/buqiuz/game-puzzle.git/blob/605dc0fac0738466db308a8ba255b5e9094c52ac/entry/src/main/ets/model/PuzzleSolver.ets#L18-L32
|
40ea5241a35165c6ee7f2a833fd22ca14b1aaafc
|
github
|
common-apps/ZRouter
|
5adc9c4bcca6ba7d9b323451ed464e1e9b47eee6
|
RouterApi/src/main/ets/animation/NavAnimationMgr.ets
|
arkts
|
defaultAnimateBuilder
|
全局转场动画构造器,构造后还是需要给页面设置NavAnimationModifier,不然不生效
@returns
|
defaultAnimateBuilder() {
const builder = NavAnimParamBuilder.builder()
this._defaultCallback = builder.getCallback()
return builder
}
|
AST#method_declaration#Left defaultAnimateBuilder AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left builder = AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NavAnimParamBuilder AST#expression#Right . builder AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left this AST#ERROR#Right . _defaultCallback AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left builder AST#expression#Right . getCallback 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#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left builder AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
defaultAnimateBuilder() {
const builder = NavAnimParamBuilder.builder()
this._defaultCallback = builder.getCallback()
return builder
}
|
https://github.com/common-apps/ZRouter/blob/5adc9c4bcca6ba7d9b323451ed464e1e9b47eee6/RouterApi/src/main/ets/animation/NavAnimationMgr.ets#L290-L294
|
c9a67528eba7396115beb0647313e2f5a6ca37e0
|
gitee
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/models/managers/sns/qq/QQLoginManager.ets
|
arkts
|
/////////////////////////////////////////////////////////////////////// / / QQ登录官方文档 /https://wiki.connect.qq.com/harmonyos_sdk环境搭建 https://wiki.connect.qq.com/使用authorization_code获取access_token#:~:text=Step2:通过Authorization%20Code获取Access%20Token / 关键步骤: / 1.在华为AppGallery Connect上 / 创建AppLinks: 如: https://www.dancishu.com(Zhika暂时使用) , / (要在www.dancishu.com下添加.well-known/applinking.json) / { / "applinking": { / "apps": [ / { / "appIdentifier": "6917583818702073612"//zhika,需要在当前签名下,从此应用中获取,参考BundleUtils.getBundleAppIdentifier() / } / ] / } / } / 2.在QQ互联平台配置: / AppLinks,bundleName,fingerprint的md5,(需要在当前的签名下,从此应用中获取,参考BundleUtils.getBundleAppIdentifier()) / 如果,跳转到QQ后,点击“同意”,时出现错误提示“未注册鸿蒙应用,前往官网注册”时,需要联系QQ客服,重新上线一下应用才行。 / / 3.配置module.json5中的:entities,actions,uris, querySchemes <参考注释:QQ登录配置> / 4. EntryAbility的onNewWant中添加: QQLoginManager.shared.handleResult(want) / / / by ko 2025.11.25 / /////////////////////////////////////////////////////////////////////// QQ登录管理类
|
export class QQLoginManager {
private static instance: QQLoginManager | null = null;
// 从应用配置中获取,这里需要替换为实际的AppId
private APP_ID: number = Number(AppSettings.CfgQQ.AppId);
private iQQOpenApi: IQQOpenApi | null = null;
private SnsOneLoginCallback: SnsOneLoginCallback | null = null;
// 单例模式
public static get shared(): QQLoginManager {
if (!QQLoginManager.instance) {
QQLoginManager.instance = new QQLoginManager();
QQLoginManager.instance.init();
}
return QQLoginManager.instance;
}
private init(): void {
try {
let openApiOption: OpenApiConfig = {
forceEnableWeb: false,
autoHandleAuthResult: true,
}
this.iQQOpenApi = QQOpenApiFactory.createApi(this.APP_ID, openApiOption);
DebugLog.d('QQLoginManager initialized successfully');
} catch (error) {
DebugLog.e('QQLoginManager init failed: ' + JSON.stringify(error));
}
}
// 检查QQ是否安装
public isQQAppInstalled(): boolean {
try {
return this.iQQOpenApi?.isQQInstalled() ?? false;
} catch (error) {
DebugLog.e('Check QQ installation failed: ' + JSON.stringify(error));
return false;
}
}
// 登录方法 - Promise方式 (not using)
public async login(callback: SnsOneLoginCallback): Promise<void> {
this.SnsOneLoginCallback = callback;
if (!this.iQQOpenApi) {
this.handleLoginError('QQOpenApi not initialized');
return;
}
try {
const result: AuthResult = await this.iQQOpenApi.login({
scope: "all",
useQrCode: false,
networkTimeout: 0,
forceWebLogin: false
});
this.handleAuthResult(result);
} catch (error) {
this.handleLoginError(error);
}
}
// 登录方法 - 回调方式
public loginWithCallback(callback: SnsOneLoginCallback): void {
this.SnsOneLoginCallback = callback;
if (!this.iQQOpenApi) {
this.handleLoginError('QQOpenApi not initialized');
return;
}
const loginApiCallback: ApiCallback<AuthResponse> = {
onComplete: (response: AuthResponse): void => {
DebugLog.d(`onComplete response: ${JSON.stringify(response)}`);
if (response.ret == 0) {
this.onAuthSuccess(response);
} else {
this.handleLoginError(`Auth failed with ret: ${response.ret}`);
}
},
onError: (msg: string | null): void => {
this.handleLoginError(`onError: ${msg}`);
},
onCancel: (msg: string | null): void => {
this.handleLoginError('Login canceled by user');
}
};
try {
this.iQQOpenApi.login({
scope: "all",
useQrCode: false,
networkTimeout: 0,
forceWebLogin: false
}, loginApiCallback);
} catch (error) {
this.handleLoginError(error);
}
}
// 处理授权结果
private handleAuthResult(result: AuthResult): void {
switch (result.type) {
case AuthResultType.Success:
if (result.authResponse) {
this.onAuthSuccess(result.authResponse);
} else {
this.handleLoginError( 'Auth response is null');
}
break;
case AuthResultType.Cancel:
this.handleLoginError('Login canceled by user');
break;
case AuthResultType.Error:
this.handleLoginError(result.message ?? 'Unknown error');
break;
default:
this.handleLoginError('Unknown auth result type');
}
|
AST#export_declaration#Left export AST#class_declaration#Left class QQLoginManager AST#class_body#Left { AST#property_declaration#Left private static instance : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left QQLoginManager AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right // 从应用配置中获取,这里需要替换为实际的AppId AST#property_declaration#Left private APP_ID : 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 Number AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppSettings AST#expression#Right . CfgQQ AST#member_expression#Right AST#expression#Right . AppId AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private iQQOpenApi : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left IQQOpenApi AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private SnsOneLoginCallback : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left SnsOneLoginCallback AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right // 单例模式 AST#method_declaration#Left public static get AST#ERROR#Left shared AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left QQLoginManager AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left QQLoginManager AST#expression#Right AST#unary_expression#Right AST#expression#Right . instance AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left QQLoginManager AST#expression#Right . instance AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left QQLoginManager AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#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 QQLoginManager AST#expression#Right . instance AST#member_expression#Right AST#expression#Right . init AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left QQLoginManager AST#expression#Right . instance AST#member_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left 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#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 openApiOption : AST#type_annotation#Left AST#primary_type#Left OpenApiConfig AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left forceEnableWeb AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left autoHandleAuthResult 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#ERROR#Left this AST#ERROR#Right . iQQOpenApi AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left QQOpenApiFactory AST#expression#Right . createApi 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 . APP_ID AST#member_expression#Right AST#expression#Right , AST#expression#Left openApiOption AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DebugLog AST#expression#Right . d AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'QQLoginManager initialized successfully' 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 DebugLog AST#expression#Right . e 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 'QQLoginManager init failed: ' AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // 检查QQ是否安装 AST#method_declaration#Left public isQQAppInstalled 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#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . iQQOpenApi AST#member_expression#Right AST#expression#Right ?. isQQInstalled AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ?? AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#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 DebugLog AST#expression#Right . e 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 'Check QQ installation failed: ' AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#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 // 登录方法 - Promise方式 (not using) AST#method_declaration#Left public async login AST#parameter_list#Left ( AST#parameter#Left callback : AST#type_annotation#Left AST#primary_type#Left SnsOneLoginCallback AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . SnsOneLoginCallback AST#member_expression#Right = AST#expression#Left callback AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . iQQOpenApi 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 . handleLoginError AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'QQOpenApi not initialized' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left result : AST#type_annotation#Left AST#primary_type#Left AuthResult AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . iQQOpenApi AST#member_expression#Right AST#expression#Right . login 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 scope AST#property_name#Right : AST#expression#Left "all" AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left useQrCode AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left networkTimeout AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left forceWebLogin AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right 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 . handleAuthResult AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left result AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#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 this AST#expression#Right . handleLoginError AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // 登录方法 - 回调方式 AST#method_declaration#Left public loginWithCallback AST#parameter_list#Left ( AST#parameter#Left callback : AST#type_annotation#Left AST#primary_type#Left SnsOneLoginCallback AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . SnsOneLoginCallback AST#member_expression#Right = AST#expression#Left callback AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . iQQOpenApi 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 . handleLoginError AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'QQOpenApi not initialized' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left loginApiCallback : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left ApiCallback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AuthResponse 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 onComplete AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left response : AST#type_annotation#Left AST#primary_type#Left AuthResponse AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DebugLog AST#expression#Right . d AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` onComplete response: 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 response 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . ret 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 . onAuthSuccess AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left response AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right 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 this AST#expression#Right . handleLoginError AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` Auth failed with ret: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . ret AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left onError AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( 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_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . handleLoginError AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` onError: AST#template_substitution#Left $ { AST#expression#Left msg 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#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left onCancel AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( 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_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . handleLoginError AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Login canceled by user' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . iQQOpenApi AST#member_expression#Right AST#expression#Right . login 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 scope AST#property_name#Right : AST#expression#Left "all" AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left useQrCode AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left networkTimeout AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left forceWebLogin AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left loginApiCallback 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 this AST#expression#Right . handleLoginError AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // 处理授权结果 AST#method_declaration#Left private handleAuthResult AST#parameter_list#Left ( AST#parameter#Left result : AST#type_annotation#Left AST#primary_type#Left AuthResult AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right { AST#expression_statement#Left AST#expression#Left switch AST#expression#Right AST#expression_statement#Right AST#ERROR#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . type AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AuthResultType AST#expression#Right . Success AST#member_expression#Right AST#expression#Right AST#expression_statement#Right AST#ERROR#Left : AST#ERROR#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . authResponse 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 . onAuthSuccess AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . authResponse AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } else { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . handleLoginError AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Auth response is null' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left break AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AuthResultType AST#expression#Right . Cancel AST#member_expression#Right AST#expression#Right AST#expression_statement#Right : AST#qualified_type#Left this . handleLoginError AST#qualified_type#Right ( AST#ERROR#Right AST#expression_statement#Left AST#expression#Left 'Login canceled by user' AST#expression#Right AST#ERROR#Left ) AST#ERROR#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left break AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AuthResultType AST#expression#Right . Error AST#member_expression#Right AST#expression#Right AST#expression_statement#Right AST#ERROR#Right : AST#ERROR#Left AST#qualified_type#Left this . handleLoginError AST#qualified_type#Right AST#ERROR#Right AST#type_annotation#Left AST#primary_type#Left AST#parenthesized_type#Left ( AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left result . message AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ? ? 'Unknown error' AST#ERROR#Right ) AST#parenthesized_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right AST#property_declaration#Left break ; AST#property_declaration#Right AST#property_declaration#Left default : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left this . handleLoginError AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ( 'Unknown auth result type' ) AST#ERROR#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class QQLoginManager {
private static instance: QQLoginManager | null = null;
private APP_ID: number = Number(AppSettings.CfgQQ.AppId);
private iQQOpenApi: IQQOpenApi | null = null;
private SnsOneLoginCallback: SnsOneLoginCallback | null = null;
public static get shared(): QQLoginManager {
if (!QQLoginManager.instance) {
QQLoginManager.instance = new QQLoginManager();
QQLoginManager.instance.init();
}
return QQLoginManager.instance;
}
private init(): void {
try {
let openApiOption: OpenApiConfig = {
forceEnableWeb: false,
autoHandleAuthResult: true,
}
this.iQQOpenApi = QQOpenApiFactory.createApi(this.APP_ID, openApiOption);
DebugLog.d('QQLoginManager initialized successfully');
} catch (error) {
DebugLog.e('QQLoginManager init failed: ' + JSON.stringify(error));
}
}
public isQQAppInstalled(): boolean {
try {
return this.iQQOpenApi?.isQQInstalled() ?? false;
} catch (error) {
DebugLog.e('Check QQ installation failed: ' + JSON.stringify(error));
return false;
}
}
public async login(callback: SnsOneLoginCallback): Promise<void> {
this.SnsOneLoginCallback = callback;
if (!this.iQQOpenApi) {
this.handleLoginError('QQOpenApi not initialized');
return;
}
try {
const result: AuthResult = await this.iQQOpenApi.login({
scope: "all",
useQrCode: false,
networkTimeout: 0,
forceWebLogin: false
});
this.handleAuthResult(result);
} catch (error) {
this.handleLoginError(error);
}
}
public loginWithCallback(callback: SnsOneLoginCallback): void {
this.SnsOneLoginCallback = callback;
if (!this.iQQOpenApi) {
this.handleLoginError('QQOpenApi not initialized');
return;
}
const loginApiCallback: ApiCallback<AuthResponse> = {
onComplete: (response: AuthResponse): void => {
DebugLog.d(`onComplete response: ${JSON.stringify(response)}`);
if (response.ret == 0) {
this.onAuthSuccess(response);
} else {
this.handleLoginError(`Auth failed with ret: ${response.ret}`);
}
},
onError: (msg: string | null): void => {
this.handleLoginError(`onError: ${msg}`);
},
onCancel: (msg: string | null): void => {
this.handleLoginError('Login canceled by user');
}
};
try {
this.iQQOpenApi.login({
scope: "all",
useQrCode: false,
networkTimeout: 0,
forceWebLogin: false
}, loginApiCallback);
} catch (error) {
this.handleLoginError(error);
}
}
private handleAuthResult(result: AuthResult): void {
switch (result.type) {
case AuthResultType.Success:
if (result.authResponse) {
this.onAuthSuccess(result.authResponse);
} else {
this.handleLoginError( 'Auth response is null');
}
break;
case AuthResultType.Cancel:
this.handleLoginError('Login canceled by user');
break;
case AuthResultType.Error:
this.handleLoginError(result.message ?? 'Unknown error');
break;
default:
this.handleLoginError('Unknown auth result type');
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/managers/sns/qq/QQLoginManager.ets#L43-L164
|
ff8e022bdf61fd7afb1f500a0af1ceef09e9b466
|
github
|
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/videotrimmer/src/main/ets/videotrimmer/RangeSeekBarView.ets
|
arkts
|
clearUndefined
|
判断位置坐标值
|
clearUndefined(num: number | undefined) {
if (num == undefined) {
return 0;
}
return num;
}
|
AST#method_declaration#Left clearUndefined AST#parameter_list#Left ( AST#parameter#Left num : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left num AST#expression#Right == AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left 0 AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left num AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
clearUndefined(num: number | undefined) {
if (num == undefined) {
return 0;
}
return num;
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/videotrimmer/src/main/ets/videotrimmer/RangeSeekBarView.ets#L474-L479
|
23b8bd0787392b8b46d00205bdcf7a7f5b616a83
|
gitee
|
yongoe1024/RdbPlus.git
|
4a3fc04ba5903bc1c1b194efbc557017976909dc
|
rdbplus/src/main/ets/core/MyWrapper.ets
|
arkts
|
getWhere
|
获取where后的条件
|
getWhere(): string {
let sql = '1=1 ' + this.whereList.join(" ")
return sql
}
|
AST#method_declaration#Left getWhere 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 sql = 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 '1=1 ' AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . whereList AST#member_expression#Right AST#expression#Right . join AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left " " AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left sql AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
getWhere(): string {
let sql = '1=1 ' + this.whereList.join(" ")
return sql
}
|
https://github.com/yongoe1024/RdbPlus.git/blob/4a3fc04ba5903bc1c1b194efbc557017976909dc/rdbplus/src/main/ets/core/MyWrapper.ets#L33-L36
|
6901da74ad5bb6e471b8a075179b1b2c69336c96
|
github
|
Joker-x-dev/HarmonyKit.git
|
f97197ce157df7f303244fba42e34918306dfb08
|
feature/demo/src/main/ets/view/LocalStoragePage.ets
|
arkts
|
构建本地存储示例页
@returns {void} 无返回值
|
build() {
AppNavDestination({
title: $r("app.string.demo_local_storage_title"),
viewModel: this.vm
}) {
this.LocalStorageContent();
}
}
|
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#resource_expression#Left $r ( AST#expression#Left "app.string.demo_local_storage_title" AST#expression#Right ) AST#resource_expression#Right 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 . LocalStorageContent 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: $r("app.string.demo_local_storage_title"),
viewModel: this.vm
}) {
this.LocalStorageContent();
}
}
|
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/feature/demo/src/main/ets/view/LocalStoragePage.ets#L24-L31
|
9392546dbda53b0be744823b6305cf411b2ca47a
|
github
|
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Media/ImageEdit/entry/src/main/ets/utils/CropUtil.ets
|
arkts
|
Crop 4:3.
@param pixelMap.
@param width.
@param height.
|
export async function banner(pixelMap: PixelMap, width: number, height: number) {
if (width <= height) {
const cropWidth = width;
const cropHeight = Math.floor(width * CommonConstants.CROP_RATE_4_3);
const cropPosition: RegionItem = {
x: 0,
y: Math.floor((height - cropHeight) / CommonConstants.AVERAGE_WEIGHT_WIDTH)
};
cropCommon(pixelMap, cropWidth, cropHeight, cropPosition);
return;
}
if (width * CommonConstants.CROP_RATE_4_3 >= height) {
const cropWidth = Math.floor(height / CommonConstants.CROP_RATE_4_3);
const cropHeight = height;
const cropPosition: RegionItem = {
x: Math.floor((width - cropWidth) / CommonConstants.AVERAGE_WEIGHT_WIDTH),
y: 0
};
cropCommon(pixelMap, cropWidth, cropHeight, cropPosition);
return;
}
const cropWidth = width;
const cropHeight = Math.floor(width * CommonConstants.CROP_RATE_4_3);
const cropPosition: RegionItem = {
x: 0,
y: Math.floor((height - cropHeight) / CommonConstants.AVERAGE_WEIGHT_WIDTH)
}
cropCommon(pixelMap, cropWidth, cropHeight, cropPosition);
}
|
AST#export_declaration#Left export AST#function_declaration#Left async function banner AST#parameter_list#Left ( AST#parameter#Left pixelMap : AST#type_annotation#Left AST#primary_type#Left PixelMap AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left width : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left height : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left width AST#expression#Right <= AST#expression#Left height 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 cropWidth = AST#expression#Left width 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 cropHeight = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left width AST#expression#Right * AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . CROP_RATE_4_3 AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left cropPosition : AST#type_annotation#Left AST#primary_type#Left RegionItem AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left height AST#expression#Right - AST#expression#Left cropHeight AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . AVERAGE_WEIGHT_WIDTH AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left cropCommon AST#expression#Right AST#argument_list#Left ( AST#expression#Left pixelMap AST#expression#Right , AST#expression#Left cropWidth AST#expression#Right , AST#expression#Left cropHeight AST#expression#Right , AST#expression#Left cropPosition AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left width AST#expression#Right * AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . CROP_RATE_4_3 AST#member_expression#Right AST#expression#Right >= AST#expression#Left height 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 cropWidth = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left height AST#expression#Right / AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . CROP_RATE_4_3 AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left cropHeight = AST#expression#Left height 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 cropPosition : AST#type_annotation#Left AST#primary_type#Left RegionItem AST#primary_type#Right AST#type_annotation#Right = 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 AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left width AST#expression#Right - AST#expression#Left cropWidth AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . AVERAGE_WEIGHT_WIDTH AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left cropCommon AST#expression#Right AST#argument_list#Left ( AST#expression#Left pixelMap AST#expression#Right , AST#expression#Left cropWidth AST#expression#Right , AST#expression#Left cropHeight AST#expression#Right , AST#expression#Left cropPosition AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left cropWidth = AST#expression#Left width 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 cropHeight = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left width AST#expression#Right * AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . CROP_RATE_4_3 AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left cropPosition : AST#type_annotation#Left AST#primary_type#Left RegionItem AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left height AST#expression#Right - AST#expression#Left cropHeight AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . AVERAGE_WEIGHT_WIDTH AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#ERROR#Left cropCommon AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left pixelMap AST#expression#Right , AST#expression#Left cropWidth AST#expression#Right , AST#expression#Left cropHeight AST#expression#Right , AST#expression#Left cropPosition AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export async function banner(pixelMap: PixelMap, width: number, height: number) {
if (width <= height) {
const cropWidth = width;
const cropHeight = Math.floor(width * CommonConstants.CROP_RATE_4_3);
const cropPosition: RegionItem = {
x: 0,
y: Math.floor((height - cropHeight) / CommonConstants.AVERAGE_WEIGHT_WIDTH)
};
cropCommon(pixelMap, cropWidth, cropHeight, cropPosition);
return;
}
if (width * CommonConstants.CROP_RATE_4_3 >= height) {
const cropWidth = Math.floor(height / CommonConstants.CROP_RATE_4_3);
const cropHeight = height;
const cropPosition: RegionItem = {
x: Math.floor((width - cropWidth) / CommonConstants.AVERAGE_WEIGHT_WIDTH),
y: 0
};
cropCommon(pixelMap, cropWidth, cropHeight, cropPosition);
return;
}
const cropWidth = width;
const cropHeight = Math.floor(width * CommonConstants.CROP_RATE_4_3);
const cropPosition: RegionItem = {
x: 0,
y: Math.floor((height - cropHeight) / CommonConstants.AVERAGE_WEIGHT_WIDTH)
}
cropCommon(pixelMap, cropWidth, cropHeight, cropPosition);
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Media/ImageEdit/entry/src/main/ets/utils/CropUtil.ets#L74-L103
|
9ee1b0db25a5190a66bfa5e91a0539c99eaa25ff
|
gitee
|
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/crypto/DES.ets
|
arkts
|
decryptECB
|
解密(ECB模式),异步
@param data 加密或者解密的数据。data不能为null。
@param symKey 指定加密或解密的密钥。
@param params 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。
@param transformation 待生成Cipher的算法名称(含密钥长度)、加密模式以及填充方法的组合(3DES192|ECB|PKCS7、3DES192|CBC|PKCS7、等)。
@returns
|
static async decryptECB(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey,
transformation: string = '3DES192|ECB|PKCS7'): Promise<cryptoFramework.DataBlob> {
return DES.decrypt(data, symKey, null, transformation);
}
|
AST#method_declaration#Left static async decryptECB AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left symKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . SymKey AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left transformation : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '3DES192|ECB|PKCS7' 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DES AST#expression#Right . decrypt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right , AST#expression#Left symKey AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right , AST#expression#Left transformation AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static async decryptECB(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey,
transformation: string = '3DES192|ECB|PKCS7'): Promise<cryptoFramework.DataBlob> {
return DES.decrypt(data, symKey, null, transformation);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/crypto/DES.ets#L61-L64
|
955f450c6f42bbed896a06aa3f8dd65e2ac05ba3
|
gitee
|
PureHarmonyProject/ScanKit_SampleCode_Clientdemo_ArkTS.git
|
3b5fa45c650dcae2773a19f122161935e0c0e2bc
|
entry/src/main/ets/pages/customScan/pages/ScanPage.ets
|
arkts
|
GlobalThisUtil
|
Not access the gallery for code recognition.
|
GlobalThisUtil.setProperty(CommonConstants.GLOBAL_SCAN_IS_DECODING_GALLERY, false);
|
AST#method_declaration#Left GlobalThisUtil AST#ERROR#Left . set Prop erty AST#ERROR#Right AST#parameter_list#Left ( AST#parameter#Left CommonConstants AST#parameter#Right AST#ERROR#Left . GLOBAL_SCAN_IS_DECODING_GALLERY AST#ERROR#Right , AST#parameter#Left false AST#parameter#Right ) AST#parameter_list#Right ; AST#method_declaration#Right
|
GlobalThisUtil.setProperty(CommonConstants.GLOBAL_SCAN_IS_DECODING_GALLERY, false);
|
https://github.com/PureHarmonyProject/ScanKit_SampleCode_Clientdemo_ArkTS.git/blob/3b5fa45c650dcae2773a19f122161935e0c0e2bc/entry/src/main/ets/pages/customScan/pages/ScanPage.ets#L125-L125
|
cc7f6c0fb94c22fe0913660606d2b3a75b034679
|
github
|
openharmony/update_update_app
|
0157b7917e2f48e914b5585991e8b2f4bc25108a
|
feature/ota/src/main/ets/notify/NotificationHelper.ets
|
arkts
|
showUpgradeSuccess
|
弹安装成功通知
@param context 实上下文
|
async showUpgradeSuccess(versionName: string, context: common.Context): Promise<void> {
let request = {
content: {
contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: await context.resourceManager.getString($r('app.string.install_success_message').id),
text: versionName
}
},
wantAgent: await wantAgent.getWantAgent(this.checkWantAgentInfo),
id: 4,
slotType: notification.SlotType.SERVICE_INFORMATION
}
await notification.publish(request).then(() => {
this.logInfo('showUpgradeSuccess publish promise success.');
}).catch((err) => {
this.logError('showUpgradeSuccess publish promise failed because ' + JSON.stringify(err));
});
}
|
AST#method_declaration#Left async showUpgradeSuccess AST#parameter_list#Left ( AST#parameter#Left versionName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , 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 AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left request = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left content AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left contentType AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left notification AST#expression#Right . ContentType AST#member_expression#Right AST#expression#Right . NOTIFICATION_CONTENT_BASIC_TEXT AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left normal AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left context AST#expression#Right AST#await_expression#Right AST#expression#Right . resourceManager AST#member_expression#Right AST#expression#Right . getString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.install_success_message' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left text AST#property_name#Right : AST#expression#Left versionName 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#property_assignment#Left AST#property_name#Left wantAgent AST#property_name#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 wantAgent AST#expression#Right AST#await_expression#Right AST#expression#Right . getWantAgent 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 . checkWantAgentInfo AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left id AST#property_name#Right : AST#expression#Left 4 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left slotType AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left notification AST#expression#Right . SlotType AST#member_expression#Right AST#expression#Right . SERVICE_INFORMATION AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 notification AST#expression#Right AST#await_expression#Right AST#expression#Right . publish AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left request AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . 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 this AST#expression#Right . logInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'showUpgradeSuccess publish promise success.' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . logError 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 'showUpgradeSuccess publish promise failed because ' 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#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
|
async showUpgradeSuccess(versionName: string, context: common.Context): Promise<void> {
let request = {
content: {
contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: await context.resourceManager.getString($r('app.string.install_success_message').id),
text: versionName
}
},
wantAgent: await wantAgent.getWantAgent(this.checkWantAgentInfo),
id: 4,
slotType: notification.SlotType.SERVICE_INFORMATION
}
await notification.publish(request).then(() => {
this.logInfo('showUpgradeSuccess publish promise success.');
}).catch((err) => {
this.logError('showUpgradeSuccess publish promise failed because ' + JSON.stringify(err));
});
}
|
https://github.com/openharmony/update_update_app/blob/0157b7917e2f48e914b5585991e8b2f4bc25108a/feature/ota/src/main/ets/notify/NotificationHelper.ets#L179-L197
|
e4eed96c5ff6b85d6c5e3a328d03a0ca05b7b8d5
|
gitee
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/SystemFeature/DeviceUsageStatistics/DeviceUsageStatistics/entry/src/main/ets/model/HmsTime.ets
|
arkts
|
Copyright (c) 2022 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
export default class HmsTime {
hour: number
minute: number
second: number
constructor
|
AST#export_declaration#Left export AST#ERROR#Left default class HmsTime { hour AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right AST#ERROR#Left m in ute AST#ERROR#Right : number second : number AST#ERROR#Right AST#variable_declaration#Left const AST#variable_declarator#Left ructor AST#variable_declarator#Right AST#variable_declaration#Right AST#export_declaration#Right
|
export default class HmsTime {
hour: number
minute: number
second: number
constructor
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/DeviceUsageStatistics/DeviceUsageStatistics/entry/src/main/ets/model/HmsTime.ets#L16-L21
|
2a42278b7fb925f56ac2ab8c29f8ff54035fff1b
|
gitee
|
|
softfatgay/harmony-netease.git
|
5f3d226b72ba8579cacfbd229e4eb0054d63abef
|
entry/src/main/ets/base/Api.ets
|
arkts
|
/热销榜名单
|
export const SUBMIT_ORDER_INFO = baseUrl + '/xhr/item/getSubmitOrderInfo.json';
|
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left SUBMIT_ORDER_INFO = AST#expression#Left AST#binary_expression#Left AST#expression#Left baseUrl AST#expression#Right + AST#expression#Left '/xhr/item/getSubmitOrderInfo.json' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
|
export const SUBMIT_ORDER_INFO = baseUrl + '/xhr/item/getSubmitOrderInfo.json';
|
https://github.com/softfatgay/harmony-netease.git/blob/5f3d226b72ba8579cacfbd229e4eb0054d63abef/entry/src/main/ets/base/Api.ets#L28-L28
|
2aa607301b25475da583553826a3d7b1f4925301
|
github
|
|
openharmony-sig/knowledge_demo_smart_home
|
6cdf5d81ef84217f386c4200bfc4124a0ded5a0d
|
FA/DistScheduleEts/entry/src/main/ets/default/app.ets
|
arkts
|
Copyright (c) 2022 Huawei Device Co., Ltd.
Licensed under the Apache License,Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
export default {
onCreate() {
console.info('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
}
|
AST#export_declaration#Left export default AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left onCreate AST#property_name#Right AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Application 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#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left onDestroy AST#property_name#Right AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Application onDestroy' 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 AST#export_declaration#Right
|
export default {
onCreate() {
console.info('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
}
|
https://github.com/openharmony-sig/knowledge_demo_smart_home/blob/6cdf5d81ef84217f386c4200bfc4124a0ded5a0d/FA/DistScheduleEts/entry/src/main/ets/default/app.ets#L15-L22
|
07a45a3c1cfd6a3eecea77fde68ab89bfc08cab8
|
gitee
|
|
openharmony/update_update_app
|
0157b7917e2f48e914b5585991e8b2f4bc25108a
|
feature/ota/src/main/ets/OtaPage.ets
|
arkts
|
getNewVersionPageInfo
|
取新版本数据
@param versionComponents 升级包
@param componentDescriptions 更新日志
@return Promise<VersionPageInfo> 具体的新版本数据
|
public async getNewVersionPageInfo(versionComponents: Array<update.VersionComponent>,
componentDescriptions?: Array<update.ComponentDescription>): Promise<VersionPageInfo> {
let component: update.VersionComponent = versionComponents.filter((component: update.VersionComponent) => {
return component.componentType == update.ComponentType.OTA;
})?.[0];
let componentId: string = component?.componentId;
let description: string = '';
if (componentDescriptions) {
description = UpdateUtils.obtainDescription(componentDescriptions, componentId);
}
let isABInstall = await VersionUtils.isABInstall();
const countDownTimes = 20;
return {
version: component.displayVersion,
size: component.size,
effectiveMode: component.effectiveMode,
otaMode:component.otaMode,
changelog: {
version: component.displayVersion,
size: FormatUtils.formatFileSize(component.size),
displayType: ChangelogType.PICTURE_AND_TEXT,
content: description
},
countDownDialogInfo: {
dialogText: isABInstall ?
$r('app.string.count_down_message_ab', component.displayVersion, countDownTimes) :
$r('app.string.count_down_message_recovery', component.displayVersion, countDownTimes),
dialogType: isABInstall ? CountDownDialogType.OTA_AB : CountDownDialogType.OTA
}
};
}
|
AST#method_declaration#Left public async getNewVersionPageInfo AST#parameter_list#Left ( AST#parameter#Left versionComponents : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left update . VersionComponent AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left componentDescriptions ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left update . ComponentDescription AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left VersionPageInfo 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 component : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left update . VersionComponent AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left versionComponents AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left component : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left update . VersionComponent AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left component AST#expression#Right . componentType AST#member_expression#Right AST#expression#Right == AST#expression#Left update AST#expression#Right AST#binary_expression#Right AST#expression#Right . ComponentType AST#member_expression#Right AST#expression#Right . OTA AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ?. [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left componentId : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left component AST#expression#Right ?. componentId AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left description : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left componentDescriptions AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left description = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left UpdateUtils AST#expression#Right . obtainDescription AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left componentDescriptions AST#expression#Right , AST#expression#Left componentId AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left isABInstall = 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 VersionUtils AST#expression#Right AST#await_expression#Right AST#expression#Right . isABInstall 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 countDownTimes = AST#expression#Left 20 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left version AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left component AST#expression#Right . displayVersion AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left size AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left component AST#expression#Right . size AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left effectiveMode AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left component AST#expression#Right . effectiveMode AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left otaMode AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left component AST#expression#Right . otaMode AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left changelog AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left version AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left component AST#expression#Right . displayVersion AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left size AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FormatUtils AST#expression#Right . formatFileSize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left component AST#expression#Right . size AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left displayType AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left ChangelogType AST#expression#Right . PICTURE_AND_TEXT AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left content AST#property_name#Right : AST#expression#Left description 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 countDownDialogInfo AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left dialogText AST#property_name#Right : AST#expression#Left AST#conditional_expression#Left AST#expression#Left isABInstall AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.count_down_message_ab' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left component AST#expression#Right . displayVersion AST#member_expression#Right AST#expression#Right , AST#expression#Left countDownTimes AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.count_down_message_recovery' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left component AST#expression#Right . displayVersion AST#member_expression#Right AST#expression#Right , AST#expression#Left countDownTimes AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left dialogType AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left isABInstall AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left CountDownDialogType AST#expression#Right . OTA_AB AST#member_expression#Right AST#expression#Right : AST#expression#Left CountDownDialogType AST#expression#Right AST#conditional_expression#Right AST#expression#Right . OTA 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public async getNewVersionPageInfo(versionComponents: Array<update.VersionComponent>,
componentDescriptions?: Array<update.ComponentDescription>): Promise<VersionPageInfo> {
let component: update.VersionComponent = versionComponents.filter((component: update.VersionComponent) => {
return component.componentType == update.ComponentType.OTA;
})?.[0];
let componentId: string = component?.componentId;
let description: string = '';
if (componentDescriptions) {
description = UpdateUtils.obtainDescription(componentDescriptions, componentId);
}
let isABInstall = await VersionUtils.isABInstall();
const countDownTimes = 20;
return {
version: component.displayVersion,
size: component.size,
effectiveMode: component.effectiveMode,
otaMode:component.otaMode,
changelog: {
version: component.displayVersion,
size: FormatUtils.formatFileSize(component.size),
displayType: ChangelogType.PICTURE_AND_TEXT,
content: description
},
countDownDialogInfo: {
dialogText: isABInstall ?
$r('app.string.count_down_message_ab', component.displayVersion, countDownTimes) :
$r('app.string.count_down_message_recovery', component.displayVersion, countDownTimes),
dialogType: isABInstall ? CountDownDialogType.OTA_AB : CountDownDialogType.OTA
}
};
}
|
https://github.com/openharmony/update_update_app/blob/0157b7917e2f48e914b5585991e8b2f4bc25108a/feature/ota/src/main/ets/OtaPage.ets#L36-L67
|
95e66267cb2ede7db647726d537a4998eb64494c
|
gitee
|
MUYS/imagePreview
|
96212a51e8c5d6c37b9b9fb94e7d6d76047cdeb0
|
library/src/main/ets/image_preview/ImagePreviewViewModel.ets
|
arkts
|
日期:2025/6/7
|
export class ImagePreviewViewModel {
private readonly state: ImagePreviewState
constructor
|
AST#export_declaration#Left export AST#ERROR#Left class ImagePreviewViewModel { private readonly state : ImagePreviewState AST#ERROR#Right AST#variable_declaration#Left const AST#variable_declarator#Left ructor AST#variable_declarator#Right AST#variable_declaration#Right AST#export_declaration#Right
|
export class ImagePreviewViewModel {
private readonly state: ImagePreviewState
constructor
|
https://github.com/MUYS/imagePreview/blob/96212a51e8c5d6c37b9b9fb94e7d6d76047cdeb0/library/src/main/ets/image_preview/ImagePreviewViewModel.ets#L8-L11
|
eadaf91745883e3539fb6b308b7f5c7107fb2211
|
gitee
|
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/functionalscenes/src/main/ets/model/WaterFlowDataSource.ets
|
arkts
|
notifyDataAdd
|
通知控制器数据增加
@param index 数组索引
|
notifyDataAdd(index: number): void {
this.listeners.forEach(listener => {
listener.onDataAdd(index);
})
}
|
AST#method_declaration#Left notifyDataAdd AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . listeners AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left listener => 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 listener AST#expression#Right . onDataAdd AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
notifyDataAdd(index: number): void {
this.listeners.forEach(listener => {
listener.onDataAdd(index);
})
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/functionalscenes/src/main/ets/model/WaterFlowDataSource.ets#L53-L57
|
ca959ee2d2ee381386490d708b35221444d738e3
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
harmonyos/src/main/ets/common/utils/DateUtils.ets
|
arkts
|
parseDate
|
解析日期字符串
@param dateString 日期字符串
@returns Date对象,如果解析失败返回null
|
static parseDate(dateString: string): Date | null {
if (!dateString || dateString.trim() === '') {
return null;
}
const date = new Date(dateString);
if (isNaN(date.getTime())) {
return null;
}
return date;
}
|
AST#method_declaration#Left static parseDate AST#parameter_list#Left ( AST#parameter#Left dateString : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#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#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#binary_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left dateString AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left dateString AST#expression#Right AST#binary_expression#Right AST#expression#Right . trim AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right === AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const 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 dateString AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left isNaN AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . 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#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left date AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static parseDate(dateString: string): Date | null {
if (!dateString || dateString.trim() === '') {
return null;
}
const date = new Date(dateString);
if (isNaN(date.getTime())) {
return null;
}
return date;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/common/utils/DateUtils.ets#L80-L91
|
25934e47a1a7f9c3f9e823886fb72e1bcbfd0742
|
github
|
Nuist666/Alzheimer.git
|
c171b8e739357bfc5a3fc71c90aaea6ce5d463d1
|
entry/src/main/ets/view/VideoPlayer.ets
|
arkts
|
VideoPlayer
|
video controller component
|
@Component
export struct VideoPlayer {
private source: string | Resource = '';
private controller: VideoController = new VideoController();
private previewUris: Resource = $r('app.media.preview');
@Provide currentTime: number = 0;
@Provide durationTime: number = 0;
@Provide durationStringTime: string = START_TIME;
@Provide currentStringTime: string = START_TIME;
@Consume isPlay: boolean;
@Consume isOpacity: boolean;
@Consume flag: boolean;
@Consume isLoading: boolean;
@Consume progressVal: number;
build() {
Column() {
Video({
src: this.source,
previewUri: this.previewUris,
controller: this.controller
})
.width(ALL_PERCENT)
.height(STRING_PERCENT.NINETY_PERCENT)
.controls(false)
.autoPlay(false)
.objectFit(ImageFit.Contain)
.loop(false)
.onUpdate((event) => {
if (event) {
this.currentTime = event.time;
this.currentStringTime = changeSliderTime(this.currentTime);
}
})
.onPrepared((event) => {
this.prepared(event?.duration);
})
.onFinish(() => {
this.finish();
})
.onError(() => {
prompt.showToast({
duration: COMMON_NUM_DURATION,
message: MESSAGE
});
})
VideoSlider({ controller: this.controller })
}
}
/**
* video component prepared callback
*/
prepared(duration: number) {
this.durationTime = duration;
let second: number = duration % COMMON_NUM_MINUTE;
let min: number = Number.parseInt((duration / COMMON_NUM_MINUTE).toString());
let head = min < COMMON_NUM_DOUBLE ? `${ZERO_STR}${min}` : min;
let end = second < COMMON_NUM_DOUBLE ? `${ZERO_STR}${second}` : second;
this.durationStringTime = `${head}${SPLIT}${end}`;
this.flag = true;
}
/**
* video component finish callback
*/
finish() {
this.isPlay = false;
this.isOpacity = false;
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct VideoPlayer AST#component_body#Left { AST#property_declaration#Left private source : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Resource AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private controller : AST#type_annotation#Left AST#primary_type#Left VideoController 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 VideoController AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private previewUris : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.preview' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Provide AST#decorator#Right currentTime : 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 @ Provide AST#decorator#Right durationTime : 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 @ Provide AST#decorator#Right durationStringTime : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left START_TIME AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Provide AST#decorator#Right currentStringTime : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left START_TIME AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Consume AST#decorator#Right isPlay : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Consume AST#decorator#Right isOpacity : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Consume AST#decorator#Right flag : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Consume AST#decorator#Right isLoading : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Consume AST#decorator#Right progressVal : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Video ( AST#component_parameters#Left { AST#component_parameter#Left src : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . source AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left previewUri : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . previewUris AST#member_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_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left ALL_PERCENT AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left STRING_PERCENT AST#expression#Right . NINETY_PERCENT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . controls ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . autoPlay ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#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 . loop ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onUpdate ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left event AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left event AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentTime AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left event AST#expression#Right . time AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentStringTime AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left changeSliderTime AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentTime AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onPrepared ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left event AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . prepared AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left event AST#expression#Right ?. duration AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onFinish ( 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 . finish 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 . onError ( 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 prompt AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left COMMON_NUM_DURATION 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#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 VideoSlider ( AST#component_parameters#Left { 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_parameters#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right /**
* video component prepared callback
*/ AST#method_declaration#Left prepared AST#parameter_list#Left ( AST#parameter#Left duration : 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 . durationTime AST#member_expression#Right = AST#expression#Left duration 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 second : 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 duration AST#expression#Right % AST#expression#Left COMMON_NUM_MINUTE AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left min : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Number AST#expression#Right . parseInt 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#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left duration AST#expression#Right / AST#expression#Left COMMON_NUM_MINUTE AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#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 head = AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left min AST#expression#Right < AST#expression#Left COMMON_NUM_DOUBLE AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left ZERO_STR AST#expression#Right } AST#template_substitution#Right AST#template_substitution#Left $ { AST#expression#Left min AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right : AST#expression#Left min 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 let AST#variable_declarator#Left end = AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left second AST#expression#Right < AST#expression#Left COMMON_NUM_DOUBLE AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left ZERO_STR AST#expression#Right } AST#template_substitution#Right AST#template_substitution#Left $ { AST#expression#Left second AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right : AST#expression#Left second 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . durationStringTime AST#member_expression#Right = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left head AST#expression#Right } AST#template_substitution#Right AST#template_substitution#Left $ { AST#expression#Left SPLIT AST#expression#Right } AST#template_substitution#Right AST#template_substitution#Left $ { AST#expression#Left end AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . flag AST#member_expression#Right = AST#expression#Left 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#method_declaration#Right /**
* video component finish callback
*/ AST#method_declaration#Left finish 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 . isPlay AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isOpacity AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct VideoPlayer {
private source: string | Resource = '';
private controller: VideoController = new VideoController();
private previewUris: Resource = $r('app.media.preview');
@Provide currentTime: number = 0;
@Provide durationTime: number = 0;
@Provide durationStringTime: string = START_TIME;
@Provide currentStringTime: string = START_TIME;
@Consume isPlay: boolean;
@Consume isOpacity: boolean;
@Consume flag: boolean;
@Consume isLoading: boolean;
@Consume progressVal: number;
build() {
Column() {
Video({
src: this.source,
previewUri: this.previewUris,
controller: this.controller
})
.width(ALL_PERCENT)
.height(STRING_PERCENT.NINETY_PERCENT)
.controls(false)
.autoPlay(false)
.objectFit(ImageFit.Contain)
.loop(false)
.onUpdate((event) => {
if (event) {
this.currentTime = event.time;
this.currentStringTime = changeSliderTime(this.currentTime);
}
})
.onPrepared((event) => {
this.prepared(event?.duration);
})
.onFinish(() => {
this.finish();
})
.onError(() => {
prompt.showToast({
duration: COMMON_NUM_DURATION,
message: MESSAGE
});
})
VideoSlider({ controller: this.controller })
}
}
prepared(duration: number) {
this.durationTime = duration;
let second: number = duration % COMMON_NUM_MINUTE;
let min: number = Number.parseInt((duration / COMMON_NUM_MINUTE).toString());
let head = min < COMMON_NUM_DOUBLE ? `${ZERO_STR}${min}` : min;
let end = second < COMMON_NUM_DOUBLE ? `${ZERO_STR}${second}` : second;
this.durationStringTime = `${head}${SPLIT}${end}`;
this.flag = true;
}
finish() {
this.isPlay = false;
this.isOpacity = false;
}
}
|
https://github.com/Nuist666/Alzheimer.git/blob/c171b8e739357bfc5a3fc71c90aaea6ce5d463d1/entry/src/main/ets/view/VideoPlayer.ets#L21-L91
|
60ea4698fe12197dc3863f65d4af92e106375acc
|
github
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/RSA2048.ets
|
arkts
|
importRSA2048
|
3.明文导入密钥
|
function importRSA2048() {
try {
huks.importKeyItem(keyAlias, options, (error, data) => {
if (error) {
console.error(`callback: importKeyItem failed` + error);
} else {
console.info(`callback: importKeyItem success`);
}
});
} catch (error) {
console.error(`callback: importKeyItem input arg invalid` + error);
throw (error as Error);
}
}
|
AST#function_declaration#Left function importRSA2048 AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left huks AST#expression#Right . importKeyItem AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left keyAlias AST#expression#Right , AST#expression#Left options AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error AST#parameter#Right , AST#parameter#Left data AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left error AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#template_literal#Left ` callback: importKeyItem failed ` AST#template_literal#Right AST#expression#Right + AST#expression#Left error AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` callback: importKeyItem success ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#template_literal#Left ` callback: importKeyItem input arg invalid ` AST#template_literal#Right AST#expression#Right + AST#expression#Left error AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#throw_statement#Left throw AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ; AST#throw_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
|
function importRSA2048() {
try {
huks.importKeyItem(keyAlias, options, (error, data) => {
if (error) {
console.error(`callback: importKeyItem failed` + error);
} else {
console.info(`callback: importKeyItem success`);
}
});
} catch (error) {
console.error(`callback: importKeyItem input arg invalid` + error);
throw (error as Error);
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/RSA2048.ets#L95-L108
|
f78ea0498f56bc701c679cf8fe6bdf28080a2135
|
gitee
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/NumberUtil.ets
|
arkts
|
isNaN
|
检查值是否为NaN
@param value
@returns
|
static isNaN(value: Any): boolean {
return Number.isNaN(value);
}
|
AST#method_declaration#Left static isNaN AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left Any 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 Number AST#expression#Right . isNaN 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 isNaN(value: Any): boolean {
return Number.isNaN(value);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/NumberUtil.ets#L35-L37
|
7ed23459679ea014fe3598f2028afc99d04dbb87
|
gitee
|
Joker-x-dev/CoolMallArkTS.git
|
9f3fabf89fb277692cb82daf734c220c7282919c
|
core/data/src/main/ets/repository/SearchHistoryRepository.ets
|
arkts
|
@file 搜索历史本地仓库,封装数据库数据源并提供业务方法。
@author Joker.X
|
export class SearchHistoryRepository {
/**
* 本地数据源实例
*/
private dataSource: SearchHistoryLocalDataSource;
/**
* 构造函数
* @param {SearchHistoryLocalDataSource} dataSource 可选的数据源实例
*/
constructor(dataSource: SearchHistoryLocalDataSource = new SearchHistoryLocalDataSourceImpl()) {
this.dataSource = dataSource;
}
/**
* 添加搜索历史记录
* @param {string} keyword 搜索关键词
* @returns {Promise<void>} Promise<void>
* @example
* const repo: SearchHistoryRepository = new SearchHistoryRepository();
* await repo.addSearchHistory("手机");
*/
async addSearchHistory(keyword: string): Promise<void> {
const trimmed: string = keyword.trim();
if (!trimmed) {
return;
}
const history: SearchHistory = new SearchHistory();
history.keyword = trimmed;
history.searchTime = Date.now();
return this.dataSource.addSearchHistory(history);
}
/**
* 根据关键词删除搜索历史记录
* @param {string} keyword 搜索关键词
* @returns {Promise<void>} Promise<void>
*/
removeSearchHistory(keyword: string): Promise<void> {
return this.dataSource.removeSearchHistory(keyword);
}
/**
* 清空所有搜索历史记录
* @returns {Promise<void>} Promise<void>
*/
clearAllSearchHistory(): Promise<void> {
return this.dataSource.clearAllSearchHistory();
}
/**
* 获取所有搜索历史记录,按搜索时间倒序
* @returns {Promise<SearchHistory[]>} 搜索历史列表
*/
getAllSearchHistory(): Promise<SearchHistory[]> {
return this.dataSource.getAllSearchHistory();
}
/**
* 获取搜索历史记录数量
* @returns {Promise<number>} 搜索历史数量
*/
getSearchHistoryCount(): Promise<number> {
return this.dataSource.getSearchHistoryCount();
}
/**
* 获取指定数量的最新搜索历史记录
* @param {number} limit 限制数量
* @returns {Promise<SearchHistory[]>} 搜索历史列表
*/
getRecentSearchHistory(limit: number): Promise<SearchHistory[]> {
return this.dataSource.getRecentSearchHistory(limit);
}
/**
* 根据关键词获取搜索历史记录
* @param {string} keyword 搜索关键词
* @returns {Promise<SearchHistory | undefined>} 匹配到的搜索历史
*/
getSearchHistoryByKeyword(keyword: string): Promise<SearchHistory | undefined> {
return this.dataSource.getSearchHistoryByKeyword(keyword);
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class SearchHistoryRepository AST#class_body#Left { /**
* 本地数据源实例
*/ AST#property_declaration#Left private dataSource : AST#type_annotation#Left AST#primary_type#Left SearchHistoryLocalDataSource AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* 构造函数
* @param {SearchHistoryLocalDataSource} dataSource 可选的数据源实例
*/ AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left dataSource : AST#type_annotation#Left AST#primary_type#Left SearchHistoryLocalDataSource 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 SearchHistoryLocalDataSourceImpl 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#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 . dataSource AST#member_expression#Right = AST#expression#Left dataSource AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right /**
* 添加搜索历史记录
* @param {string} keyword 搜索关键词
* @returns {Promise<void>} Promise<void>
* @example
* const repo: SearchHistoryRepository = new SearchHistoryRepository();
* await repo.addSearchHistory("手机");
*/ AST#method_declaration#Left async addSearchHistory AST#parameter_list#Left ( AST#parameter#Left keyword : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left trimmed : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left keyword 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left trimmed AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left history : AST#type_annotation#Left AST#primary_type#Left SearchHistory 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 SearchHistory AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left history AST#expression#Right . keyword AST#member_expression#Right = AST#expression#Left trimmed 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 history AST#expression#Right . searchTime AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Date AST#expression#Right . now AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#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 . dataSource AST#member_expression#Right AST#expression#Right . addSearchHistory AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left history 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 {string} keyword 搜索关键词
* @returns {Promise<void>} Promise<void>
*/ AST#method_declaration#Left removeSearchHistory AST#parameter_list#Left ( AST#parameter#Left keyword : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataSource AST#member_expression#Right AST#expression#Right . removeSearchHistory 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 清空所有搜索历史记录
* @returns {Promise<void>} Promise<void>
*/ AST#method_declaration#Left clearAllSearchHistory AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataSource AST#member_expression#Right AST#expression#Right . clearAllSearchHistory AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 获取所有搜索历史记录,按搜索时间倒序
* @returns {Promise<SearchHistory[]>} 搜索历史列表
*/ AST#method_declaration#Left getAllSearchHistory AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left SearchHistory [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#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 . dataSource AST#member_expression#Right AST#expression#Right . getAllSearchHistory AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 获取搜索历史记录数量
* @returns {Promise<number>} 搜索历史数量
*/ AST#method_declaration#Left getSearchHistoryCount AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataSource AST#member_expression#Right AST#expression#Right . getSearchHistoryCount AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 获取指定数量的最新搜索历史记录
* @param {number} limit 限制数量
* @returns {Promise<SearchHistory[]>} 搜索历史列表
*/ AST#method_declaration#Left getRecentSearchHistory AST#parameter_list#Left ( AST#parameter#Left limit : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left SearchHistory [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#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 . dataSource AST#member_expression#Right AST#expression#Right . getRecentSearchHistory AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left limit 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 {string} keyword 搜索关键词
* @returns {Promise<SearchHistory | undefined>} 匹配到的搜索历史
*/ AST#method_declaration#Left getSearchHistoryByKeyword AST#parameter_list#Left ( AST#parameter#Left keyword : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left SearchHistory AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataSource AST#member_expression#Right AST#expression#Right . getSearchHistoryByKeyword 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#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 SearchHistoryRepository {
private dataSource: SearchHistoryLocalDataSource;
constructor(dataSource: SearchHistoryLocalDataSource = new SearchHistoryLocalDataSourceImpl()) {
this.dataSource = dataSource;
}
async addSearchHistory(keyword: string): Promise<void> {
const trimmed: string = keyword.trim();
if (!trimmed) {
return;
}
const history: SearchHistory = new SearchHistory();
history.keyword = trimmed;
history.searchTime = Date.now();
return this.dataSource.addSearchHistory(history);
}
removeSearchHistory(keyword: string): Promise<void> {
return this.dataSource.removeSearchHistory(keyword);
}
clearAllSearchHistory(): Promise<void> {
return this.dataSource.clearAllSearchHistory();
}
getAllSearchHistory(): Promise<SearchHistory[]> {
return this.dataSource.getAllSearchHistory();
}
getSearchHistoryCount(): Promise<number> {
return this.dataSource.getSearchHistoryCount();
}
getRecentSearchHistory(limit: number): Promise<SearchHistory[]> {
return this.dataSource.getRecentSearchHistory(limit);
}
getSearchHistoryByKeyword(keyword: string): Promise<SearchHistory | undefined> {
return this.dataSource.getSearchHistoryByKeyword(keyword);
}
}
|
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/data/src/main/ets/repository/SearchHistoryRepository.ets#L8-L91
|
553c176b36ca16ae1d664c501f345ca289338661
|
github
|
|
openharmony/arkui_ace_engine
|
30c7d1ee12fbedf0fabece54291d75897e2ad44f
|
frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/loader/app/shopping/entry/src/main/ets/model/homeModel.ets
|
arkts
|
Copyright (c) 2023 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
export class TabTitleModel {
public id: number
public uri: string
public selectedUri: string
public title: string
constructor
|
AST#export_declaration#Left export AST#ERROR#Left class TabTitleModel { AST#property_declaration#Left public id : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#property_declaration#Left public uri : 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 public selectedUri : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#property_declaration#Right public title : string AST#ERROR#Right AST#variable_declaration#Left const AST#variable_declarator#Left ructor AST#variable_declarator#Right AST#variable_declaration#Right AST#export_declaration#Right
|
export class TabTitleModel {
public id: number
public uri: string
public selectedUri: string
public title: string
constructor
|
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/loader/app/shopping/entry/src/main/ets/model/homeModel.ets#L16-L21
|
82a321cfa2d141e1a5365cbf9ccf8ec39408b42a
|
gitee
|
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template2/PageTwo.ets
|
arkts
|
PageTwoBuilder
|
Copyright (c) 2025 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
@Builder
export function PageTwoBuilder(name: string, param: Object) {
PageTwo()
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function PageTwoBuilder AST#parameter_list#Left ( AST#parameter#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left param : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left PageTwo ( ) 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 PageTwoBuilder(name: string, param: Object) {
PageTwo()
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template2/PageTwo.ets#L15-L18
|
d5bdb94587c2cfee1ec94d0afd8e86f9fddcedef
|
gitee
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/SuperFeature/Widget/ArkTSCard/CardInteractionCase/entry/src/main/ets/widget/utils/CaseCardUtils.ets
|
arkts
|
卡片展示最大案例数
|
export class CaseCardUtils {
// 案例字符串格式化
public static formatData(data: string) {
let result: CASES[] = [];
if (data.indexOf('**下面是详细的案例列表:**') > -1) {
let casesArray: string[] = data.split('**下面是详细的案例列表:**')[1].split('####');
for (let i = 1; i <= CASES_MAX_LENGTH; i++) {
const cases: CASES = {
name: CaseCardUtils.nameFormat(casesArray[i]),
url: CaseCardUtils.urlFormat(casesArray[i]),
describe: CaseCardUtils.introduceFormat(casesArray[i]),
img: CaseCardUtils.imageFormat(casesArray[i])
}
result.push(cases);
}
}
return result;
}
// 案例图片地址格式化
public static imageFormat(casesTexts: string): string {
let casesText: string = casesTexts;
let reg1 = /<img\s+[^>]*>/i;
let reg2 = /\/base\/media\/[^.]*/;
const matches1 = casesText.match(reg1);
const matches2 = matches1?.[0].match(reg2);
casesText = matches2?.[0].replace(/\/base\/media\//, '') || '';
return casesText;
}
|
AST#export_declaration#Left export AST#class_declaration#Left class CaseCardUtils AST#class_body#Left { // 案例字符串格式化 AST#method_declaration#Left public static formatData AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left result : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left CASES [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '**下面是详细的案例列表:**' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right > AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left casesArray : 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 AST#subscript_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . split AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '**下面是详细的案例列表:**' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . split AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '####' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 1 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 CASES_MAX_LENGTH AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left cases : AST#type_annotation#Left AST#primary_type#Left CASES 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left name AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CaseCardUtils AST#expression#Right . nameFormat AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left casesArray AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CaseCardUtils AST#expression#Right . urlFormat AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left casesArray AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left describe AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CaseCardUtils AST#expression#Right . introduceFormat AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left casesArray AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left img AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CaseCardUtils AST#expression#Right . imageFormat AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left casesArray AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#ERROR#Left result AST#ERROR#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left cases 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#for_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // 案例图片地址格式化 AST#property_declaration#Left public static imageFormat AST#ERROR#Left AST#parameter_list#Left ( AST#parameter#Left casesTexts : 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#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left casesText : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left casesTexts AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right let reg1 = / AST#type_parameters#Left < AST#type_parameter#Left img AST#type_parameter#Right AST#ERROR#Left \s + [ ^ AST#ERROR#Right > AST#type_parameters#Right ] * > / i AST#ERROR#Right ; AST#property_declaration#Right AST#property_declaration#Left let AST#ERROR#Left reg 2 AST#ERROR#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#expression#Right AST#ERROR#Left / \ AST#ERROR#Right / AST#expression#Left base 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#property_declaration#Right AST#property_declaration#Left const AST#ERROR#Left matches 1 AST#ERROR#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left casesText AST#expression#Right . match AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left reg1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left const AST#ERROR#Left matches 2 AST#ERROR#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left matches1 AST#expression#Right ?. [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . match AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left reg2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left casesText = 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#subscript_expression#Left AST#expression#Left matches2 AST#expression#Right ?. [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left / \ AST#ERROR#Right / AST#expression#Left base 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 \ //, '') || ''; return cases Text AST#ERROR#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class CaseCardUtils {
public static formatData(data: string) {
let result: CASES[] = [];
if (data.indexOf('**下面是详细的案例列表:**') > -1) {
let casesArray: string[] = data.split('**下面是详细的案例列表:**')[1].split('####');
for (let i = 1; i <= CASES_MAX_LENGTH; i++) {
const cases: CASES = {
name: CaseCardUtils.nameFormat(casesArray[i]),
url: CaseCardUtils.urlFormat(casesArray[i]),
describe: CaseCardUtils.introduceFormat(casesArray[i]),
img: CaseCardUtils.imageFormat(casesArray[i])
}
result.push(cases);
}
}
return result;
}
public static imageFormat(casesTexts: string): string {
let casesText: string = casesTexts;
let reg1 = /<img\s+[^>]*>/i;
let reg2 = /\/base\/media\/[^.]*/;
const matches1 = casesText.match(reg1);
const matches2 = matches1?.[0].match(reg2);
casesText = matches2?.[0].replace(/\/base\/media\
return casesText;
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SuperFeature/Widget/ArkTSCard/CardInteractionCase/entry/src/main/ets/widget/utils/CaseCardUtils.ets#L26-L54
|
b7649ba6adf9839efe4d5ca1271fad39c07fc8d5
|
gitee
|
|
openharmony/interface_sdk-js
|
c349adc73e2ec1f61f6fca489b5af059e3ed6999
|
api/@ohos.arkui.advanced.ComposeListItem.d.ets
|
arkts
|
Declare type OperateButton
@syscap SystemCapability.ArkUI.ArkUI.Full
@since 10
Declare type OperateButton
@syscap SystemCapability.ArkUI.ArkUI.Full
@atomicservice
@since 11
Declare type OperateButton
@syscap SystemCapability.ArkUI.ArkUI.Full
@crossplatform
@atomicservice
@since 20
|
export declare class OperateButton {
/**
* The text on the button.
* @type { ?ResourceStr }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
/**
* The text on the button.
* @type { ?ResourceStr }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/
/**
* The text on the button.
* @type { ?ResourceStr }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 20
*/
text?: ResourceStr;
/**
* The accessibilityText of the button.
*
* @type { ?ResourceStr }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 18
*/
/**
* The accessibilityText of the button.
*
* @type { ?ResourceStr }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 20
*/
accessibilityText?: ResourceStr;
/**
* The accessibilityDescription of the button.
*
* @type { ?ResourceStr }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 18
*/
/**
* The accessibilityDescription of the button.
*
* @type { ?ResourceStr }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 20
*/
accessibilityDescription?: ResourceStr;
/**
* The accessibilityLevel of the button.
*
* @type { ?string }
* @default "auto"
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 18
*/
/**
* The accessibilityLevel of the button.
*
* @type { ?string }
* @default "auto"
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 20
*/
accessibilityLevel?: string;
}
|
AST#export_declaration#Left export AST#ERROR#Left declare AST#ERROR#Right AST#class_declaration#Left class OperateButton AST#class_body#Left { /**
* The text on the button.
* @type { ?ResourceStr }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/ /**
* The text on the button.
* @type { ?ResourceStr }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/ /**
* The text on the button.
* @type { ?ResourceStr }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 20
*/ AST#property_declaration#Left text ? : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* The accessibilityText of the button.
*
* @type { ?ResourceStr }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 18
*/ /**
* The accessibilityText of the button.
*
* @type { ?ResourceStr }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 20
*/ AST#property_declaration#Left accessibilityText ? : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* The accessibilityDescription of the button.
*
* @type { ?ResourceStr }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 18
*/ /**
* The accessibilityDescription of the button.
*
* @type { ?ResourceStr }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 20
*/ AST#property_declaration#Left accessibilityDescription ? : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* The accessibilityLevel of the button.
*
* @type { ?string }
* @default "auto"
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 18
*/ /**
* The accessibilityLevel of the button.
*
* @type { ?string }
* @default "auto"
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 20
*/ AST#property_declaration#Left accessibilityLevel ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export declare class OperateButton {
text?: ResourceStr;
accessibilityText?: ResourceStr;
accessibilityDescription?: ResourceStr;
accessibilityLevel?: string;
}
|
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.arkui.advanced.ComposeListItem.d.ets#L484-L566
|
61a1d587e3bb6979c66ffe6c2397b906530a24ad
|
gitee
|
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Media/ImageEdit/entry/src/main/ets/utils/MathUtils.ets
|
arkts
|
roundOutRect
|
Round out rect.
@param rect
|
static roundOutRect(rect: RectF): void {
rect.set(Math.round(rect.left), Math.round(rect.top), Math.round(rect.right), Math.round(rect.bottom));
}
|
AST#method_declaration#Left static roundOutRect AST#parameter_list#Left ( AST#parameter#Left rect : AST#type_annotation#Left AST#primary_type#Left RectF AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_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 rect AST#expression#Right . set 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 Math AST#expression#Right . round AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left rect AST#expression#Right . left AST#member_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#member_expression#Left AST#expression#Left Math AST#expression#Right . round AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left rect AST#expression#Right . top AST#member_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#member_expression#Left AST#expression#Left Math AST#expression#Right . round AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left rect AST#expression#Right . right AST#member_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#member_expression#Left AST#expression#Left Math AST#expression#Right . round AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left rect AST#expression#Right . bottom 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#builder_function_body#Right AST#method_declaration#Right
|
static roundOutRect(rect: RectF): void {
rect.set(Math.round(rect.left), Math.round(rect.top), Math.round(rect.right), Math.round(rect.bottom));
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Media/ImageEdit/entry/src/main/ets/utils/MathUtils.ets#L27-L29
|
572feb8ec80e2b4cebbcb49bd1d86e9b5d5787c2
|
gitee
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowDataSource.ets
|
arkts
|
reload
|
重新加载数据
|
public reload(): void {
this.dataArray.splice(1, 1);
this.dataArray.splice(3, 2);
this.notifyDataReload();
}
|
AST#method_declaration#Left public reload AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1 AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 3 AST#expression#Right , AST#expression#Left 2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . notifyDataReload 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
|
public reload(): void {
this.dataArray.splice(1, 1);
this.dataArray.splice(3, 2);
this.notifyDataReload();
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowDataSource.ets#L137-L141
|
5120beaacd832bfd3559313ee16a5b1a3468ff43
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/calendar/LunarSolarMappingService.ets
|
arkts
|
getLunarMonthName
|
获取农历月份名称
|
private getLunarMonthName(month: number, isLeapMonth: boolean): string {
const monthNames = ['', '正月', '二月', '三月', '四月', '五月', '六月',
'七月', '八月', '九月', '十月', '十一月', '十二月'];
const name = monthNames[month] || month.toString();
return isLeapMonth ? `闰${name}` : name;
}
|
AST#method_declaration#Left private getLunarMonthName 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#variable_declaration#Left const AST#variable_declarator#Left monthNames = 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#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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left name = 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#subscript_expression#Left AST#expression#Left monthNames AST#expression#Right [ AST#expression#Left month AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right || AST#expression#Left month AST#expression#Right AST#binary_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#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 isLeapMonth AST#expression#Right ? AST#expression#Left AST#template_literal#Left ` 闰 AST#template_substitution#Left $ { AST#expression#Left name AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right : AST#expression#Left name 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
|
private getLunarMonthName(month: number, isLeapMonth: boolean): string {
const monthNames = ['', '正月', '二月', '三月', '四月', '五月', '六月',
'七月', '八月', '九月', '十月', '十一月', '十二月'];
const name = monthNames[month] || month.toString();
return isLeapMonth ? `闰${name}` : name;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/calendar/LunarSolarMappingService.ets#L292-L297
|
0644cc01050e993c3436c769a3f8b78ba86217a2
|
github
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
UseSendable/entry/src/main/ets/pages/ConcurrencyCapabilitySelection1.ets
|
arkts
|
ConcurrencyCapabilitySelection1
|
[End taskpool]
|
@Component
export struct ConcurrencyCapabilitySelection1 {
@Styles
buttonStyles() {
.width('100%')
.height(40)
}
build() {
NavDestination() {
Column() {
Button($r('app.string.time_consuming_task_title'))
.buttonStyles()
.margin({
bottom: 16
})
.onClick(() => {
executeTaskPool();
})
}
.width('100%')
.height('100%')
.justifyContent(FlexAlign.End)
.padding({
right: 24,
bottom: 16,
left: 24
})
}
.title($r('app.string.time_consuming_task_title'))
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ConcurrencyCapabilitySelection1 AST#component_body#Left { AST#method_declaration#Left AST#decorator#Left @ Styles AST#decorator#Right buttonStyles AST#parameter_list#Left ( ) AST#parameter_list#Right AST#extend_function_body#Left { AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right } AST#extend_function_body#Right AST#method_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left NavDestination ( ) 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 Button ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.time_consuming_task_title' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . buttonStyles ( ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left executeTaskPool AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . End AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 24 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 24 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#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 . title ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.time_consuming_task_title' 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#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct ConcurrencyCapabilitySelection1 {
@Styles
buttonStyles() {
.width('100%')
.height(40)
}
build() {
NavDestination() {
Column() {
Button($r('app.string.time_consuming_task_title'))
.buttonStyles()
.margin({
bottom: 16
})
.onClick(() => {
executeTaskPool();
})
}
.width('100%')
.height('100%')
.justifyContent(FlexAlign.End)
.padding({
right: 24,
bottom: 16,
left: 24
})
}
.title($r('app.string.time_consuming_task_title'))
}
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/UseSendable/entry/src/main/ets/pages/ConcurrencyCapabilitySelection1.ets#L45-L76
|
1906e48ada51c8a2f4e33a0fecb4f520dae6c4f7
|
gitee
|
lentozi/DailyPlan.git
|
96ce0bec8f545511c51b577c4aa8327c2c5bb0c8
|
entry/src/main/ets/databaseability/DatabaseAbility.ets
|
arkts
|
insertData
|
添加数据
|
insertData(data: relationalStore.ValuesBucket, callback: Function = () => {}) {
if (!callback || typeof callback === 'undefined' || callback === undefined) {
hilog.info(0x0000, '[Debug.Rdb]', 'insertData() has no callback!');
return;
}
let resFlag: boolean = false;
const valueBucket: relationalStore.ValuesBucket = data;
hilog.info(0x0000, '[Debug.Rdb]', JSON.stringify(valueBucket));
if (this.rdbStore) {
this.rdbStore.insert(this.tableName, valueBucket, (err, ret) => {
if (err) {
hilog.info(0x0000, '[Debug.Rdb]', `insert data failed, err: ${JSON.stringify(err)}`);
callback(resFlag);
return;
}
hilog.info(0x0000, '[Debug.Rdb]', `insert data finished: ${ret}`);
callback(ret);
});
}
}
|
AST#method_declaration#Left insertData AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left relationalStore . ValuesBucket AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left callback : AST#type_annotation#Left AST#primary_type#Left Function AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right AST#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#binary_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left callback AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left callback AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left 'undefined' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left callback AST#expression#Right === AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 '[Debug.Rdb]' AST#expression#Right , AST#expression#Left 'insertData() has no callback!' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left resFlag : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left valueBucket : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left relationalStore . ValuesBucket AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left data AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 '[Debug.Rdb]' 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 valueBucket 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#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rdbStore AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rdbStore AST#member_expression#Right AST#expression#Right . insert 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 . tableName AST#member_expression#Right AST#expression#Right , AST#expression#Left valueBucket AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right , AST#parameter#Left ret 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 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 '[Debug.Rdb]' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` insert data failed, err: 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#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left callback AST#expression#Right AST#argument_list#Left ( AST#expression#Left resFlag AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left '[Debug.Rdb]' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` insert data finished: AST#template_substitution#Left $ { AST#expression#Left ret 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 callback AST#expression#Right AST#argument_list#Left ( AST#expression#Left ret 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#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
insertData(data: relationalStore.ValuesBucket, callback: Function = () => {}) {
if (!callback || typeof callback === 'undefined' || callback === undefined) {
hilog.info(0x0000, '[Debug.Rdb]', 'insertData() has no callback!');
return;
}
let resFlag: boolean = false;
const valueBucket: relationalStore.ValuesBucket = data;
hilog.info(0x0000, '[Debug.Rdb]', JSON.stringify(valueBucket));
if (this.rdbStore) {
this.rdbStore.insert(this.tableName, valueBucket, (err, ret) => {
if (err) {
hilog.info(0x0000, '[Debug.Rdb]', `insert data failed, err: ${JSON.stringify(err)}`);
callback(resFlag);
return;
}
hilog.info(0x0000, '[Debug.Rdb]', `insert data finished: ${ret}`);
callback(ret);
});
}
}
|
https://github.com/lentozi/DailyPlan.git/blob/96ce0bec8f545511c51b577c4aa8327c2c5bb0c8/entry/src/main/ets/databaseability/DatabaseAbility.ets#L51-L72
|
3c36f06e393ebd1622cc8dc86cd3f4b9fa926b85
|
github
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.