nwo stringclasses 304
values | sha stringclasses 304
values | path stringlengths 9 214 | language stringclasses 1
value | identifier stringlengths 0 49 | docstring stringlengths 1 34.2k | function stringlengths 8 59.4k | ast_function stringlengths 71 497k | obf_function stringlengths 8 39.4k | url stringlengths 102 324 | function_sha stringlengths 40 40 | source stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
harmonyos_samples/BestPracticeSnippets | 490ea539a6d4427dd395f3dac3cf4887719f37af | ComponentReuse/entry/src/main/ets/view/WithFuncParam.ets | arkts | aboutToReuse | [EndExclude opt_funcParam] | aboutToReuse(params: Record<string, Object>): void {
this.sum = params.sum as number;
} | AST#method_declaration#Left aboutToReuse AST#parameter_list#Left ( AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotatio... | aboutToReuse(params: Record<string, Object>): void {
this.sum = params.sum as number;
} | https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ComponentReuse/entry/src/main/ets/view/WithFuncParam.ets#L86-L88 | e49a95f2d622972b9837292f4342346c8e9a1cf6 | gitee |
openharmony/applications_app_samples | a826ab0e75fe51d028c1c5af58188e908736b53b | code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_encryption_decryption/sm4_gcm_encryption_decryption_synchronous.ets | arkts | decryptMessage | 解密消息 | function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) {
let decoder = cryptoFramework.createCipher('SM4_128|GCM|PKCS7');
decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams);
let decryptUpdate = decoder.updateSync(cipherText);
// gcm模式解密doFinal时传入空... | AST#function_declaration#Left function decryptMessage AST#parameter_list#Left ( 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 c... | function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) {
let decoder = cryptoFramework.createCipher('SM4_128|GCM|PKCS7');
decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams);
let decryptUpdate = decoder.updateSync(cipherText);
let decryptData = ... | https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidanceSM4ArkTs/entry/src/main/ets/pages/sm4_gcm_encryption_decryption/sm4_gcm_encryption_decryption_synchronous.ets#L59-L69 | c3a21c4e6627248ccab05f8192da4106d81ab5c2 | gitee |
zqaini002/YaoYaoLingXian.git | 5095b12cbeea524a87c42d0824b1702978843d39 | YaoYaoLingXian/entry/src/main/ets/utils/StorageUtils.ets | arkts | ensureInitialized | 确保存储已初始化 | private async ensureInitialized(): Promise<void> {
if (!this.preferences) {
await this.init();
}
} | AST#method_declaration#Left private async ensureInitialized 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 >... | private async ensureInitialized(): Promise<void> {
if (!this.preferences) {
await this.init();
}
} | https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/utils/StorageUtils.ets#L126-L130 | 220f0a5bc360d5ec637e22c3b5904bbf0e9e40c2 | github |
harmonyos-cases/cases | eccdb71f1cee10fa6ff955e16c454c1b59d3ae13 | CommonAppDevelopment/feature/customstepper/src/main/ets/common/Utils.ets | arkts | 对未实现对应功能的UI进行提示
@param msg toast进行提示的信息,如果不传,则使用配置的默认值 | export function notImplementPrompt(msg?: string) {
promptAction.showToast({ message: msg ?? $r("app.string.stepper_not_implement_prompt") });
} | AST#export_declaration#Left export AST#function_declaration#Left function notImplementPrompt AST#parameter_list#Left ( AST#parameter#Left msg ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left... | export function notImplementPrompt(msg?: string) {
promptAction.showToast({ message: msg ?? $r("app.string.stepper_not_implement_prompt") });
} | https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/customstepper/src/main/ets/common/Utils.ets#L22-L24 | e2238f823bd03a92d36746ee2642af54d8c58901 | gitee | |
common-apps/ZRouter | 5adc9c4bcca6ba7d9b323451ed464e1e9b47eee6 | RouterApi/src/main/ets/api/Router.ets | arkts | getService | 获取服务路由实例
@param name
@returns | public static getService<T extends IProvider>(name: string): T | null {
return ZRouter.serviceMgr().getService<T>(name)
} | AST#method_declaration#Left public static getService AST#type_parameters#Left < AST#type_parameter#Left T extends AST#type_annotation#Left AST#primary_type#Left IProvider AST#primary_type#Right AST#type_annotation#Right AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left na... | public static getService<T extends IProvider>(name: string): T | null {
return ZRouter.serviceMgr().getService<T>(name)
} | https://github.com/common-apps/ZRouter/blob/5adc9c4bcca6ba7d9b323451ed464e1e9b47eee6/RouterApi/src/main/ets/api/Router.ets#L210-L212 | 255b53cd277d30f8bad6bc1d41103a6a118eea43 | gitee |
openharmony/applications_app_samples | a826ab0e75fe51d028c1c5af58188e908736b53b | code/SystemFeature/FileManagement/MediaCollections/entry/src/main/ets/model/TypeConversion.ets | arkts | uuidChange | uuid 转换
1.字母大写
2.去除符号:- | static uuidChange(uuid: string): string {
let oldArr: string[] = uuid.split('')
let newArr: string[] = []
for (let i = 0; i < oldArr.length; i++) {
if (oldArr[i] === '-') {
continue
}
if (oldArr[i] >= 'a' && oldArr[i] <= 'z') {
oldArr[i] = oldArr[i].toUpperCase()
}
... | AST#method_declaration#Left static uuidChange AST#parameter_list#Left ( AST#parameter#Left uuid : 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... | static uuidChange(uuid: string): string {
let oldArr: string[] = uuid.split('')
let newArr: string[] = []
for (let i = 0; i < oldArr.length; i++) {
if (oldArr[i] === '-') {
continue
}
if (oldArr[i] >= 'a' && oldArr[i] <= 'z') {
oldArr[i] = oldArr[i].toUpperCase()
}
... | https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/FileManagement/MediaCollections/entry/src/main/ets/model/TypeConversion.ets#L84-L97 | 363ff4da620980b9595092c997a13903ecf674ea | gitee |
wangjinyuan/JS-TS-ArkTS-database.git | a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26 | npm/alprazolamdiv/11.5.1/package/src/client/actions/GuildEmojisUpdate.ets | arkts | handle | 应替换为具体Client类型 应用约束18:类字段在类中声明 | handle(data: any): void { // 应替换为具体数据类型
const guild = this.client.guilds.get(data.guild_id);
if (!guild || !guild.emojis) return;
// 应用约束14:使用Map代替index signature
const deletions = mappify(guild.emojis.entries());
for (const emoji of data.emojis) {
const cachedEmoji... | AST#method_declaration#Left handle AST#parameter_list#Left ( AST#parameter#Left data : 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 void AST#primary_type#Right AST#type_... | handle(data: any): void {
const guild = this.client.guilds.get(data.guild_id);
if (!guild || !guild.emojis) return;
const deletions = mappify(guild.emojis.entries());
for (const emoji of data.emojis) {
const cachedEmoji = guild.emojis.get(emoji.id);
if... | https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/client/actions/GuildEmojisUpdate.ets#L19-L43 | 3a3608dbc83fa850c9686e36fa96f4c9aa977109 | github |
harmonyos-cases/cases | eccdb71f1cee10fa6ff955e16c454c1b59d3ae13 | CommonAppDevelopment/feature/imagedepthcopy/src/main/ets/view/ImageDepthCopy.ets | arkts | getCropTool | 底部裁剪选项 | @Builder
getCropTool() {
Row() {
List() {
// TODO: 性能知识点:使用ForEach组件循环渲染数据
ForEach(cropTaskDatas, (item: TaskData, index: number) => {
ListItem() {
Column() {
Image(item.image)
.width($r('app.float.image_depthcopy_size_30'))
... | AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right getCropTool AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element... | @Builder
getCropTool() {
Row() {
List() {
ForEach(cropTaskDatas, (item: TaskData, index: number) => {
ListItem() {
Column() {
Image(item.image)
.width($r('app.float.image_depthcopy_size_30'))
.height($r('app.float.image_dep... | https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/imagedepthcopy/src/main/ets/view/ImageDepthCopy.ets#L178-L231 | ad4af9df90c918e09391910a35eb183638dba8e5 | gitee |
harmonyos-cases/cases | eccdb71f1cee10fa6ff955e16c454c1b59d3ae13 | CommonAppDevelopment/feature/miniplayeranimation/src/main/ets/view/MiniPlayerAnimation.ets | arkts | aboutToAppear | 获取屏幕宽高,顶部和底部非安全区域高度 | async aboutToAppear() {
// 检查设备是否可折叠。false表示不可折叠,true表示可折叠。
this.isFoldable = display.isFoldable();
if (this.isFoldable) {
// 如果是可折叠设备,注册折叠设备屏幕显示模式变化监听
display.on('foldDisplayModeChange', this.callback);
}
// 获取屏幕宽高
this.animationData.screenHeight = px2vp(display.getDefaultDisplaySyn... | AST#method_declaration#Left async aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { // 检查设备是否可折叠。false表示不可折叠,true表示可折叠。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#... | async aboutToAppear() {
this.isFoldable = display.isFoldable();
if (this.isFoldable) {
display.on('foldDisplayModeChange', this.callback);
}
this.animationData.screenHeight = px2vp(display.getDefaultDisplaySync().height);
this.animationData.screenWidth = this.getCurrentScreenW... | https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/miniplayeranimation/src/main/ets/view/MiniPlayerAnimation.ets#L115-L154 | 34e79d35306ba5e2f56bf44719a5dd68080eeb2e | gitee |
openharmony-tpc/ohos_mpchart | 4fb43a7137320ef2fee2634598f53d93975dfb4a | library/src/main/ets/components/components/XAxis.ets | arkts | getCustomLabels | 获取自定义Labels
@returns labels数组 | public getCustomLabels(): number[] {
return this.customLabels;
} | AST#method_declaration#Left public getCustomLabels AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement... | public getCustomLabels(): number[] {
return this.customLabels;
} | https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/components/XAxis.ets#L195-L197 | 5145fbcb965cc44ca1696cced38137fb37a02212 | gitee |
openharmony/arkui_ace_engine | 30c7d1ee12fbedf0fabece54291d75897e2ad44f | advanced_ui_component/multinavigation/source/multinavigation.ets | arkts | isPhone | whether the device type is phone
@returns true if is phone | static isPhone(): boolean {
return (DeviceHelper.DEVICE_TYPE === DeviceHelper.TYPE_PHONE ||
DeviceHelper.DEVICE_TYPE === DeviceHelper.TYPE_DEFAULT);
} | AST#method_declaration#Left static isPhone AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#parenthesized_e... | static isPhone(): boolean {
return (DeviceHelper.DEVICE_TYPE === DeviceHelper.TYPE_PHONE ||
DeviceHelper.DEVICE_TYPE === DeviceHelper.TYPE_DEFAULT);
} | https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/advanced_ui_component/multinavigation/source/multinavigation.ets#L38-L41 | 69a731676828e566d62795f30744f97b3cd72fe4 | gitee |
harmonyos_samples/BestPracticeSnippets | 490ea539a6d4427dd395f3dac3cf4887719f37af | DealStrideSolution/entry/src/main/ets/pages/PageThree.ets | arkts | navDestinationTitleImg | [StartExclude PageThree_start] | @Builder
navDestinationTitleImg(res:Resource,fun:()=>void) {
Image(res)
.padding(8)
.width(40)
.height(40)
.borderRadius('50%')
.colorFilter('#171717')
.backgroundColor('#e6e8e9')
.onClick(() => {
fun();
})
} | AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right navDestinationTitleImg AST#parameter_list#Left ( AST#parameter#Left res : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left fun : AST#type_annotati... | @Builder
navDestinationTitleImg(res:Resource,fun:()=>void) {
Image(res)
.padding(8)
.width(40)
.height(40)
.borderRadius('50%')
.colorFilter('#171717')
.backgroundColor('#e6e8e9')
.onClick(() => {
fun();
})
} | https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/DealStrideSolution/entry/src/main/ets/pages/PageThree.ets#L51-L63 | 1627cd5fc8505b947f416f440d733b00eec5fb4a | gitee |
openharmony/applications_app_samples | a826ab0e75fe51d028c1c5af58188e908736b53b | code/UI/SearchComponent/searchcomponent/Index.ets | arkts | SearchComponent | 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, soft... | export { SearchComponent } from './src/main/ets/components/mainpage/SearchComponent'; | AST#export_declaration#Left export { SearchComponent } from './src/main/ets/components/mainpage/SearchComponent' ; AST#export_declaration#Right | export { SearchComponent } from './src/main/ets/components/mainpage/SearchComponent'; | https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/UI/SearchComponent/searchcomponent/Index.ets#L16-L16 | 370db81f34b37e5879e17aad7b92761de81c6cd7 | gitee |
harmonyos_samples/BestPracticeSnippets | 490ea539a6d4427dd395f3dac3cf4887719f37af | VideoProcessBaseWeb/entry/src/main/ets/utils/WebDownloadManager.ets | arkts | pause | [StartExclude manage] | public pause() {
const state = this.currentTask.getState();
if (state === webview.WebDownloadState.IN_PROGRESS) {
try {
this.currentTask.pause();
} catch (error) {
hilog.error(0x0000, 'testTag', 'Execution failed, code = %{public}d, message = %{public}s',
error.code, error.... | AST#method_declaration#Left public pause AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left state = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#... | public pause() {
const state = this.currentTask.getState();
if (state === webview.WebDownloadState.IN_PROGRESS) {
try {
this.currentTask.pause();
} catch (error) {
hilog.error(0x0000, 'testTag', 'Execution failed, code = %{public}d, message = %{public}s',
error.code, error.... | https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/VideoProcessBaseWeb/entry/src/main/ets/utils/WebDownloadManager.ets#L121-L131 | 0255aa1f84d7d0b1d024051092037445e63f48e0 | gitee |
openharmony/interface_sdk-js | c349adc73e2ec1f61f6fca489b5af059e3ed6999 | api/@ohos.arkui.advanced.Dialog.d.ets | arkts | AlertDialog | Declare CustomDialog AlertDialog
@syscap SystemCapability.ArkUI.ArkUI.Full
@since 10
Declare CustomDialog AlertDialog
@syscap SystemCapability.ArkUI.ArkUI.Full
@atomicservice
@since 11
Declare CustomDialog AlertDialog
@syscap SystemCapability.ArkUI.ArkUI.Full
@crossplatform
@atomicservice
@since 18 | @CustomDialog
export declare struct AlertDialog {
/**
* Sets the AlertDialog Controller.
* @type { CustomDialogController }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
/**
* Sets the AlertDialog Controller.
* @type { CustomDialogController }.
* @syscap SystemCapability.ArkUI.... | AST#decorated_export_declaration#Left AST#decorator#Left @ CustomDialog AST#decorator#Right export AST#ERROR#Left declare AST#ERROR#Right struct AlertDialog AST#component_body#Left { /**
* Sets the AlertDialog Controller.
* @type { CustomDialogController }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @sin... | @CustomDialog
export declare struct AlertDialog {
controller: CustomDialogController;
primaryTitle?: ResourceStr;
secondaryTitle?: ResourceStr;
content: ResourceStr;
primaryButton?: ButtonOptions;
secondaryButton?: ButtonOptions;
theme?: Theme | CustomTheme;
... | https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.arkui.advanced.Dialog.d.ets#L863-L991 | a79df3810d534766abc1dcf174df7d98c09f5612 | gitee |
HomoArk/Homogram.git | 8a6e85898b6194fdd04ead75e732d348888a0c07 | features/home/src/main/ets/viewmodel/Chat/ChatDataSource.ets | arkts | notifyDataAdd | 通知LazyForEach组件需要在index对应索引处添加子组件 | notifyDataAdd(index: number): void {
Logger.debug('notifyDataAdd: ' + index);
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#Righ... | notifyDataAdd(index: number): void {
Logger.debug('notifyDataAdd: ' + index);
this.listeners.forEach(listener => {
listener.onDataAdd(index);
})
} | https://github.com/HomoArk/Homogram.git/blob/8a6e85898b6194fdd04ead75e732d348888a0c07/features/home/src/main/ets/viewmodel/Chat/ChatDataSource.ets#L237-L242 | f13d85ec6d28ecc0e0ebac55089c26b2e58b5cd6 | github |
openharmony/applications_app_samples | a826ab0e75fe51d028c1c5af58188e908736b53b | code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/VPNControl_Case/entry/src/main/ets/notification/NotificationUtil.ets | arkts | publishNotification | @param notificationRequest
@param id, Support specifying notification id when publishing notifications | async publishNotification(notificationRequest: notificationManager.NotificationRequest, group?: string) {
notificationRequest.id = this.id;
this.id++;
if (group) {
notificationRequest.groupName = group;
}
try {
await notificationManager.publish(notificationRequest);
// Notify mana... | AST#method_declaration#Left async publishNotification AST#parameter_list#Left ( AST#parameter#Left notificationRequest : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left notificationManager . NotificationRequest AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#paramete... | async publishNotification(notificationRequest: notificationManager.NotificationRequest, group?: string) {
notificationRequest.id = this.id;
this.id++;
if (group) {
notificationRequest.groupName = group;
}
try {
await notificationManager.publish(notificationRequest);
await n... | https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/VPNControl_Case/entry/src/main/ets/notification/NotificationUtil.ets#L49-L65 | 7822d89f5c6c74320d3c2df1788a8dc5dd43afba | gitee |
openharmony/applications_app_samples | a826ab0e75fe51d028c1c5af58188e908736b53b | code/Performance/OperateRDBInTaskPool/casesfeature/operaterdbintaskpool/src/main/ets/view/DatabaseConnection.ets | arkts | updateData | 更新数据库 | public async updateData(context: common.Context, contact: Contact): Promise<void> {
logger.info(TAG, 'update begin');
if (!context) {
logger.info(TAG, 'context is null or undefined');
}
const predicates = new rdb.RdbPredicates(TABLE_NAME);
if (predicates === null || predicates === undefined) ... | AST#method_declaration#Left public async updateData 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#Left contact : ... | public async updateData(context: common.Context, contact: Contact): Promise<void> {
logger.info(TAG, 'update begin');
if (!context) {
logger.info(TAG, 'context is null or undefined');
}
const predicates = new rdb.RdbPredicates(TABLE_NAME);
if (predicates === null || predicates === undefined) ... | https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Performance/OperateRDBInTaskPool/casesfeature/operaterdbintaskpool/src/main/ets/view/DatabaseConnection.ets#L256-L303 | f87023032fa55a6603a55835a6c201094853d02c | gitee |
openharmony/update_update_app | 0157b7917e2f48e914b5585991e8b2f4bc25108a | feature/ota/src/main/ets/dialog/DialogHelper.ets | arkts | 文件校验失败弹框
@param operator 回调 | export function displayVerifyFailDialog(operator ?: DialogOperator): void {
defaultNoTitleDialog($r('app.string.package_verify_fail'), operator);
} | AST#export_declaration#Left export AST#function_declaration#Left function displayVerifyFailDialog AST#parameter_list#Left ( AST#parameter#Left operator ? : AST#type_annotation#Left AST#primary_type#Left DialogOperator AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#... | export function displayVerifyFailDialog(operator ?: DialogOperator): void {
defaultNoTitleDialog($r('app.string.package_verify_fail'), operator);
} | https://github.com/openharmony/update_update_app/blob/0157b7917e2f48e914b5585991e8b2f4bc25108a/feature/ota/src/main/ets/dialog/DialogHelper.ets#L133-L135 | 2b2fcb654600493b9060f0029759f35432aa5188 | gitee | |
openharmony/applications_app_samples | a826ab0e75fe51d028c1c5af58188e908736b53b | code/Solutions/IM/Chat/features/chatlist/src/main/ets/utils/DataFactory.ets | arkts | 加载聊天列表数据,到参数传入的懒加载数据列表中
@param listData 懒加载数据列表 | export async function makeDataLocal(listData: ChatListData, MockDataFileDir: string): Promise<void> {
Logger.info(TAG, 'makeDataLocal');
hiTraceMeter.startTrace(MAKE_DATA_LOCAL_TRACE, MAKE_DATA_LOCAL_TRACE_ID);
let chatModelMockData = await getChatModelObjFromJSON(MockDataFileDir);
for (let i = 0; i < Constants... | 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 ChatListData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left MockDataFileDir : AS... | export async function makeDataLocal(listData: ChatListData, MockDataFileDir: string): Promise<void> {
Logger.info(TAG, 'makeDataLocal');
hiTraceMeter.startTrace(MAKE_DATA_LOCAL_TRACE, MAKE_DATA_LOCAL_TRACE_ID);
let chatModelMockData = await getChatModelObjFromJSON(MockDataFileDir);
for (let i = 0; i < Constants... | https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Solutions/IM/Chat/features/chatlist/src/main/ets/utils/DataFactory.ets#L40-L49 | bd21cb2d66190b21226a545ee903f71d6cd5819d | gitee | |
yycy134679/FoodieHarmony.git | e6971f0a8f7574ae278d02eb5c057e57e667dab5 | entry/src/main/ets/view/home/HomeTabContent.ets | arkts | loadInitialData | 加载初始数据
包括轮播图商家和第一页商家列表 | private async loadInitialData() {
try {
hilog.info(DOMAIN, TAG, 'Loading initial data');
// 加载轮播图商家
this.bannerMerchants = await this.homeViewModel.getBannerMerchants();
// 加载第一页商家列表
await this.loadMerchantList(1, false);
hilog.info(DOMAIN, TAG, 'Initial data... | AST#method_declaration#Left private async loadInitialData 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#... | private async loadInitialData() {
try {
hilog.info(DOMAIN, TAG, 'Loading initial data');
this.bannerMerchants = await this.homeViewModel.getBannerMerchants();
await this.loadMerchantList(1, false);
hilog.info(DOMAIN, TAG, 'Initial data loaded successfully')... | https://github.com/yycy134679/FoodieHarmony.git/blob/e6971f0a8f7574ae278d02eb5c057e57e667dab5/entry/src/main/ets/view/home/HomeTabContent.ets#L67-L85 | e6e0096ca632eae2ed31c84b8dc0e9f8cad68ef9 | github |
harmonyos_samples/BestPracticeSnippets | 490ea539a6d4427dd395f3dac3cf4887719f37af | Privacy/PrivacyError/src/main/ets/pages/UntrustedDataToSQL.ets | arkts | exesql | [EndExclude untrusted_data_to_sql] The sql parameters are from external input | function exesql(sql: string) {
const STORE_CONFIG: relationalStore.StoreConfig = {
name: 'RdbTest.db',
securityLevel: relationalStore.SecurityLevel.S1
};
let store: relationalStore.RdbStore | undefined = undefined;
relationalStore.getRdbStore(context, STORE_CONFIG, (err: BusinessError, rdbStore: relatio... | AST#function_declaration#Left function exesql AST#parameter_list#Left ( AST#parameter#Left sql : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Le... | function exesql(sql: string) {
const STORE_CONFIG: relationalStore.StoreConfig = {
name: 'RdbTest.db',
securityLevel: relationalStore.SecurityLevel.S1
};
let store: relationalStore.RdbStore | undefined = undefined;
relationalStore.getRdbStore(context, STORE_CONFIG, (err: BusinessError, rdbStore: relatio... | https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/Privacy/PrivacyError/src/main/ets/pages/UntrustedDataToSQL.ets#L32-L57 | 0335fe48001ba24be19d50bbbc96bf48928aaf6b | gitee |
Joker-x-dev/HarmonyKit.git | f97197ce157df7f303244fba42e34918306dfb08 | core/data/src/main/ets/repository/AccountStoreRepository.ets | arkts | @file 账号密码本地存储仓库,封装存取逻辑
@author Joker.X | export class AccountStoreRepository {
/**
* 本地数据源实例
*/
private dataSource: AccountStoreDataSource;
/**
* 构造函数
* @param {common.Context} [context] UIAbility 上下文
* @param {AccountStoreDataSource} [dataSource] 可选自定义数据源
*/
constructor(context?: common.Context, dataSource?: AccountStoreDataSource)... | AST#export_declaration#Left export AST#class_declaration#Left class AccountStoreRepository AST#class_body#Left { /**
* 本地数据源实例
*/ AST#property_declaration#Left private dataSource : AST#type_annotation#Left AST#primary_type#Left AccountStoreDataSource AST#primary_type#Right AST#type_annotation#Right ; AST#property... | export class AccountStoreRepository {
private dataSource: AccountStoreDataSource;
constructor(context?: common.Context, dataSource?: AccountStoreDataSource) {
this.dataSource = dataSource ?? new AccountStoreDataSourceImpl(context);
}
saveAccount(account: string): Promise<void> {
return this.d... | https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/data/src/main/ets/repository/AccountStoreRepository.ets#L8-L56 | 40323e939d4acdaa4e4e282aa9b06248b8d4c6a5 | github | |
zqaini002/YaoYaoLingXian.git | 5095b12cbeea524a87c42d0824b1702978843d39 | YaoYaoLingXian/entry/src/main/ets/pages/dream/DreamEditPage.ets | arkts | uploadImage | 上传图片到服务器 | async uploadImage(imageUri: string): Promise<string | null> {
try {
this.isUploadingImage = true;
const toastOpts: ToastOptions = { message: '开始上传图片...' };
promptAction.showToast(toastOpts);
console.info(`准备上传图片: ${imageUri}`);
// 检查URI格式
if (!imageUri.startsWith('file://'... | AST#method_declaration#Left async uploadImage AST#parameter_list#Left ( AST#parameter#Left imageUri : 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#Le... | async uploadImage(imageUri: string): Promise<string | null> {
try {
this.isUploadingImage = true;
const toastOpts: ToastOptions = { message: '开始上传图片...' };
promptAction.showToast(toastOpts);
console.info(`准备上传图片: ${imageUri}`);
if (!imageUri.startsWith('file://')) {
... | https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/pages/dream/DreamEditPage.ets#L673-L750 | 3bd0b2cfa9161870b26a253e135acab3153257a6 | github |
bigbear20240612/birthday_reminder.git | 647c411a6619affd42eb5d163ff18db4b34b27ff | entry/src/main/ets/services/common/ErrorHandler.ets | arkts | showUserFriendlyError | 显示用户友好的错误提示 | private async showUserFriendlyError(errorInfo: ErrorInfo): Promise<void> {
const userMessage = errorInfo.userMessage || this.getDefaultUserMessage(errorInfo.type);
const suggestions = errorInfo.suggestions || this.getDefaultSuggestions(errorInfo.type);
// 对于严重错误,显示对话框
if (this.isSevereError(errorInfo.t... | AST#method_declaration#Left private async showUserFriendlyError AST#parameter_list#Left ( AST#parameter#Left errorInfo : AST#type_annotation#Left AST#primary_type#Left ErrorInfo AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Le... | private async showUserFriendlyError(errorInfo: ErrorInfo): Promise<void> {
const userMessage = errorInfo.userMessage || this.getDefaultUserMessage(errorInfo.type);
const suggestions = errorInfo.suggestions || this.getDefaultSuggestions(errorInfo.type);
if (this.isSevereError(errorInfo.type)) {
a... | https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/common/ErrorHandler.ets#L109-L120 | 92ae144a4cd22084d771cec385a261dcf336436b | github |
tongyuyan/harmony-utils | 697472f011a43e783eeefaa28ef9d713c4171726 | harmony_utils/src/main/ets/crypto/AES.ets | arkts | encryptCBCSync | 加密(CBC模式),同步
@param data 加密或者解密的数据。data不能为null。
@param symKey 指定加密或解密的密钥。
@param ivParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。
@param transformation 待生成Cipher的算法名称(含密钥长度)、加密模式以及填充方法的组合(AES256|CBC|PKCS7、AES192|CBC|PKCS7、AES128|CBC|PKCS7)。
@returns | static encryptCBCSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey,
ivParams: cryptoFramework.IvParamsSpec, transformation: string = 'AES256|CBC|PKCS7'): cryptoFramework.DataBlob {
return AES.encryptSync(data, symKey, ivParams, transformation);
} | AST#method_declaration#Left static encryptCBCSync 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 symKe... | static encryptCBCSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey,
ivParams: cryptoFramework.IvParamsSpec, transformation: string = 'AES256|CBC|PKCS7'): cryptoFramework.DataBlob {
return AES.encryptSync(data, symKey, ivParams, transformation);
} | https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/crypto/AES.ets#L123-L126 | b57f8907d722e4e3dd5ff173e6d29ac48cf32c04 | gitee |
KoStudio/ArkTS-WordTree.git | 78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324 | entry/src/main/ets/common/utils/DateUtils.ets | arkts | addMinutes | 增加分钟
@param date 基准日期
@param minutesToAdd 增加的分钟数
@returns 新日期对象 | static addMinutes(date: Date, minutesToAdd: number): Date {
return new Date(date.getTime() + minutesToAdd * 60000); // 60 * 1000
} | AST#method_declaration#Left static addMinutes AST#parameter_list#Left ( AST#parameter#Left date : AST#type_annotation#Left AST#primary_type#Left Date AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left minutesToAdd : AST#type_annotation#Left AST#primary_type#Left number AST#primary... | static addMinutes(date: Date, minutesToAdd: number): Date {
return new Date(date.getTime() + minutesToAdd * 60000);
} | https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/utils/DateUtils.ets#L92-L94 | 2c8a77c7ef51955b30882d66f3ec8cd4351bccfc | github |
Joker-x-dev/CoolMallArkTS.git | 9f3fabf89fb277692cb82daf734c220c7282919c | core/data/src/main/ets/repository/FootprintRepository.ets | arkts | addFootprint | 添加足迹记录
@param {Footprint} footprint 足迹记录
@returns {Promise<void>} Promise<void> | addFootprint(footprint: Footprint): Promise<void> {
return this.dataSource.addFootprint(footprint);
} | AST#method_declaration#Left addFootprint AST#parameter_list#Left ( AST#parameter#Left footprint : AST#type_annotation#Left AST#primary_type#Left Footprint 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#Lef... | addFootprint(footprint: Footprint): Promise<void> {
return this.dataSource.addFootprint(footprint);
} | https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/data/src/main/ets/repository/FootprintRepository.ets#L27-L29 | 38978971d547f2606c5bd0bcce4ceed81e56f3ff | github |
openharmony/applications_app_samples | a826ab0e75fe51d028c1c5af58188e908736b53b | code/DocsSample/NetWork_Kit/NetWorkKit_Datatransmission/Socket/entry/src/main/ets/connect/OneWayTls.ets | arkts | connect2Server | 连接服务端 | connect2Server() {
if (!this.ca) {
this.msgHistory += 'Error: CA certificate is empty. Please load CA before connecting.\r\n';
return;
}
// 服务端地址
workerPort.postMessage({
type: 'connectServer',
serverIp: this.serverIp,
serverPort: this.serverPort,
ca: this.ca
});
... | AST#method_declaration#Left connect2Server 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_... | connect2Server() {
if (!this.ca) {
this.msgHistory += 'Error: CA certificate is empty. Please load CA before connecting.\r\n';
return;
}
workerPort.postMessage({
type: 'connectServer',
serverIp: this.serverIp,
serverPort: this.serverPort,
ca: this.ca
});
work... | https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/NetWork_Kit/NetWorkKit_Datatransmission/Socket/entry/src/main/ets/connect/OneWayTls.ets#L244-L266 | 0eae8d424e7efcf2c83c1785bf3dd7fa299e3c0a | gitee |
chongzi/Lucky-ArkTs.git | 84fc104d4a68def780a483e2543ebf9f53e793fd | entry/src/main/ets/common/StudyTimeManager.ets | arkts | startTracking | 开始学习时长统计 | startTracking(): void {
if (this.isTracking) {
return
}
this.isTracking = true
this.startTime = Date.now()
this.totalSessionTime = 0
console.info('[StudyTimeManager] 开始学习时长统计')
// 每分钟更新一次学习时长
this.updateInterval = setInterval(() => {
this.updateStudyTime()
}, 60000) //... | AST#method_declaration#Left startTracking 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_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_exp... | startTracking(): void {
if (this.isTracking) {
return
}
this.isTracking = true
this.startTime = Date.now()
this.totalSessionTime = 0
console.info('[StudyTimeManager] 开始学习时长统计')
this.updateInterval = setInterval(() => {
this.updateStudyTime()
}, 60000)
} | https://github.com/chongzi/Lucky-ArkTs.git/blob/84fc104d4a68def780a483e2543ebf9f53e793fd/entry/src/main/ets/common/StudyTimeManager.ets#L20-L35 | 6b840039998bd72d446fd04ccca30cfbd7dcaf64 | github |
harmonyos-cases/cases | eccdb71f1cee10fa6ff955e16c454c1b59d3ae13 | CommonAppDevelopment/feature/encapsulationdialog/src/main/ets/dialog/util/AnimationUtil.ets | arkts | transitionFromCenter | 中间弹出动画
@param duration 动画时间
@returns | static transitionFromCenter(duration: number = 200): TransitionEffect {
return TransitionEffect.OPACITY.animation({ duration: duration });
} | AST#method_declaration#Left static transitionFromCenter 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#expression#Left 200 AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_... | static transitionFromCenter(duration: number = 200): TransitionEffect {
return TransitionEffect.OPACITY.animation({ duration: duration });
} | https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/encapsulationdialog/src/main/ets/dialog/util/AnimationUtil.ets#L79-L81 | 4f0fa079dc10b10bca0c3861046e197a0393b0a9 | gitee |
wuyuanwuhui999/harmony-arkts-chat-app-ui.git | 128861bc002adae9c34c6ce8fbf12686c26e51ec | entry/src/main/ets/utils/PreferenceModel.ets | arkts | deletePreferences | 删除 preferences 实例对应的首选项 | async deletePreferences() {
try {
await dataPreferences.deletePreferences(context, 'mystore');
} catch (err) {
console.error("Failed to delete preferences:", err);
}
preference = null; // 删除后重置为 null
} | AST#method_declaration#Left async deletePreferences 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 A... | async deletePreferences() {
try {
await dataPreferences.deletePreferences(context, 'mystore');
} catch (err) {
console.error("Failed to delete preferences:", err);
}
preference = null;
} | https://github.com/wuyuanwuhui999/harmony-arkts-chat-app-ui.git/blob/128861bc002adae9c34c6ce8fbf12686c26e51ec/entry/src/main/ets/utils/PreferenceModel.ets#L25-L32 | f013c0ba5f1213468eec46d96972c1ce16afcd66 | github |
bigbear20240612/birthday_reminder.git | 647c411a6619affd42eb5d163ff18db4b34b27ff | entry/src/main/ets/pages/greetings/GreetingSendPage.ets | arkts | getRelationLabel | 获取关系标签 | private getRelationLabel(relation: string): string {
switch (relation) {
case 'family':
return '家人';
case 'friend':
return '朋友';
case 'colleague':
return '同事';
case 'other':
return '其他';
default:
return '其他';
}
} | AST#method_declaration#Left private getRelationLabel AST#parameter_list#Left ( AST#parameter#Left relation : 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#p... | private getRelationLabel(relation: string): string {
switch (relation) {
case 'family':
return '家人';
case 'friend':
return '朋友';
case 'colleague':
return '同事';
case 'other':
return '其他';
default:
return '其他';
}
} | https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/greetings/GreetingSendPage.ets#L809-L822 | e87b0bdd003ea042a5e04c50606b173b01162b1b | github |
openharmony-tpc/ImageKnife | bc55de9e2edd79ed4646ce37177ad94b432874f7 | library/src/main/ets/downsampling/DownsampleUtils.ets | arkts | 四舍五入 | export function round(value: number): number {
return Math.floor(value + 0.5);
} | AST#export_declaration#Left export AST#function_declaration#Left function round AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primar... | export function round(value: number): number {
return Math.floor(value + 0.5);
} | https://github.com/openharmony-tpc/ImageKnife/blob/bc55de9e2edd79ed4646ce37177ad94b432874f7/library/src/main/ets/downsampling/DownsampleUtils.ets#L56-L58 | c9fe79c28a18675550e1241ac1c96294b666738f | gitee | |
bigbear20240612/planner_build-.git | 89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1 | entry/src/main/ets/common/utils/DateUtils.ets | arkts | formatDate | 格式化日期
@param date 日期对象
@param format 格式字符串 ('YYYY-MM-DD', 'MM-DD', 'HH:mm' 等)
@returns 格式化后的日期字符串 | static formatDate(date: Date, format: string = 'YYYY-MM-DD'): string {
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
const hours = date.getHours().toString().padStart(2, '0');
const minutes = ... | AST#method_declaration#Left static formatDate AST#parameter_list#Left ( AST#parameter#Left date : AST#type_annotation#Left AST#primary_type#Left Date AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left format : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#... | static formatDate(date: Date, format: string = 'YYYY-MM-DD'): string {
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
const hours = date.getHours().toString().padStart(2, '0');
const minutes = ... | https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/common/utils/DateUtils.ets#L8-L23 | 868318b35b798c336e1fdf77b8d1b247dad85860 | github |
Joker-x-dev/CoolMallArkTS.git | 9f3fabf89fb277692cb82daf734c220c7282919c | core/database/src/main/ets/datasource/searchhistory/SearchHistoryLocalDataSourceImpl.ets | arkts | getSearchHistoryByKeyword | 根据关键词获取搜索历史记录
@param {string} keyword 搜索关键词
@returns {Promise<SearchHistory | undefined>} 匹配到的搜索历史 | async getSearchHistoryByKeyword(keyword: string): Promise<SearchHistory | undefined> {
const result: SearchHistoryEntity[] = this.orm.query(SearchHistoryEntity).where("keyword", keyword).find();
const entity: SearchHistoryEntity | undefined = result[0];
return entity ? this.toModel(entity) : undefined;
} | AST#method_declaration#Left async 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#ge... | async getSearchHistoryByKeyword(keyword: string): Promise<SearchHistory | undefined> {
const result: SearchHistoryEntity[] = this.orm.query(SearchHistoryEntity).where("keyword", keyword).find();
const entity: SearchHistoryEntity | undefined = result[0];
return entity ? this.toModel(entity) : undefined;
} | https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/database/src/main/ets/datasource/searchhistory/SearchHistoryLocalDataSourceImpl.ets#L99-L103 | c7f26eabdf90a03db62341f8af024ce34a94318a | github |
yunkss/ef-tool | 75f6761a0f2805d97183504745bf23c975ae514d | ef_crypto_dto/src/main/ets/crypto/encryption/SHA.ets | arkts | digestSHA224 | SHA224摘要
@param str 带摘要的字符串
@returns 摘要后的字符串 | static async digestSHA224(str: string): Promise<OutDTO<string>> {
return CryptoUtil.digest(str, 'SHA224');
} | AST#method_declaration#Left static async digestSHA224 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 AST#generic_type... | static async digestSHA224(str: string): Promise<OutDTO<string>> {
return CryptoUtil.digest(str, 'SHA224');
} | https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto_dto/src/main/ets/crypto/encryption/SHA.ets#L42-L44 | 477f3a66bd0fa10ff93345e9ad2c411c34fdbb9e | gitee |
awa_Liny/LinysBrowser_NEXT | a5cd96a9aa8114cae4972937f94a8967e55d4a10 | home/src/main/ets/processes/tabs_actions.ets | arkts | Saves the history.
@param tab_info The tab_info_packed item of that tab. | export function save_history(tab_info: tab_info_packed) {
let new_record = new history_record(tab_info.title, tab_info.url);
let history = AppStorage.get('bunch_of_history') as bunch_of_history;
history.add_history(new_record, true, true);
} | AST#export_declaration#Left export AST#function_declaration#Left function save_history AST#parameter_list#Left ( AST#parameter#Left tab_info : AST#type_annotation#Left AST#primary_type#Left tab_info_packed AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statemen... | export function save_history(tab_info: tab_info_packed) {
let new_record = new history_record(tab_info.title, tab_info.url);
let history = AppStorage.get('bunch_of_history') as bunch_of_history;
history.add_history(new_record, true, true);
} | https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/processes/tabs_actions.ets#L77-L82 | 1e04dda7fd2a4acceb080f47a63a5fc0544e2e7a | gitee | |
harmonyos_samples/BestPracticeSnippets | 490ea539a6d4427dd395f3dac3cf4887719f37af | NetworkManagement/entry/src/main/ets/pages/WiFiQuery.ets | arkts | getWifiIsConnected | [End get_wifi_status] [Start get_wifi_is_connected] | getWifiIsConnected() {
try {
let ret = wifiManager.isConnected();
hilog.info(0x0000, 'Sample', 'isConnected: %{public}s', ret);
// [StartExclude get_wifi_is_connected]
this.textArea = 'isConnected:' + ret;
// [EndExclude get_wifi_is_connected]
} catch (error) {
hilog.error(0x... | AST#method_declaration#Left getWifiIsConnected AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left ret = AST#expression#Left AST#call_exp... | getWifiIsConnected() {
try {
let ret = wifiManager.isConnected();
hilog.info(0x0000, 'Sample', 'isConnected: %{public}s', ret);
this.textArea = 'isConnected:' + ret;
} catch (error) {
hilog.error(0x0000, 'Sample', 'failed: err->: %{public}s', JSON.stringify(error));
}
... | https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/NetworkManagement/entry/src/main/ets/pages/WiFiQuery.ets#L44-L54 | 3f1c71d2ba24bbbeb98228dcb77dd022f5d61dbe | gitee |
Joker-x-dev/HarmonyKit.git | f97197ce157df7f303244fba42e34918306dfb08 | entry/src/main/ets/adapter/WindowAdapter.ets | arkts | updateSafeArea | 更新安全区状态
@param {SafeAreaInsets} insets - 安全区数据(vp)
@returns {void} 无返回值 | private updateSafeArea(insets: SafeAreaInsets): void {
if (
insets.top === this.currentSafeArea.top
&& insets.left === this.currentSafeArea.left
&& insets.bottom === this.currentSafeArea.bottom
&& insets.right === this.currentSafeArea.right
) {
return;
}
this.currentS... | AST#method_declaration#Left private updateSafeArea AST#parameter_list#Left ( AST#parameter#Left insets : AST#type_annotation#Left AST#primary_type#Left SafeAreaInsets 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... | private updateSafeArea(insets: SafeAreaInsets): void {
if (
insets.top === this.currentSafeArea.top
&& insets.left === this.currentSafeArea.left
&& insets.bottom === this.currentSafeArea.bottom
&& insets.right === this.currentSafeArea.right
) {
return;
}
this.currentS... | https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/entry/src/main/ets/adapter/WindowAdapter.ets#L174-L185 | 1e2a487ee0cca031bb83430791e1769f7dc29d87 | github |
harmonyos-cases/cases | eccdb71f1cee10fa6ff955e16c454c1b59d3ae13 | CommonAppDevelopment/feature/pageflip/src/main/ets/datasource/BasicDataSource.ets | arkts | addItem | 从开头添加数据 | public addItem(item: string): void {
this.elements.unshift(item);
this.listeners.forEach(listeners => listeners.onDataAdd(CONFIGURATION.PAGEFLIPZERO));
} | AST#method_declaration#Left public addItem AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Righ... | public addItem(item: string): void {
this.elements.unshift(item);
this.listeners.forEach(listeners => listeners.onDataAdd(CONFIGURATION.PAGEFLIPZERO));
} | https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/pageflip/src/main/ets/datasource/BasicDataSource.ets#L60-L63 | f55656879a739d22429f51fc84ca502996ef9487 | gitee |
harmonyos-cases/cases | eccdb71f1cee10fa6ff955e16c454c1b59d3ae13 | CommonAppDevelopment/feature/customcalendarpickerdialog/src/main/ets/view/CalendarView.ets | arkts | aboutToAppear | 获取当前日期 | aboutToAppear(): void {
let dateModel: DateModel = getRealTimeDate(); // 获取当前年月日信息
this.currentMonth = dateModel.month; // 获取当前月份
this.currentDay = dateModel.day; // 获取当前日
this.currentYear = dateModel.year; // 获取当前年份
} | AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left dateModel : A... | aboutToAppear(): void {
let dateModel: DateModel = getRealTimeDate();
this.currentMonth = dateModel.month;
this.currentDay = dateModel.day;
this.currentYear = dateModel.year;
} | https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/customcalendarpickerdialog/src/main/ets/view/CalendarView.ets#L42-L47 | 4fdd0e8717c71f2b6676274224e3a277015545dc | gitee |
CongDuang/PlayHarmony.git | 674a0459e1b20db9de8c837dff6a8d1f06330e79 | html_entities_replace/src/main/ets/HtmEntityReplace.ets | arkts | replace | 替换方法
@param str 原字符串
@returns 处理过的结果字符串 | static replace(str?: string): string | undefined {
if (!str) {
return;
}
return str.replace(/&(\w+);/g, (match: string, entity: string) => {
const res = decodeMap[entity] as string | undefined;
return res || match;
})
} | AST#method_declaration#Left static replace 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#union_type#Left AST#primary_type#Left strin... | static replace(str?: string): string | undefined {
if (!str) {
return;
}
return str.replace(/&(\w+);/g, (match: string, entity: string) => {
const res = decodeMap[entity] as string | undefined;
return res || match;
})
} | https://github.com/CongDuang/PlayHarmony.git/blob/674a0459e1b20db9de8c837dff6a8d1f06330e79/html_entities_replace/src/main/ets/HtmEntityReplace.ets#L12-L20 | bf4ae37f96aaed3cddcbfdb29fc6dcff4afd6d13 | github |
harmonyos/samples | f5d967efaa7666550ee3252d118c3c73a77686f5 | ETSUI/CategorySample/entry/src/main/ets/view/CategoryListComponent.ets | arkts | CategoryListComponent | Category list component. | @Component
export struct CategoryListComponent {
private scroller: Scroller = new Scroller();
@State sideTabIndex: number = 1;
build() {
Row() {
List() {
ForEach(CategoryViewModel.getIndexListData(), (item: IndexListItem, index: number) => {
ListItem() {
Text(item.title)
... | AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct CategoryListComponent AST#component_body#Left { AST#property_declaration#Left private scroller : AST#type_annotation#Left AST#primary_type#Left Scroller AST#primary_type#Right AST#type_annotation#Right = AST#expressio... | @Component
export struct CategoryListComponent {
private scroller: Scroller = new Scroller();
@State sideTabIndex: number = 1;
build() {
Row() {
List() {
ForEach(CategoryViewModel.getIndexListData(), (item: IndexListItem, index: number) => {
ListItem() {
Text(item.title)
... | https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/ETSUI/CategorySample/entry/src/main/ets/view/CategoryListComponent.ets#L10-L68 | f9834c3b43078baf3e3ecc568f203922da8f0d0a | gitee |
openharmony/interface_sdk-js | c349adc73e2ec1f61f6fca489b5af059e3ed6999 | api/@ohos.matrix4.d.ets | arkts | Set poly to poly point options.
@interface PolyToPolyOptions
@syscap SystemCapability.ArkUI.ArkUI.Full
@crossplatform
@atomicservice
@since 12 | export interface PolyToPolyOptions {
/**
* Array of point coordinates for the source polygon.
*
* @type { Array<Point> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
src: Array<Point>;
/**
* Start point index of t... | AST#export_declaration#Left export AST#interface_declaration#Left interface PolyToPolyOptions AST#object_type#Left { /**
* Array of point coordinates for the source polygon.
*
* @type { Array<Point> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @sin... | export interface PolyToPolyOptions {
src: Array<Point>;
srcIndex?: number;
dst:Array<Point>;
dstIndex?: number;
pointCount?:number;
} | https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.matrix4.d.ets#L532-L593 | 2b17dfa8069828b4d45fcc4d3fdef6e4e6e4602b | gitee | |
harmonyos-cases/cases | eccdb71f1cee10fa6ff955e16c454c1b59d3ae13 | CommonAppDevelopment/feature/imageviewer/src/main/ets/view/PicturePreviewImage.ets | arkts | PicturePreviewImage | PicturePreviewImage
图片绘制组件
实现步骤:
- 1. 使用matrix实现图片的缩放
- 2. 使用offset实现组件的偏移
- 3. 提前计算图片属性以便对组件属性进行设置
- 4. Image.objectFile使用Cover以便图片能够超出其父组件显示(而不撑大父组件)
@param { Color } listBGColor - 图片背景色
@param { string } imageUrl - 图片预览地址
@param { Axis } listDirection - 图片预览的主轴方向
@param { number } [TogglePercent] - 图片滑动多大距离需要切... | @Reusable
@Component
export struct PicturePreviewImage {
// 当前背景色
@Link listBGColor: Color;
// 图片显示的地址
@Require @Prop imageUrl: string = '';
// 图片滑动方向
@Require @Prop listDirection: Axis;
// 图片滑动多大距离需要切换图片
@Prop TogglePercent: number = 0.2;
// 当前图片下标
@Prop imageIndex: number = 0;
// 最多几张图片
@Prop ... | AST#decorated_export_declaration#Left AST#decorator#Left @ Reusable AST#decorator#Right AST#decorator#Left @ Component AST#decorator#Right export struct PicturePreviewImage AST#component_body#Left { // 当前背景色 AST#property_declaration#Left AST#decorator#Left @ Link AST#decorator#Right listBGColor : AST#type_annotation#Le... | @Reusable
@Component
export struct PicturePreviewImage {
@Link listBGColor: Color;
@Require @Prop imageUrl: string = '';
@Require @Prop listDirection: Axis;
@Prop TogglePercent: number = 0.2;
@Prop imageIndex: number = 0;
@Prop imageMaxLength: number = 0;
setListOffset: (offset: numbe... | https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/imageviewer/src/main/ets/view/PicturePreviewImage.ets#L48-L525 | 6f35909ee10d143245d4a42302f4a6ad86cc6778 | gitee |
openharmony/codelabs | d899f32a52b2ae0dfdbb86e34e8d94645b5d4090 | CommonEventAndNotification/AlarmClock/entry/src/main/ets/viewmodel/MainViewModel.ets | arkts | getTaskTimeContent | 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));
} | 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#pri... | 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));
} | https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/CommonEventAndNotification/AlarmClock/entry/src/main/ets/viewmodel/MainViewModel.ets#L111-L115 | 60329e95eafb522cc1bbe4f207c68defb11db7bb | gitee |
jerryzhou2/ArkTS-news-app.git | 6dfa8631948f1def4269be5a48554b99ee64a18d | fluent-news-homepage-master/entry/src/main/ets/constants/CommonConstants.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, soft... | export class CommonConstants {
/**
* Full percent.
*/
public static readonly FULL_PERCENT: string = '100%';
/**
* Ninety percent.
*/
public static readonly NINETY_PERCENT: string = '90%';
/**
* Common zero.
*/
public static readonly ZERO: number = 0;
/**
* Font weight 500.
*/
pub... | AST#export_declaration#Left export AST#class_declaration#Left class CommonConstants AST#class_body#Left { /**
* Full percent.
*/ AST#property_declaration#Left public static readonly FULL_PERCENT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expressi... | export class CommonConstants {
public static readonly FULL_PERCENT: string = '100%';
public static readonly NINETY_PERCENT: string = '90%';
public static readonly ZERO: number = 0;
public static readonly FONT_WEIGHT_500: number = 500;
public static readonly FONT_WEIGHT_400: number = 400;
p... | https://github.com/jerryzhou2/ArkTS-news-app.git/blob/6dfa8631948f1def4269be5a48554b99ee64a18d/fluent-news-homepage-master/entry/src/main/ets/constants/CommonConstants.ets#L16-L85 | 0e6e1e86fc53dc6932127ced14befae53848d472 | github | |
harmonyos/samples | f5d967efaa7666550ee3252d118c3c73a77686f5 | HarmonyOS_NEXT/Security/Huks/entry/src/main/ets/model/HuksModel.ets | arkts | 功能模型 | export class HuksModel {
// 模拟使用HUKS生成的新密钥进行加密
async encryptData(plainText: string, resultCallback: Function): Promise<void> {
let aesKeyAlias = 'test_aesKeyAlias';
let handle: number = 0;
let generateKeyProperties: HuksProperties[] = new Array();
getAesGenerateProperties(generateKeyProperties);
... | AST#export_declaration#Left export AST#class_declaration#Left class HuksModel AST#class_body#Left { // 模拟使用HUKS生成的新密钥进行加密 AST#method_declaration#Left async encryptData AST#parameter_list#Left ( AST#parameter#Left plainText : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotatio... | export class HuksModel {
async encryptData(plainText: string, resultCallback: Function): Promise<void> {
let aesKeyAlias = 'test_aesKeyAlias';
let handle: number = 0;
let generateKeyProperties: HuksProperties[] = new Array();
getAesGenerateProperties(generateKeyProperties);
let generateKeyOptio... | https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/HarmonyOS_NEXT/Security/Huks/entry/src/main/ets/model/HuksModel.ets#L296-L595 | c0a7e1da008e572bb884839405580a36e8e6cbcd | gitee | |
bigbear20240612/birthday_reminder.git | 647c411a6619affd42eb5d163ff18db4b34b27ff | entry/src/main/ets/services/ai/ModelConfigService.ets | arkts | testModelConnection | 测试模型连通性 | public async testModelConnection(config: ModelConfig): Promise<ModelTestResult> {
const startTime = Date.now();
try {
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP,
`[ModelConfigService] Testing connection for ${config.provider}/${config.modelId}`);
const baseUrl = config.baseUr... | AST#method_declaration#Left public async testModelConnection AST#parameter_list#Left ( AST#parameter#Left config : AST#type_annotation#Left AST#primary_type#Left ModelConfig AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left A... | public async testModelConnection(config: ModelConfig): Promise<ModelTestResult> {
const startTime = Date.now();
try {
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP,
`[ModelConfigService] Testing connection for ${config.provider}/${config.modelId}`);
const baseUrl = config.baseUr... | https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/ai/ModelConfigService.ets#L384-L416 | 0d07c73ad13532bc47b41928c8c8ef6f42c9fa42 | github |
kumaleap/ArkSwipeDeck.git | 5afa77b9b2a2a531595d31f895c54a3371e4249a | library/src/main/ets/utils/GestureUtils.ets | arkts | clampDragDistance | 限制拖拽范围
@param delta - 位移
@param maxDistance - 最大距离
@returns 限制后的位移 | static clampDragDistance(delta: number, maxDistance: number): number {
return Math.max(-maxDistance, Math.min(maxDistance, delta));
} | AST#method_declaration#Left static clampDragDistance AST#parameter_list#Left ( AST#parameter#Left delta : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left maxDistance : AST#type_annotation#Left AST#primary_type#Left number AS... | static clampDragDistance(delta: number, maxDistance: number): number {
return Math.max(-maxDistance, Math.min(maxDistance, delta));
} | https://github.com/kumaleap/ArkSwipeDeck.git/blob/5afa77b9b2a2a531595d31f895c54a3371e4249a/library/src/main/ets/utils/GestureUtils.ets#L233-L235 | d25010daf2bf298d7d90f225bb77183a555aee50 | github |
harmonyos-cases/cases | eccdb71f1cee10fa6ff955e16c454c1b59d3ae13 | CommonAppDevelopment/feature/imageviewer/src/main/ets/view/ImageItemView.ets | arkts | resetCurrentImageInfo | 在图片消失时,将当前图片的信息设置为默认值 | resetCurrentImageInfo(): void {
this.imageScaleInfo.reset();
this.imageOffsetInfo.reset();
this.matrix = matrix4.identity().copy();
} | AST#method_declaration#Left resetCurrentImageInfo 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#ex... | resetCurrentImageInfo(): void {
this.imageScaleInfo.reset();
this.imageOffsetInfo.reset();
this.matrix = matrix4.identity().copy();
} | https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/imageviewer/src/main/ets/view/ImageItemView.ets#L114-L118 | 933dc3cc3f5a8876b1006d527ce56f6e4482f0cc | gitee |
bigbear20240612/birthday_reminder.git | 647c411a6619affd42eb5d163ff18db4b34b27ff | entry/src/main/ets/services/settings/SettingsService.ets | arkts | getAccessibilitySettings | 获取无障碍设置
@returns 无障碍设置 | async getAccessibilitySettings(): Promise<AccessibilitySettings> {
const settings = await this.getSettings();
return settings.accessibility;
} | AST#method_declaration#Left async getAccessibilitySettings 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 AccessibilitySettings AST#primary_type#Right AST#type_an... | async getAccessibilitySettings(): Promise<AccessibilitySettings> {
const settings = await this.getSettings();
return settings.accessibility;
} | https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/settings/SettingsService.ets#L305-L308 | 58492d76c4cf3a704ccb6de54fcb130145b3e1a4 | github |
bigbear20240612/birthday_reminder.git | 647c411a6619affd42eb5d163ff18db4b34b27ff | entry/src/main/ets/services/social/SocialShareService.ets | arkts | initializeService | 初始化服务 | private async initializeService(): Promise<void> {
try {
await this.loadShareTemplates();
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, 'SocialShareService initialized');
} catch (error) {
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to initialize SocialShareS... | AST#method_declaration#Left private async initializeService 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 >... | private async initializeService(): Promise<void> {
try {
await this.loadShareTemplates();
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, 'SocialShareService initialized');
} catch (error) {
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to initialize SocialShareS... | https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/social/SocialShareService.ets#L108-L115 | c14ed6c7e31fdadb8fef75e37db2c184434948e3 | github |
openharmony/applications_app_samples | a826ab0e75fe51d028c1c5af58188e908736b53b | code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetConnection_Exploitation_case/entry/src/main/ets/pages/Index.ets | arkts | GetDefaultNet | [EndExclude build_project5] | GetDefaultNet() {
try {
let netId = testNetManager.NetId();
this.logMessage = `The defaultNetId is [${netId}]`;
Logger.info(this.logMessage);
} catch (error) {
this.logMessage = `Error fetching defaultNetId: ${error}`;
Logger.error(this.logMessage);
}
} | AST#method_declaration#Left GetDefaultNet AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left netId = AST#expression#Left AST#call_expres... | GetDefaultNet() {
try {
let netId = testNetManager.NetId();
this.logMessage = `The defaultNetId is [${netId}]`;
Logger.info(this.logMessage);
} catch (error) {
this.logMessage = `Error fetching defaultNetId: ${error}`;
Logger.error(this.logMessage);
}
} | https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetConnection_Exploitation_case/entry/src/main/ets/pages/Index.ets#L224-L233 | 6b4a2dba51c1b210d2e07e04a90d5eb4bcc61a6f | gitee |
harmonyos_samples/BestPracticeSnippets | 490ea539a6d4427dd395f3dac3cf4887719f37af | OptimizationAppDelay/entry/src/main/ets/pages/CityListPage.ets | arkts | computeTaskAsync | Asynchronous thread | computeTaskAsync() {
let task: taskpool.Task = new taskpool.Task(computeTask);
taskpool.execute(task).then((res) => {
this.citys = res as string[]
})
} | AST#method_declaration#Left computeTaskAsync AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left task : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left taskpool . Task AST#qualified_type#... | computeTaskAsync() {
let task: taskpool.Task = new taskpool.Task(computeTask);
taskpool.execute(task).then((res) => {
this.citys = res as string[]
})
} | https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/OptimizationAppDelay/entry/src/main/ets/pages/CityListPage.ets#L53-L58 | 2c5f5697cae90902287ec6405db0adf28079c55c | gitee |
mayuanwei/harmonyOS_bilibili | 8a36b68b1ddf4433e2e17ee10fee4993cce2a6c5 | Q1/grammar/entry/src/main/ets/pages/LifeCycle1.ets | arkts | onPageHide | 页面隐藏 | onPageHide() {
console.log('page1...onPageHide')
} | AST#method_declaration#Left onPageHide 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_express... | onPageHide() {
console.log('page1...onPageHide')
} | https://github.com/mayuanwei/harmonyOS_bilibili/blob/8a36b68b1ddf4433e2e17ee10fee4993cce2a6c5/Q1/grammar/entry/src/main/ets/pages/LifeCycle1.ets#L49-L51 | 5995414304cf79bb1cfdad4ceadd8ebb82d34e34 | gitee |
anhao0226/harmony-music-player.git | 4bc1d8f9f5fdb573af387d3ba9ad333c9beb8073 | entry/src/main/ets/view_models/ArtistDetailModel.ets | arkts | HotAlbumModel | export class ArtistAlbumModel {
id: number;
name: string;
picUrl: string;
publishTime: number;
blurPicUrl: string;
type: string;
size: number;
description: string;
formJson(json: any): ArtistAlbumModel {
this.id = json['id'];
this.name = json['name'];
this.picUrl = json['picUrl'];
thi... | AST#export_declaration#Left export AST#class_declaration#Left class ArtistAlbumModel 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 name : AST#t... | export class ArtistAlbumModel {
id: number;
name: string;
picUrl: string;
publishTime: number;
blurPicUrl: string;
type: string;
size: number;
description: string;
formJson(json: any): ArtistAlbumModel {
this.id = json['id'];
this.name = json['name'];
this.picUrl = json['picUrl'];
thi... | https://github.com/anhao0226/harmony-music-player.git/blob/4bc1d8f9f5fdb573af387d3ba9ad333c9beb8073/entry/src/main/ets/view_models/ArtistDetailModel.ets#L29-L50 | 27d896cefb9369432cdfc31b5de6b2e6942f67f0 | github | |
yunkss/ef-tool | 75f6761a0f2805d97183504745bf23c975ae514d | ef_crypto_dto/src/main/ets/crypto/encryption/RSA.ets | arkts | encode2048PKCS1 | 2048位加密
@param encodeStr 待加密的字符串
@param pubKey 2048位RSA公钥 | static async encode2048PKCS1(str: string, pubKey: string): Promise<OutDTO<string>> {
return CryptoUtil.encodeAsym(str, pubKey, 'RSA2048', 'RSA2048|PKCS1', 2048);
} | AST#method_declaration#Left static async encode2048PKCS1 AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left pubKey : AST#type_annotation#Left AST#primary_type#Left string AST#p... | static async encode2048PKCS1(str: string, pubKey: string): Promise<OutDTO<string>> {
return CryptoUtil.encodeAsym(str, pubKey, 'RSA2048', 'RSA2048|PKCS1', 2048);
} | https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto_dto/src/main/ets/crypto/encryption/RSA.ets#L69-L71 | 2c23fbd5bd139c6e8472439862634075957d9e6b | gitee |
yunkss/ef-tool | 75f6761a0f2805d97183504745bf23c975ae514d | ef_ui/src/main/ets/ui/base/LocationUtil.ets | arkts | geoConvert | 地理逆编码,转换为中文-无需申请定位权限
@param latitude 维度
@param longitude 经度
@returns 逆编码后对象 | static async geoConvert(latitude: number, longitude: number): Promise<geoLocationManager.GeoAddress> {
//校验是否逆编码可用
let isAvailable = geoLocationManager.isGeocoderAvailable();
if (isAvailable) {
let reverseGeocodeRequest: geoLocationManager.ReverseGeoCodeRequest = {
latitude: latitude,
... | AST#method_declaration#Left static async geoConvert AST#parameter_list#Left ( AST#parameter#Left latitude : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left longitude : AST#type_annotation#Left AST#primary_type#Left number AS... | static async geoConvert(latitude: number, longitude: number): Promise<geoLocationManager.GeoAddress> {
let isAvailable = geoLocationManager.isGeocoderAvailable();
if (isAvailable) {
let reverseGeocodeRequest: geoLocationManager.ReverseGeoCodeRequest = {
latitude: latitude,
longitude: ... | https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_ui/src/main/ets/ui/base/LocationUtil.ets#L100-L121 | e09f92763d8100b4faaf603242b181c07edfb77b | gitee |
zqaini002/YaoYaoLingXian.git | 5095b12cbeea524a87c42d0824b1702978843d39 | YaoYaoLingXian/entry/src/main/ets/model/CommonTypes.ets | arkts | 系统图标定义 | export class SystemSymbols {
static readonly Calendar: string = 'calendar';
static readonly Task: string = 'task';
static readonly Home: string = 'home';
static readonly User: string = 'user';
static readonly Add: string = 'add';
} | AST#export_declaration#Left export AST#class_declaration#Left class SystemSymbols AST#class_body#Left { AST#property_declaration#Left static readonly Calendar : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'calendar' AST#expression#Right ; ... | export class SystemSymbols {
static readonly Calendar: string = 'calendar';
static readonly Task: string = 'task';
static readonly Home: string = 'home';
static readonly User: string = 'user';
static readonly Add: string = 'add';
} | https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/model/CommonTypes.ets#L217-L223 | 97d2312c9d6819eecc8ac47714a42947afd8f550 | github | |
anhao0226/harmony-music-player.git | 4bc1d8f9f5fdb573af387d3ba9ad333c9beb8073 | entry/src/main/ets/api/SongApi.ets | arkts | fetchArtistDetail | export function fetchArtistDetail(artistId: number) {
const params = { id: artistId };
return new Promise<ArtistDetail | null>((resolve, reject) => {
httpRequestGet<ArtistDetailResponse>(AccessUrls.ArtistDetail,
{ queryParams: params }).then((res) => {
if (res.code === 200) {
resolve(res.dat... | AST#export_declaration#Left export AST#function_declaration#Left function fetchArtistDetail AST#parameter_list#Left ( AST#parameter#Left artistId : 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#Le... | export function fetchArtistDetail(artistId: number) {
const params = { id: artistId };
return new Promise<ArtistDetail | null>((resolve, reject) => {
httpRequestGet<ArtistDetailResponse>(AccessUrls.ArtistDetail,
{ queryParams: params }).then((res) => {
if (res.code === 200) {
resolve(res.dat... | https://github.com/anhao0226/harmony-music-player.git/blob/4bc1d8f9f5fdb573af387d3ba9ad333c9beb8073/entry/src/main/ets/api/SongApi.ets#L86-L101 | f30ad236b84c9f7c4dd7569bc3e76ad3cb62f6a1 | github | |
harmonyos_samples/BestPracticeSnippets | 490ea539a6d4427dd395f3dac3cf4887719f37af | SimpleChatList/entry/src/main/ets/pages/PullUpLoading.ets | arkts | PullUpLoading | 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, soft... | @Component
export struct PullUpLoading {
@State arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
@State isRefreshing: boolean = false;
@State refreshOffset: number = 0;
@State refreshState: RefreshStatus = RefreshStatus.Inactive;
@StorageProp('topRectHeight') topRectHeight: number = 0;
// [Start PullToRefre... | AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct PullUpLoading AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right arr : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#R... | @Component
export struct PullUpLoading {
@State arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
@State isRefreshing: boolean = false;
@State refreshOffset: number = 0;
@State refreshState: RefreshStatus = RefreshStatus.Inactive;
@StorageProp('topRectHeight') topRectHeight: number = 0;
@Builder
refresh... | https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/SimpleChatList/entry/src/main/ets/pages/PullUpLoading.ets#L16-L102 | 81e80d69d81ac7b47099c4c9dac00da53cc4d540 | gitee |
Application-Security-Automation/Arktan.git | 3ad9cb05235e38b00cd5828476aa59a345afa1c0 | dataset/completeness/function_call/argument_passing/argument_passing_004_F.ets | arkts | Introduction 参数传递-默认参数值 | export function argument_passing_002_F(taint_src : string) {
let _t = taint_src
let _clean = "clean"
f(_clean);
} | AST#export_declaration#Left export AST#function_declaration#Left function argument_passing_002_F AST#parameter_list#Left ( AST#parameter#Left taint_src : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statem... | export function argument_passing_002_F(taint_src : string) {
let _t = taint_src
let _clean = "clean"
f(_clean);
} | https://github.com/Application-Security-Automation/Arktan.git/blob/3ad9cb05235e38b00cd5828476aa59a345afa1c0/dataset/completeness/function_call/argument_passing/argument_passing_004_F.ets#L6-L10 | cbd318b1d8b3b28dcd557ade2bddebd40173c022 | github | |
harmonyos-cases/cases | eccdb71f1cee10fa6ff955e16c454c1b59d3ae13 | CommonAppDevelopment/feature/dynamicattributes/src/main/ets/common/AttributeModifier.ets | arkts | 自定义class实现Checkbox组件的AttributeModifier接口 | export class CheckboxModifier implements AttributeModifier<CheckboxAttribute> {
applyNormalAttribute(instance: CheckboxAttribute): void {
instance.selectedColor($r('app.color.dynamicattributes_selectColor'));
instance.width($r('app.float.dynamicattributes_float_15'));
instance.height($r('app.float.dynamic... | AST#export_declaration#Left export AST#class_declaration#Left class CheckboxModifier AST#implements_clause#Left implements AST#generic_type#Left AttributeModifier AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left CheckboxAttribute AST#primary_type#Right AST#type_annotation#Right > AST#type_argume... | export class CheckboxModifier implements AttributeModifier<CheckboxAttribute> {
applyNormalAttribute(instance: CheckboxAttribute): void {
instance.selectedColor($r('app.color.dynamicattributes_selectColor'));
instance.width($r('app.float.dynamicattributes_float_15'));
instance.height($r('app.float.dynamic... | https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/dynamicattributes/src/main/ets/common/AttributeModifier.ets#L109-L116 | 2aae3dfa0b59c67b7435ab1c7ea11c332d348d9c | gitee | |
openharmony/codelabs | d899f32a52b2ae0dfdbb86e34e8d94645b5d4090 | Data/Preferences/entry/src/main/ets/viewmodel/ButtonItemData.ets | arkts | The constructor of ButtonItemData.
@param resource Button item resource.
@param clickMethod Button item clickMethod. | constructor(resource: Resource, clickMethod: () => void) {
this.resource = resource;
this.clickMethod = clickMethod;
} | AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left resource : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left clickMethod : AST#type_annotation#Left AST#function_type#Left AST#paramet... | constructor(resource: Resource, clickMethod: () => void) {
this.resource = resource;
this.clickMethod = clickMethod;
} | https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Data/Preferences/entry/src/main/ets/viewmodel/ButtonItemData.ets#L40-L43 | 20057f5e9fe4be9093cd6f3a65e9af8a7cf99026 | gitee | |
BohanSu/LumosAgent-HarmonyOS.git | 9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76 | entry/src/main/ets/common/RdbHelper.ets | arkts | getMemos | Get all memos
@returns Array of Memo objects | async getMemos(): Promise<Memo[]> {
if (!this.rdbStore) {
throw new Error('Database not initialized');
}
const predicates = new relationalStore.RdbPredicates(Constants.TABLE_MEMOS);
predicates.orderByDesc('created_at');
try {
const resultSet = await this.rdbStore.query(predicates);
... | AST#method_declaration#Left async getMemos 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 Memo [ ] AST#array_type#Right AST#primary_type#Right... | async getMemos(): Promise<Memo[]> {
if (!this.rdbStore) {
throw new Error('Database not initialized');
}
const predicates = new relationalStore.RdbPredicates(Constants.TABLE_MEMOS);
predicates.orderByDesc('created_at');
try {
const resultSet = await this.rdbStore.query(predicates);
... | https://github.com/BohanSu/LumosAgent-HarmonyOS.git/blob/9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76/entry/src/main/ets/common/RdbHelper.ets#L349-L378 | 20f5f3ff3eae69c7477753243280c14b861b1e2b | github |
bigbear20240612/birthday_reminder.git | 647c411a6619affd42eb5d163ff18db4b34b27ff | entry/src/main/ets/services/settings/SettingsService.ets | arkts | getReminderSettings | 获取提醒设置
@returns 提醒设置 | async getReminderSettings(): Promise<ReminderSettings> {
const settings = await this.getSettings();
return settings.reminder;
} | AST#method_declaration#Left async getReminderSettings 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 ReminderSettings AST#primary_type#Right AST#type_annotation#R... | async getReminderSettings(): Promise<ReminderSettings> {
const settings = await this.getSettings();
return settings.reminder;
} | https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/settings/SettingsService.ets#L210-L213 | 17d04c0aa7f5c250468738a5226a4f00705435e9 | github |
Application-Security-Automation/Arktan.git | 3ad9cb05235e38b00cd5828476aa59a345afa1c0 | dataset/completeness/exception_throw/exception_finally_002_F.ets | arkts | Introduction 异常抛出-finally块 | export function exception_finally_002_F(taint_src : string) {
try {}
catch (e) {}
finally {
let _t = taint_src;
let clean = "_";
taint.Sink(clean);
}
} | AST#export_declaration#Left export AST#function_declaration#Left function exception_finally_002_F AST#parameter_list#Left ( AST#parameter#Left taint_src : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_state... | export function exception_finally_002_F(taint_src : string) {
try {}
catch (e) {}
finally {
let _t = taint_src;
let clean = "_";
taint.Sink(clean);
}
} | https://github.com/Application-Security-Automation/Arktan.git/blob/3ad9cb05235e38b00cd5828476aa59a345afa1c0/dataset/completeness/exception_throw/exception_finally_002_F.ets#L6-L14 | 14fc51bef366871289b71b50f694190cd811daf5 | github | |
bigbear20240612/birthday_reminder.git | 647c411a6619affd42eb5d163ff18db4b34b27ff | entry/src/main/ets/services/media/MediaManager.ets | arkts | cleanup | 清理资源 | async cleanup(): Promise<void> {
try {
// 停止录音
if (this.audioRecorder) {
await this.audioRecorder.release();
this.audioRecorder = null;
}
// 停止录像
if (this.videoRecorder) {
await this.videoRecorder.release();
this.videoRecorder = null;
}
// ... | AST#method_declaration#Left async cleanup 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_argument... | async cleanup(): Promise<void> {
try {
if (this.audioRecorder) {
await this.audioRecorder.release();
this.audioRecorder = null;
}
if (this.videoRecorder) {
await this.videoRecorder.release();
this.videoRecorder = null;
}
if (this.i... | https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/media/MediaManager.ets#L715-L739 | 06aa1474a3b0c25830f2fc1910497bd742c720ef | github |
bigbear20240612/birthday_reminder.git | 647c411a6619affd42eb5d163ff18db4b34b27ff | entry/src/main/ets/common/data/FestivalData2025.ets | arkts | isLegalHoliday | 判断指定日期是否为法定节假日
优化版本:使用缓存提升查询性能 | public static isLegalHoliday(year: number, month: number, day: number): boolean {
const cacheKey = `legal-${year}-${month}-${day}`;
// 检查缓存
if (FestivalData2025.legalHolidayCache.has(cacheKey)) {
return FestivalData2025.legalHolidayCache.get(cacheKey)!;
}
// 计算是否为法定节假日
const fest... | AST#method_declaration#Left public static isLegalHoliday AST#parameter_list#Left ( AST#parameter#Left year : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left month : AST#type_annotation#Left AST#primary_type#Left number AST#p... | public static isLegalHoliday(year: number, month: number, day: number): boolean {
const cacheKey = `legal-${year}-${month}-${day}`;
if (FestivalData2025.legalHolidayCache.has(cacheKey)) {
return FestivalData2025.legalHolidayCache.get(cacheKey)!;
}
const festivals = FestivalData... | https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/data/FestivalData2025.ets#L282-L303 | c172e2e7dbfbfa0e87571baf7317cf84cf02ecf3 | github |
harmonyos/samples | f5d967efaa7666550ee3252d118c3c73a77686f5 | HarmonyOS_NEXT/DeviceManagement/DeviceManagementCollection/feature/menuitems/src/main/ets/components/ItemGroup.ets | arkts | ItemGroup | 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, soft... | @Component
export struct ItemGroup {
@BuilderParam noParam: () => void;
build() {
Column() {
this.noParam();
}
.width('100%')
.borderRadius(20)
.backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
.margin({ bottom: 12 })
}
} | AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ItemGroup AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ BuilderParam AST#decorator#Right noParam : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#paramet... | @Component
export struct ItemGroup {
@BuilderParam noParam: () => void;
build() {
Column() {
this.noParam();
}
.width('100%')
.borderRadius(20)
.backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
.margin({ bottom: 12 })
}
} | https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/HarmonyOS_NEXT/DeviceManagement/DeviceManagementCollection/feature/menuitems/src/main/ets/components/ItemGroup.ets#L16-L29 | f6b56fbb437e3282730bbe07a0057cf59c5c6b7d | gitee |
bigbear20240612/birthday_reminder.git | 647c411a6619affd42eb5d163ff18db4b34b27ff | entry/src/main/ets/services/ai/ModelConfigService.ets | arkts | getCurrentConfig | 获取当前配置 | public getCurrentConfig(): ModelConfig | null {
return this.currentConfig;
} | AST#method_declaration#Left public getCurrentConfig AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ModelConfig AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_st... | public getCurrentConfig(): ModelConfig | null {
return this.currentConfig;
} | https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/ai/ModelConfigService.ets#L329-L331 | 05a0f05564eded8f967af562d7315b78e77c4f6a | github |
Joker-x-dev/CoolMallArkTS.git | 9f3fabf89fb277692cb82daf734c220c7282919c | feature/user/src/main/ets/viewmodel/AddressDetailViewModel.ets | arkts | onRequestSuccess | 请求成功回调,回填表单数据
@param {Address} data - 地址数据
@returns {void} 无返回值 | protected onRequestSuccess(data: Address): void {
this.updateFormData(new Address(data));
super.onRequestSuccess(data);
} | AST#method_declaration#Left protected onRequestSuccess AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left Address 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#prim... | protected onRequestSuccess(data: Address): void {
this.updateFormData(new Address(data));
super.onRequestSuccess(data);
} | https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/user/src/main/ets/viewmodel/AddressDetailViewModel.ets#L277-L280 | 8376f25e0d9cda96fcd7a13decf36909df72a1ae | github |
sedlei/Smart-park-system.git | 253228f73e419e92fd83777f564889d202f7c699 | @huaweicloud/iot-device-sdk/src/main/ets/client/listener/CommandListener.d.ets | arkts | 命令监听器,用于接收平台下发的命令 | export interface CommandListener {
/**
* 命令处理
*
* @param requestId 请求id
* @param serviceId 服务id
* @param commandName 命令名
* @param paras 命令参数
*/
onCommand: (requestId: string, serviceId: string, commandName: string, paras: object) => void;
} | AST#export_declaration#Left export AST#interface_declaration#Left interface CommandListener AST#object_type#Left { /**
* 命令处理
*
* @param requestId 请求id
* @param serviceId 服务id
* @param commandName 命令名
* @param paras 命令参数
*/ AST#type_member#Left onCommand : AST#type_annotatio... | export interface CommandListener {
onCommand: (requestId: string, serviceId: string, commandName: string, paras: object) => void;
} | https://github.com/sedlei/Smart-park-system.git/blob/253228f73e419e92fd83777f564889d202f7c699/@huaweicloud/iot-device-sdk/src/main/ets/client/listener/CommandListener.d.ets#L4-L14 | 23a1066f0b4847dda125f99749aaccc50934f349 | github | |
harmonyos-cases/cases | eccdb71f1cee10fa6ff955e16c454c1b59d3ae13 | CommonAppDevelopment/feature/bluetooth/src/main/ets/pages/BluetoothClient.ets | arkts | onPageShow | 当前页面可见时恢复竖屏显示 | async onPageShow(): Promise<void> {
Log.showInfo(TAG, `BluetoothView onPageShow`);
await globalThis.setOrientation(window.Orientation.UNSPECIFIED);
} | AST#method_declaration#Left async onPageShow 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_argum... | async onPageShow(): Promise<void> {
Log.showInfo(TAG, `BluetoothView onPageShow`);
await globalThis.setOrientation(window.Orientation.UNSPECIFIED);
} | https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/bluetooth/src/main/ets/pages/BluetoothClient.ets#L85-L88 | 4d647a9fc8bbb5d0ac0b215a78e4cdad62c79d2c | gitee |
openharmony/applications_app_samples | a826ab0e75fe51d028c1c5af58188e908736b53b | code/UI/ImageViewer/entry/src/main/ets/utils/Constrain.ets | arkts | 查询当前是尺寸 | export function getImgSize(imageSize: image.Size, rotate: number,
dimensionWH: ImageFitType.TYPE_WIDTH | ImageFitType.TYPE_HEIGHT): number {
const isStandardRotation: boolean = [90, 270].includes(Math.abs(rotate % 360));
const key: ImageFitType.TYPE_WIDTH | ImageFitType.TYPE_HEIGHT =
isStandardRotation ? (dim... | AST#export_declaration#Left export AST#function_declaration#Left function getImgSize AST#parameter_list#Left ( AST#parameter#Left imageSize : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left image . Size AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ... | export function getImgSize(imageSize: image.Size, rotate: number,
dimensionWH: ImageFitType.TYPE_WIDTH | ImageFitType.TYPE_HEIGHT): number {
const isStandardRotation: boolean = [90, 270].includes(Math.abs(rotate % 360));
const key: ImageFitType.TYPE_WIDTH | ImageFitType.TYPE_HEIGHT =
isStandardRotation ? (dim... | https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/UI/ImageViewer/entry/src/main/ets/utils/Constrain.ets#L103-L110 | 0957157a0e11121b5acc10b5d8edda2e1e642d67 | gitee | |
openharmony/applications_app_samples | a826ab0e75fe51d028c1c5af58188e908736b53b | code/Solutions/IM/Chat/products/phone/entry/src/main/ets/pages/FriendsPage.ets | arkts | FriendsPage | 通讯录页面组件 | @Preview
@Component
export struct FriendsPage {
@State friendsListLength: number = 0;
private friendsListData: FriendListData = new FriendListData();
private friendsPageItem: FriendsPageItemType[] = [
{ image: $r('app.media.new_friend'), text: $r('app.string.new_friend') },
{ image: $r('app.media.group'),... | AST#decorated_export_declaration#Left AST#decorator#Left @ Preview AST#decorator#Right AST#decorator#Left @ Component AST#decorator#Right export struct FriendsPage AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right friendsListLength : AST#type_annotation#Left AST#prim... | @Preview
@Component
export struct FriendsPage {
@State friendsListLength: number = 0;
private friendsListData: FriendListData = new FriendListData();
private friendsPageItem: FriendsPageItemType[] = [
{ image: $r('app.media.new_friend'), text: $r('app.string.new_friend') },
{ image: $r('app.media.group'),... | https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Solutions/IM/Chat/products/phone/entry/src/main/ets/pages/FriendsPage.ets#L43-L163 | e40af1bedab39305efc2dd0f54ad4200ab03a7d6 | gitee |
openharmony/applications_app_samples | a826ab0e75fe51d028c1c5af58188e908736b53b | code/SystemFeature/ApplicationModels/Launcher/desktop/src/main/ets/default/model/DesktopLayoutModel.ets | arkts | getAppName | getAppName
@param cacheKey | getAppName(cacheKey: string): string {
return ResourceManager.getInstance(this.context).getAppResourceCache(cacheKey, KEY_NAME);
} | AST#method_declaration#Left getAppName AST#parameter_list#Left ( AST#parameter#Left cacheKey : 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#Ri... | getAppName(cacheKey: string): string {
return ResourceManager.getInstance(this.context).getAppResourceCache(cacheKey, KEY_NAME);
} | https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/ApplicationModels/Launcher/desktop/src/main/ets/default/model/DesktopLayoutModel.ets#L176-L178 | b5aea51de8030be34d1a38bec738f806b4274f64 | gitee |
harmonyos-cases/cases | eccdb71f1cee10fa6ff955e16c454c1b59d3ae13 | CommonAppDevelopment/feature/containernestedslide/src/main/ets/view/NewsDetailPage.ets | arkts | publishComment | 发布评论 | publishComment(): void {
// 生成评论id
const uuid: string = util.generateRandomUUID();
// 添加一条评论,包含评论id、头像、昵称、回复id、回复昵称、回复文本
const comment: NewsCommentModel =
new NewsCommentModel(uuid, $r('app.media.news_user_select'), this.curUser, this.replyId, this.replyUser,
this.textInComment, new Date()... | AST#method_declaration#Left publishComment 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 { // 生成评论id AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left ... | publishComment(): void {
const uuid: string = util.generateRandomUUID();
const comment: NewsCommentModel =
new NewsCommentModel(uuid, $r('app.media.news_user_select'), this.curUser, this.replyId, this.replyUser,
this.textInComment, new Date(), new NewsCommentData());
const paren... | https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/containernestedslide/src/main/ets/view/NewsDetailPage.ets#L124-L145 | a0af900f1fd746a1a7473fe589bae722f6e87595 | gitee |
bigbear20240612/birthday_reminder.git | 647c411a6619affd42eb5d163ff18db4b34b27ff | entry/src/main/ets/pages/SimpleBirthdayApp.ets | arkts | buildStatCard | 构建统计卡片 | @Builder
buildStatCard(icon: string, count: string, label: string, color: string) {
Column({ space: 8 }) {
Text(icon)
.fontSize(32)
Text(count)
.fontSize(24)
.fontWeight(FontWeight.Bold)
.fontColor(color)
Text(label)
.fontSize(12)
.fontColor('#66... | AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildStatCard AST#parameter_list#Left ( AST#parameter#Left icon : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left count : AST#type_annotation#Left ... | @Builder
buildStatCard(icon: string, count: string, label: string, color: string) {
Column({ space: 8 }) {
Text(icon)
.fontSize(32)
Text(count)
.fontSize(24)
.fontWeight(FontWeight.Bold)
.fontColor(color)
Text(label)
.fontSize(12)
.fontColor('#66... | https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/SimpleBirthdayApp.ets#L512-L532 | c2dd55f5e1f8d99dbec9cfa0bff3016a50868a5d | github |
Joker-x-dev/CoolMallArkTS.git | 9f3fabf89fb277692cb82daf734c220c7282919c | feature/order/src/main/ets/view/OrderLogisticsPage.ets | arkts | LogisticsPhoneValue | 物流联系电话展示区域
@param {Logistics} logistics - 物流信息
@returns {void} 无返回值 | @Builder
private LogisticsPhoneValue(logistics: Logistics): void {
RowStartCenter() {
Text(logistics.courierPhone ?? $r("app.string.none"))
.fontSize($r("app.float.body_medium"))
.fontColor($r("app.color.text_secondary"));
SpaceHorizontalSmall();
Text($r("app.string.call"))
... | AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right private LogisticsPhoneValue AST#parameter_list#Left ( AST#parameter#Left logistics : AST#type_annotation#Left AST#primary_type#Left Logistics AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST... | @Builder
private LogisticsPhoneValue(logistics: Logistics): void {
RowStartCenter() {
Text(logistics.courierPhone ?? $r("app.string.none"))
.fontSize($r("app.float.body_medium"))
.fontColor($r("app.color.text_secondary"));
SpaceHorizontalSmall();
Text($r("app.string.call"))
... | https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/order/src/main/ets/view/OrderLogisticsPage.ets#L208-L223 | 7b2e33faa2ea1d558c1c4e894a76d4f5ed3968ae | github |
openharmony/codelabs | d899f32a52b2ae0dfdbb86e34e8d94645b5d4090 | CommonEventAndNotification/AlarmClock/entry/src/main/ets/model/database/PreferencesHandler.ets | arkts | set | Set data in PreferencesHandler.
@param key string
@param value any | public async set(key: string, value: string) {
if (this.preferences != null) {
await this.preferences.put(key, value);
await this.preferences.flush();
}
} | AST#method_declaration#Left public async set AST#parameter_list#Left ( AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#R... | public async set(key: string, value: string) {
if (this.preferences != null) {
await this.preferences.put(key, value);
await this.preferences.flush();
}
} | https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/CommonEventAndNotification/AlarmClock/entry/src/main/ets/model/database/PreferencesHandler.ets#L65-L70 | 5f41713246537ff45eb293903154c8b169f78098 | gitee |
EL233/WeChat-HarmonyOS.git | b5fa65556eb5f5698a92ec289ffd9ebe4cc5bb3e | entry/src/main/ets/http/Api.ets | arkts | 获取全部打卡列表 | export function getAllPost(page: number, size: number) {
return instance.get('/word/post/getAll', { params: { page: page, size: size } })
} | AST#export_declaration#Left export AST#function_declaration#Left function getAllPost AST#parameter_list#Left ( AST#parameter#Left page : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left size : AST#type_annotation#Left AST#pri... | export function getAllPost(page: number, size: number) {
return instance.get('/word/post/getAll', { params: { page: page, size: size } })
} | https://github.com/EL233/WeChat-HarmonyOS.git/blob/b5fa65556eb5f5698a92ec289ffd9ebe4cc5bb3e/entry/src/main/ets/http/Api.ets#L32-L34 | 2fd0c0908e28bfc06f17785fd0a3de2ad86161d9 | github | |
openharmony/xts_acts | 5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686 | arkui/ace_ets_module_ui/ace_ets_module_scroll/ace_ets_module_scroll_api15/entry/src/main/ets/MainAbility/pages/data/BasicDataSource.ets | arkts | notifyDataChange | 通知LazyForEach组件在index对应索引处数据有变化,需要重建该子组件 | notifyDataChange(index: number): void {
this.listeners.forEach(listener => {
listener.onDataChange(index);
// 写法2:listener.onDatasetChange([{type: DataOperationType.CHANGE, index: index}]);
})
} | AST#method_declaration#Left notifyDataChange 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#R... | notifyDataChange(index: number): void {
this.listeners.forEach(listener => {
listener.onDataChange(index);
})
} | https://github.com/openharmony/xts_acts/blob/5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686/arkui/ace_ets_module_ui/ace_ets_module_scroll/ace_ets_module_scroll_api15/entry/src/main/ets/MainAbility/pages/data/BasicDataSource.ets#L61-L66 | d4b2d2741d081fa6f416fd1317c821d80c4e2d0b | gitee |
openharmony-tpc/ohos_mpchart | 4fb43a7137320ef2fee2634598f53d93975dfb4a | library/src/main/ets/components/charts/ScatterChartModel.ets | arkts | The ScatterChart. Draws dots, triangles, squares and custom shapes into the
Chart-View. CIRCLE and SCQUARE offer the best performance, TRIANGLE has the
worst performance. | @ObservedV2
export default class ScatterChartModel extends BarLineChartBaseModel<ScatterData> implements ScatterDataProvider {
// ScatterData() {
// throw new Error('Method not implemented.');
// }
constructor() {
super();
this.init();
}
public onChartSizeChanged(newWidth: number, newHeight: num... | AST#decorated_export_declaration#Left AST#decorator#Left @ ObservedV2 AST#decorator#Right export default AST#class_declaration#Left class ScatterChartModel extends AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left BarLineChartBaseModel AST#type_arguments#Left < AST#type_annotation#Left AST#primary_ty... | @ObservedV2
export default class ScatterChartModel extends BarLineChartBaseModel<ScatterData> implements ScatterDataProvider {
constructor() {
super();
this.init();
}
public onChartSizeChanged(newWidth: number, newHeight: number, oldWidth: number, oldHeight: number) {
super.onSizeChanged(ne... | https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/charts/ScatterChartModel.ets#L27-L85 | f0dc95de39d9d13711e864d5a9457feac6f6c926 | gitee | |
harmonyos_samples/BestPracticeSnippets | 490ea539a6d4427dd395f3dac3cf4887719f37af | UseSendable/entry/src/main/ets/pages/ConcurrencyCapabilitySelection2.ets | arkts | ConcurrencyCapabilitySelection2 | [End execute_taskpool] | @Component
export struct ConcurrencyCapabilitySelection2 {
@Styles
buttonStyles() {
.width('100%')
.height(40)
}
build() {
NavDestination() {
Column() {
Button($r('app.string.long_term_task_title'))
.buttonStyles()
.margin({
bottom: 16
})
... | AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ConcurrencyCapabilitySelection2 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_functi... | @Component
export struct ConcurrencyCapabilitySelection2 {
@Styles
buttonStyles() {
.width('100%')
.height(40)
}
build() {
NavDestination() {
Column() {
Button($r('app.string.long_term_task_title'))
.buttonStyles()
.margin({
bottom: 16
})
... | https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/UseSendable/entry/src/main/ets/pages/ConcurrencyCapabilitySelection2.ets#L53-L84 | 78b77b667dca3077ace02aab5e938d40183d33cf | gitee |
MUYS/imagePreview | 96212a51e8c5d6c37b9b9fb94e7d6d76047cdeb0 | library/src/main/ets/image_preview/ImagePreview.ets | arkts | ImagePreview | 日期:2025/6/7 | @ComponentV2
export struct ImagePreview {
@Param config?: ImagePreviewConfig = undefined
@BuilderParam imageBuilder: CustomBuilder
private readonly state: ImagePreviewState = new ImagePreviewState(this.config)
private readonly viewModel: ImagePreviewViewModel = new ImagePreviewViewModel(this.state)
build() {... | AST#decorated_export_declaration#Left AST#decorator#Left @ ComponentV2 AST#decorator#Right export struct ImagePreview AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right config ? : AST#type_annotation#Left AST#primary_type#Left ImagePreviewConfig AST#primary_type#Right... | @ComponentV2
export struct ImagePreview {
@Param config?: ImagePreviewConfig = undefined
@BuilderParam imageBuilder: CustomBuilder
private readonly state: ImagePreviewState = new ImagePreviewState(this.config)
private readonly viewModel: ImagePreviewViewModel = new ImagePreviewViewModel(this.state)
build() {... | https://github.com/MUYS/imagePreview/blob/96212a51e8c5d6c37b9b9fb94e7d6d76047cdeb0/library/src/main/ets/image_preview/ImagePreview.ets#L14-L76 | abe8a658c46b78550fced3bdf7a51024237df22e | gitee |
openharmony/applications_app_samples | a826ab0e75fe51d028c1c5af58188e908736b53b | code/UI/ArkTsComponentCollection/ComponentCollection/RouterModule/index.ets | arkts | RouterModule | 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 l... | export { RouterModule } from './src/main/ets/utils/RouterModule'; | AST#export_declaration#Left export { RouterModule } from './src/main/ets/utils/RouterModule' ; AST#export_declaration#Right | export { RouterModule } from './src/main/ets/utils/RouterModule'; | https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/UI/ArkTsComponentCollection/ComponentCollection/RouterModule/index.ets#L16-L16 | b4aac06f847076cea8dca05c0d5783df26a5ba16 | gitee |
harmonyos-cases/cases | eccdb71f1cee10fa6ff955e16c454c1b59d3ae13 | CommonAppDevelopment/feature/imagecompression/src/main/ets/view/ImageCompression.ets | arkts | afterCompressChange | 压缩后图片大小,仅用于自动化用例验证 | afterCompressChange() {
emitter.emit('ImageCompression0', {
data: {
afterCompressionSize: this.afterCompressionSize
}
});
} | AST#method_declaration#Left afterCompressChange 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 emitter AST#expression#Right . emit AST#memb... | afterCompressChange() {
emitter.emit('ImageCompression0', {
data: {
afterCompressionSize: this.afterCompressionSize
}
});
} | https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/imagecompression/src/main/ets/view/ImageCompression.ets#L113-L119 | 41c9bbb922a4b1a241885f64b575047a66041cda | gitee |
bigbear20240612/birthday_reminder.git | 647c411a6619affd42eb5d163ff18db4b34b27ff | harmonyos/src/main/ets/pages/contacts/ContactDetailPage.ets | arkts | buildInfoItem | 构建信息项 | @Builder
buildInfoItem(label: string, value: string) {
Row() {
Text(label)
.fontSize(14)
.fontColor('#666666')
.width(60)
Text(value)
.fontSize(14)
.fontColor('#333333')
.layoutWeight(1)
}
.width('100%')
.alignItems(VerticalAlign.Cente... | AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildInfoItem AST#parameter_list#Left ( AST#parameter#Left label : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left value : AST#type_annotation#Left... | @Builder
buildInfoItem(label: string, value: string) {
Row() {
Text(label)
.fontSize(14)
.fontColor('#666666')
.width(60)
Text(value)
.fontSize(14)
.fontColor('#333333')
.layoutWeight(1)
}
.width('100%')
.alignItems(VerticalAlign.Cente... | https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/pages/contacts/ContactDetailPage.ets#L473-L488 | ade0607672e8494094f3b6b7fb4863bcfede397a | github |
awa_Liny/LinysBrowser_NEXT | a5cd96a9aa8114cae4972937f94a8967e55d4a10 | home/src/main/ets/hosts/bunch_of_tabs.ets | arkts | update_web_state | Calls the specific tab to sync web_state to bunch_of_tabs.
@param index The index of tab.
@param force Set to true if want to ignore frequency limit. | update_web_state(index: number, force: boolean): boolean {
return this.Tabs[index].update_web_state(force);
} | AST#method_declaration#Left update_web_state AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left force : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_typ... | update_web_state(index: number, force: boolean): boolean {
return this.Tabs[index].update_web_state(force);
} | https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/hosts/bunch_of_tabs.ets#L219-L221 | 0fbf3cebd77d6dae9aa1c97c38a72b981ed86ecf | gitee |
ericple/ohos-weather | f197791bce462c5eb1b22945c25f5bcd5fcc9f7c | libNMC/src/main/ets/Data/WeatherRealTime.ets | arkts | This file is part of libNMC, which is the foundation of ohos-weather. Copyright (C) 2023 Tingjin<dev@peercat.cn> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (... | export interface WeatherRealTime {
obsTime: string;
temp: string;
feelsLike: string;
icon: string;
text: string;
wind360: string;
windDir: string;
windSpeed: string;
humidity: string;
precip: string;
pressure: string;
vis: string;
cloud: string;
dew: string;
} | AST#export_declaration#Left export AST#interface_declaration#Left interface WeatherRealTime AST#object_type#Left { AST#type_member#Left obsTime : 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 temp : AST#type_annotation... | export interface WeatherRealTime {
obsTime: string;
temp: string;
feelsLike: string;
icon: string;
text: string;
wind360: string;
windDir: string;
windSpeed: string;
humidity: string;
precip: string;
pressure: string;
vis: string;
cloud: string;
dew: string;
} | https://github.com/ericple/ohos-weather/blob/f197791bce462c5eb1b22945c25f5bcd5fcc9f7c/libNMC/src/main/ets/Data/WeatherRealTime.ets#L16-L31 | 020f748c3ecef74fa8f3b4d1264a5b6b63f5a06c | gitee | |
bigbear20240612/birthday_reminder.git | 647c411a6619affd42eb5d163ff18db4b34b27ff | entry/src/main/ets/common/utils/DateUtils.ets | arkts | getStartOfWeek | 获取本周开始日期(周一)
@param date 基准日期,默认为今天
@returns 本周开始日期 | static getStartOfWeek(date: Date = new Date()): Date {
const startOfWeek = new Date(date);
const day = startOfWeek.getDay();
const diff = startOfWeek.getDate() - day + (day === 0 ? -6 : 1);
startOfWeek.setDate(diff);
startOfWeek.setHours(0, 0, 0, 0);
return startOfWeek;
} | AST#method_declaration#Left static getStartOfWeek AST#parameter_list#Left ( AST#parameter#Left date : AST#type_annotation#Left AST#primary_type#Left Date AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Da... | static getStartOfWeek(date: Date = new Date()): Date {
const startOfWeek = new Date(date);
const day = startOfWeek.getDay();
const diff = startOfWeek.getDate() - day + (day === 0 ? -6 : 1);
startOfWeek.setDate(diff);
startOfWeek.setHours(0, 0, 0, 0);
return startOfWeek;
} | https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/utils/DateUtils.ets#L148-L155 | 5cb2a1227f28520863c4d677781e01650fa8fee1 | github |
KoStudio/ArkTS-WordTree.git | 78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324 | entry/src/main/ets/models/datas/basedict/utils/StringDealUtilityForBaseWord.ets | arkts | matchRegex | /匹配正则表达式 | static matchRegex(srcStr: string | null, reg: string): Array<string> {
const list: Array<string> = [];
if (srcStr !== null) {
const pattern = new RegExp(reg, "g");
const matches = srcStr.matchAll(pattern);
for (const m of matches) {
if (m.index !== undefined) {
const text =... | AST#method_declaration#Left static matchRegex AST#parameter_list#Left ( AST#parameter#Left srcStr : 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 , AS... | static matchRegex(srcStr: string | null, reg: string): Array<string> {
const list: Array<string> = [];
if (srcStr !== null) {
const pattern = new RegExp(reg, "g");
const matches = srcStr.matchAll(pattern);
for (const m of matches) {
if (m.index !== undefined) {
const text =... | https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/datas/basedict/utils/StringDealUtilityForBaseWord.ets#L19-L35 | 22623bc9224ec7f40232e48c623d5515dbf1118d | github |
harmonyos_samples/BestPracticeSnippets | 490ea539a6d4427dd395f3dac3cf4887719f37af | DealStrideSolution/entry/src/main/ets/utils/CameraServiceTwo.ets | arkts | releaseCamera | Release the session and related parameters | async releaseCamera(): Promise<void> {
Logger.info(TAG, 'releaseCamera is called');
try {
await this.receiver?.release();
} catch (err) {
Logger.error(TAG, `imageReceiver release fail: error: ${JSON.stringify(err)}`);
}
try {
await this.previewOutput?.release();
} catch (err) {... | AST#method_declaration#Left async releaseCamera 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_ar... | async releaseCamera(): Promise<void> {
Logger.info(TAG, 'releaseCamera is called');
try {
await this.receiver?.release();
} catch (err) {
Logger.error(TAG, `imageReceiver release fail: error: ${JSON.stringify(err)}`);
}
try {
await this.previewOutput?.release();
} catch (err) {... | https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/DealStrideSolution/entry/src/main/ets/utils/CameraServiceTwo.ets#L196-L225 | 017f5718a8fe3511ccbb54a18f4c3ed69befc06e | gitee |
didi/dimina.git | 7ad9d89af58cd54e624b2e3d3eb14801cc8e05d2 | harmony/dimina/src/main/ets/Service/DMPChannelProxyNext.ets | arkts | ServiceToRenderWithAppIndex | 不再解析直接透传 | public static ServiceToRenderWithAppIndex(dataString: string, webViewId: number, appIndex: number) {
// DMPLogger.d(Tags.BRIDGE, `ServiceToRenderWithAppIndex ${dataString} `);
const app = DMPAppManager.sharedInstance().getApp(appIndex);
if (app) {
app.render.fromServiceNext(dataString, webViewId);
... | AST#method_declaration#Left public static ServiceToRenderWithAppIndex AST#parameter_list#Left ( AST#parameter#Left dataString : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left webViewId : AST#type_annotation#Left AST#primary... | public static ServiceToRenderWithAppIndex(dataString: string, webViewId: number, appIndex: number) {
const app = DMPAppManager.sharedInstance().getApp(appIndex);
if (app) {
app.render.fromServiceNext(dataString, webViewId);
} else {
DMPLogger.d(Tags.BRIDGE, `ServiceToRender消息失效, appIndex:${... | https://github.com/didi/dimina.git/blob/7ad9d89af58cd54e624b2e3d3eb14801cc8e05d2/harmony/dimina/src/main/ets/Service/DMPChannelProxyNext.ets#L131-L140 | f36a26db93712759a41e915c8ddf296e0a6fde6f | github |
tongyuyan/harmony-utils | 697472f011a43e783eeefaa28ef9d713c4171726 | harmony_web/src/main/ets/utils/Tools.ets | arkts | toAppSetting | 跳转应用设置页面 | static async toAppSetting(): Promise<void> {
const URI_APPLICATION_INFO: string = 'application_info_entry' //应用和元服务-某个具体应用的应用信息,需传递want.parameters.pushParams为具体应用的包名
return Tools.toSetting(URI_APPLICATION_INFO);
} | AST#method_declaration#Left static async toAppSetting 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#t... | static async toAppSetting(): Promise<void> {
const URI_APPLICATION_INFO: string = 'application_info_entry'
return Tools.toSetting(URI_APPLICATION_INFO);
} | https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_web/src/main/ets/utils/Tools.ets#L77-L80 | 7196c3731bf26a0aade7b98578672df0916e0c21 | gitee |
fmtjava/Ohs_ArkTs_Eyepetizer.git | 79578f394ccb926da1455e63b7fe0722df9b9a22 | entry/src/main/ets/pages/CategoryDetailPage.ets | arkts | restoreOriginalSettings | 恢复原始设置 | private async restoreOriginalSettings() {
// 1. 获取当前窗口
window.getLastWindow(this.getUIContext().getHostContext(), async (err: BusinessError, win: window.Window) => {
try {
if (err.code) {
console.error(`获取窗口失败:${err.message}`);
return;
}
// 2.恢复状态栏原始设置
a... | AST#method_declaration#Left private async restoreOriginalSettings AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { // 1. 获取当前窗口 AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#ex... | private async restoreOriginalSettings() {
window.getLastWindow(this.getUIContext().getHostContext(), async (err: BusinessError, win: window.Window) => {
try {
if (err.code) {
console.error(`获取窗口失败:${err.message}`);
return;
}
await win.setWindowLayoutFu... | https://github.com/fmtjava/Ohs_ArkTs_Eyepetizer.git/blob/79578f394ccb926da1455e63b7fe0722df9b9a22/entry/src/main/ets/pages/CategoryDetailPage.ets#L75-L92 | c29aa850d85d5ebec080c9be5e35bb7a79a24f7c | github |
openharmony/interface_sdk-js | c349adc73e2ec1f61f6fca489b5af059e3ed6999 | api/@ohos.deviceInfo.d.ets | arkts | get | Obtains the product series represented by a string.
@syscap SystemCapability.Startup.SystemInfo
@crossplatform
@since 20
@arkts 1.2 | static get productSeries(): string; | AST#method_declaration#Left static get AST#ERROR#Left productSeries AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right | static get productSeries(): string; | https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.deviceInfo.d.ets#L87-L87 | a122aed2e4eb24656f071a4e11dfbac94ad4b8d4 | gitee |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.