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
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/utils/JList.ets
arkts
Copyright (C) 2022 Huawei Device Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, soft...
export class JList<T> { dataSource: Array<T>; listSize: number; // 列表的大小 pos: number; // 列表中当前的位置 constructor() { this.dataSource = []; this.listSize = 0; // 列表的大小 this.pos = 0; // 列表中当前的位置 } /** * 在列表的末尾添加新元素 * @param {*} element 要添加的元素 */ append(element: T): void { this.dataS...
AST#export_declaration#Left export AST#class_declaration#Left class JList AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#class_body#Left { AST#property_declaration#Left dataSource : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array ...
export class JList<T> { dataSource: Array<T>; listSize: number; pos: number; constructor() { this.dataSource = []; this.listSize = 0; this.pos = 0; } append(element: T): void { this.dataSource[this.listSize++] = element; }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/utils/JList.ets#L16-L34
fdb1ec759553fa41fe3c5d712a5fbcf8133b251f
gitee
zl3624/harmonyos_network_samples
b8664f8bf6ef5c5a60830fe616c6807e83c21f96
code/http/HttpsRequestDemo/entry/src/main/ets/pages/Index.ets
arkts
doHttpRequest
发起http请求
doHttpRequest() { //http请求对象 let httpRequest = http.createHttp(); let opt: http.HttpRequestOptions = { method: http.RequestMethod.GET, expectDataType: http.HttpDataType.STRING } if (this.certVerifyType == 1) { this.copyCaFile2Sandisk() opt.caPath = this.caFileSandPath }...
AST#method_declaration#Left doHttpRequest AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { //http请求对象 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left httpRequest = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left...
doHttpRequest() { let httpRequest = http.createHttp(); let opt: http.HttpRequestOptions = { method: http.RequestMethod.GET, expectDataType: http.HttpDataType.STRING } if (this.certVerifyType == 1) { this.copyCaFile2Sandisk() opt.caPath = this.caFileSandPath } http...
https://github.com/zl3624/harmonyos_network_samples/blob/b8664f8bf6ef5c5a60830fe616c6807e83c21f96/code/http/HttpsRequestDemo/entry/src/main/ets/pages/Index.ets#L151-L173
ffeef0e7b500cca7efc804914d6d27a1a513ada3
gitee
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto_dto/src/main/ets/crypto/encryption/AESSync.ets
arkts
decodeECB
解密-ECB模式 @param str 加密的字符串 @param aesKey AES密钥 @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式 @param dataCoding 入参字符串编码方式(hex/base64) - 不传默认为base64 @returns
static decodeECB(str: string, aesKey: string, keyCoding: buffer.BufferEncoding, dataCoding: buffer.BufferEncoding = 'base64'): OutDTO<string> { return CryptoSyncUtil.decodeECB(str, aesKey, 'AES256', 'AES256|ECB|PKCS7', 256, keyCoding, dataCoding); }
AST#method_declaration#Left static decodeECB AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left aesKey : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#...
static decodeECB(str: string, aesKey: string, keyCoding: buffer.BufferEncoding, dataCoding: buffer.BufferEncoding = 'base64'): OutDTO<string> { return CryptoSyncUtil.decodeECB(str, aesKey, 'AES256', 'AES256|ECB|PKCS7', 256, keyCoding, dataCoding); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto_dto/src/main/ets/crypto/encryption/AESSync.ets#L273-L276
1fb8688dc11ee7ec21ebd9e7cff26c4d0aedda50
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/calendar/LunarCalendar.ets
arkts
getLunarYearDays
获取农历年的总天数
private getLunarYearDays(year: number): number { if (year < 1900 || year > 2100) return 365; const yearInfo = this.lunarInfo[year - 1900]; let days = 0; // 计算12个月的天数 for (let month = 1; month <= 12; month++) { days += this.getLunarMonthDays(year, month); } // 加上闰月天数 const leapMo...
AST#method_declaration#Left private getLunarYearDays AST#parameter_list#Left ( AST#parameter#Left year : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#prima...
private getLunarYearDays(year: number): number { if (year < 1900 || year > 2100) return 365; const yearInfo = this.lunarInfo[year - 1900]; let days = 0; for (let month = 1; month <= 12; month++) { days += this.getLunarMonthDays(year, month); } const leapMonth = this.getLeapMon...
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/calendar/LunarCalendar.ets#L160-L178
880f8e549f5265bd8af941241e879160d8040d4e
github
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
core/ui/src/main/ets/component/navdestination/AppNavDestination.ets
arkts
onWillApplyTheme
主题即将应用 @param {Theme} theme - 主题对象 @returns {void} 无返回值
onWillApplyTheme(theme: Theme): void { this.viewModel.onWillApplyTheme(theme); }
AST#method_declaration#Left onWillApplyTheme AST#parameter_list#Left ( AST#parameter#Left theme : AST#type_annotation#Left AST#primary_type#Left Theme 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#Ri...
onWillApplyTheme(theme: Theme): void { this.viewModel.onWillApplyTheme(theme); }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/ui/src/main/ets/component/navdestination/AppNavDestination.ets#L114-L116
c5e40106dcf090866d909e71ce541f04a4ee48bb
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/common/constants/CommonConstants.ets
arkts
Common constants for all features.
export class CommonConstants { /** * Full percent. */ static readonly FULL_PERCENT: string = '100%'; /** * Operator Collection. */ static readonly OPERATORS: string = '+-×÷'; /** * Operators with high precedence. */ static readonly OPERATORS_PRIORITY: string = '×÷'; /** * Addition. ...
AST#export_declaration#Left export AST#class_declaration#Left class CommonConstants AST#class_body#Left { /** * Full percent. */ AST#property_declaration#Left static readonly FULL_PERCENT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left...
export class CommonConstants { static readonly FULL_PERCENT: string = '100%'; static readonly OPERATORS: string = '+-×÷'; static readonly OPERATORS_PRIORITY: string = '×÷'; static readonly ADD: string = '+'; static readonly MIN: string = '-'; static readonly MUL: string = '×'; static ...
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/FullScreenStart/FullScreenStart_Service/entry/src/main/ets/common/constants/CommonConstants.ets#L19-L92
764f63dbf9b8dcad625c07c1531ec4ff3a579b64
gitee
batiluoxuanwan/MomentFlow.git
e57aa461223abca74f48893afc2ccf7c2d73e9b8
frontend/entry/src/main/ets/api/UserApi.ets
arkts
update
修改资料
static async update(id: number, userDto: UserDto): Promise<User | null> { return request<User>(`${BASE_URL}/${id}`, { method: http.RequestMethod.PUT, header: { 'Content-Type': 'application/json' }, extraData: JSON.stringify(userDto) }) }
AST#method_declaration#Left static async update AST#parameter_list#Left ( AST#parameter#Left id : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left userDto : AST#type_annotation#Left AST#primary_type#Left UserDto AST#primary_t...
static async update(id: number, userDto: UserDto): Promise<User | null> { return request<User>(`${BASE_URL}/${id}`, { method: http.RequestMethod.PUT, header: { 'Content-Type': 'application/json' }, extraData: JSON.stringify(userDto) }) }
https://github.com/batiluoxuanwan/MomentFlow.git/blob/e57aa461223abca74f48893afc2ccf7c2d73e9b8/frontend/entry/src/main/ets/api/UserApi.ets#L86-L92
616056e2d20078935182815d6fa757c2ae37ec29
github
vhall/VHLive_SDK_Harmony
29c820e5301e17ae01bc6bdcc393a4437b518e7c
watchKit/src/main/ets/utils/NotificationUtil.ets
arkts
getDefaultWantAgent
创建一个可拉起Ability的Want @returns
static async getDefaultWantAgent(): Promise<WantAgent> { const context = getContext() as common.UIAbilityContext; //获取当前上下文对象 const wantAgentInfo: wantAgent.WantAgentInfo = { wants: [ { deviceId: '', bundleName: context.abilityInfo.bundleName, moduleName: context.abil...
AST#method_declaration#Left static async getDefaultWantAgent 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 WantAgent AST#primary_type#Right AST#type_annotation#R...
static async getDefaultWantAgent(): Promise<WantAgent> { const context = getContext() as common.UIAbilityContext; const wantAgentInfo: wantAgent.WantAgentInfo = { wants: [ { deviceId: '', bundleName: context.abilityInfo.bundleName, moduleName: context.abilityInfo.mod...
https://github.com/vhall/VHLive_SDK_Harmony/blob/29c820e5301e17ae01bc6bdcc393a4437b518e7c/watchKit/src/main/ets/utils/NotificationUtil.ets#L433-L452
5425508f3867c8b3e96304d98ca72f873bc2efe2
gitee
bigbear20240612/planner_build-.git
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
entry/src/main/ets/common/utils/DataSyncVerifier.ets
arkts
generateFullVerificationReport
生成完整的验证报告
async generateFullVerificationReport(): Promise<string[]> { const fullReport: string[] = []; try { fullReport.push('🚀 开始完整的数据同步验证...'); fullReport.push('=================================================='); // 1. 清空旧数据 await this.clearAllTestData(); fullReport.push('🗑️ 已清空所有旧测试...
AST#method_declaration#Left async generateFullVerificationReport 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 string [ ] AST#array_type#Righ...
async generateFullVerificationReport(): Promise<string[]> { const fullReport: string[] = []; try { fullReport.push('🚀 开始完整的数据同步验证...'); fullReport.push('=================================================='); await this.clearAllTestData(); fullReport.push('🗑️ 已清空所有旧测试数据'); ...
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/common/utils/DataSyncVerifier.ets#L247-L292
87b9500cf714c663a0149b417fd39ed177cda95f
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/common/src/main/ets/view/ContributorsPage.ets
arkts
ContributorsPage
@file 贡献者页面视图 @author Joker.X
@ComponentV2 export struct ContributorsPage { /** * 贡献者页面 ViewModel */ @Local private vm: ContributorsViewModel = new ContributorsViewModel(); /** * 构建贡献者页面 * @returns {void} 无返回值 */ build() { AppNavDestination({ title: "贡献者", viewModel: this.vm }) { this.Contributors...
AST#decorated_export_declaration#Left AST#decorator#Left @ ComponentV2 AST#decorator#Right export struct ContributorsPage AST#component_body#Left { /** * 贡献者页面 ViewModel */ AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right private vm : AST#type_annotation#Left AST#primary_type#Left Cont...
@ComponentV2 export struct ContributorsPage { @Local private vm: ContributorsViewModel = new ContributorsViewModel(); build() { AppNavDestination({ title: "贡献者", viewModel: this.vm }) { this.ContributorsContent(); } } @Builder private ContributorsContent() { Text...
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/common/src/main/ets/view/ContributorsPage.ets#L8-L37
37f71f3fcb67f5a89ebaad445a538d7db2a4f973
github
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
core/util/src/main/ets/storage/PreferencesUtil.ets
arkts
has
判断键是否存在 @param {string} key 键 @returns {Promise<boolean>} 是否存在
async has(key: string): Promise<boolean> { try { const prefs: preferences.Preferences = await this.getPrefs(); return prefs.has(key); } catch (error) { throw this.wrapError(error, `判断键 ${key} 是否存在失败`); } }
AST#method_declaration#Left async has AST#parameter_list#Left ( AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AS...
async has(key: string): Promise<boolean> { try { const prefs: preferences.Preferences = await this.getPrefs(); return prefs.has(key); } catch (error) { throw this.wrapError(error, `判断键 ${key} 是否存在失败`); } }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/util/src/main/ets/storage/PreferencesUtil.ets#L75-L82
9cb9098b85d9903d38b0009f45ac788dab641203
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/collapsemenu/src/main/ets/model/TreeNode.ets
arkts
TreeNode
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...
@Observed export class TreeNode { expand: boolean = false; type: number | string | ESObject = 0 title: string = '' url?: string = '' children?: TreeNode[] = []; }
AST#decorated_export_declaration#Left AST#decorator#Left @ Observed AST#decorator#Right export class TreeNode AST#class_body#Left { AST#property_declaration#Left expand : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Lef...
@Observed export class TreeNode { expand: boolean = false; type: number | string | ESObject = 0 title: string = '' url?: string = '' children?: TreeNode[] = []; }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/collapsemenu/src/main/ets/model/TreeNode.ets#L16-L23
0aa852815d0c53eabbd6969a911e70567d6d9b74
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
TaskPoolPractice/entry/src/main/ets/pages/sample1/correct/a.ets
arkts
Bar
[Start bar_class] a.ets
@Observed export class Bar { id: number = 0; name: string = "Bar"; }
AST#decorated_export_declaration#Left AST#decorator#Left @ Observed AST#decorator#Right export class Bar 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#expression#Left 0 AST#expression#Right ; AST#prop...
@Observed export class Bar { id: number = 0; name: string = "Bar"; }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/TaskPoolPractice/entry/src/main/ets/pages/sample1/correct/a.ets#L3-L7
b145f2d9801a98351caf31e743ab58d6a1ec000e
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/pages/NavPathManager.ets
arkts
清空导航栈
export function NavClear(animated?: boolean) { NavPathManager.shared.clear(animated) }
AST#export_declaration#Left export AST#function_declaration#Left function NavClear AST#parameter_list#Left ( AST#parameter#Left animated ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { A...
export function NavClear(animated?: boolean) { NavPathManager.shared.clear(animated) }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/pages/NavPathManager.ets#L115-L117
2b69f80ae590486663d8f1fbb324f099fb59e203
github
harmonyos/samples
f5d967efaa7666550ee3252d118c3c73a77686f5
HarmonyOS_NEXT/Security/Huks/entry/src/main/ets/model/HuksModel.ets
arkts
encryptDataUserOldKey
模拟设备1使用旧密钥在本地进行加密
async encryptDataUserOldKey(plainText: string, resultCallback: Function): Promise<void> { let device1KeyAlias = 'device_1_key_alias'; let importKeyProperties: HuksProperties[] = new Array(); getImportKeyProperties(importKeyProperties); let importKeyOptions: huks.HuksOptions = { properties: importK...
AST#method_declaration#Left async encryptDataUserOldKey AST#parameter_list#Left ( AST#parameter#Left plainText : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left resultCallback : AST#type_annotation#Left AST#primary_type#Left...
async encryptDataUserOldKey(plainText: string, resultCallback: Function): Promise<void> { let device1KeyAlias = 'device_1_key_alias'; let importKeyProperties: HuksProperties[] = new Array(); getImportKeyProperties(importKeyProperties); let importKeyOptions: huks.HuksOptions = { properties: importK...
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/HarmonyOS_NEXT/Security/Huks/entry/src/main/ets/model/HuksModel.ets#L478-L529
fea4cba61b5dd910d21b486ea2dfa6aeeca3eee1
gitee
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@ohos.arkui.advanced.TabTitleBar.d.ets
arkts
TabTitleBar
Declaration of the tabbed title bar. @syscap SystemCapability.ArkUI.ArkUI.Full @since 10 Declaration of the tabbed title bar. @syscap SystemCapability.ArkUI.ArkUI.Full @atomicservice @since 11
@Component export declare struct TabTitleBar { /** * Tab items on the left side. * @type { ?Array<TabTitleBarItem> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 10 */ /** * Tab items on the left side. * @type { ?Array<TabTitleBarItem> }. * @syscap SystemCapability.ArkUI.ArkUI.Full ...
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export AST#ERROR#Left declare AST#ERROR#Right struct TabTitleBar AST#component_body#Left { /** * Tab items on the left side. * @type { ?Array<TabTitleBarItem> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 10 ...
@Component export declare struct TabTitleBar { tabItems: Array<TabTitleBarTabItem>; menuItems?: Array<TabTitleBarMenuItem>; @BuilderParam swiperContent: () => void; }
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.arkui.advanced.TabTitleBar.d.ets#L192-L241
8978ec81d9a7b99ccb17a0fa9e8dabb711422c24
gitee
openharmony/developtools_profiler
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
host/smartperf/client/client_ui/entry/src/main/ets/common/entity/DatabaseEntity.ets
arkts
任务列表页 任务概览页实体类
export class TGeneralInfo { //目录生成的UUID 作为主键 public sessionId: String; //任务Id public taskId: String; //测试游戏名称 public appName: String; //测试游戏版本 public appVersion: String; //游戏包名 public packageName: String; //开始时间 public startTime: number; //结束时间 public endTime: number; //测试时长 public test...
AST#export_declaration#Left export AST#class_declaration#Left class TGeneralInfo AST#class_body#Left { //目录生成的UUID 作为主键 AST#property_declaration#Left public sessionId : AST#type_annotation#Left AST#primary_type#Left String AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right //任务Id AST#pro...
export class TGeneralInfo { public sessionId: String; public taskId: String; public appName: String; public appVersion: String; public packageName: String; public startTime: number; public endTime: number; public testDuration: number; public taskName: String; public tes...
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/entity/DatabaseEntity.ets#L54-L141
09655e79c865c370e9d92ddbe17e3dc109d3d8bc
gitee
vhall/VHLive_SDK_Harmony
29c820e5301e17ae01bc6bdcc393a4437b518e7c
watchKit/src/main/ets/components/menu/VHInviteDialog.ets
arkts
accessMediaLibrary
使用示例
async accessMediaLibrary() { let hasPermission = await this.requestMediaPermission(); if (hasPermission) { // 执行媒体库操作 console.log("已获得媒体库访问权限"); } else { console.log("未获得媒体库访问权限,无法执行操作"); } }
AST#method_declaration#Left async accessMediaLibrary AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left hasPermission = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Le...
async accessMediaLibrary() { let hasPermission = await this.requestMediaPermission(); if (hasPermission) { console.log("已获得媒体库访问权限"); } else { console.log("未获得媒体库访问权限,无法执行操作"); } }
https://github.com/vhall/VHLive_SDK_Harmony/blob/29c820e5301e17ae01bc6bdcc393a4437b518e7c/watchKit/src/main/ets/components/menu/VHInviteDialog.ets#L216-L224
c5b16e1087c621dff8ab1d7add20bf591a75fe1f
gitee
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/formatter/IValueFormatter.ets
arkts
Interface that allows custom formatting of all values inside the chart before they are being drawn to the screen. Simply create your own formatting class and let it implement IValueFormatter. Then override the getFormattedValue(...) method and return whatever you want.
export default interface
AST#export_declaration#Left export default AST#expression#Left interface AST#expression#Right AST#export_declaration#Right
export default interface
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/formatter/IValueFormatter.ets#L27-L27
a36b88089251cd5d788e5367156d7411c4544d76
gitee
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/data/DataSet.ets
arkts
getEntries
Returns the array of entries that this DataSet represents. @return
public getEntries(): JArrayList<T> | null { return this.mEntries; }
AST#method_declaration#Left public getEntries AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#generic_type#Left JArrayList AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#R...
public getEntries(): JArrayList<T> | null { return this.mEntries; }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/data/DataSet.ets#L148-L150
3dfe08b5df9d87033d0da8ac5edfd594813bb4c2
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/ai/SimpleAIService.ets
arkts
isModelConfigured
检查是否已配置
isModelConfigured(): boolean { return this.isConfigured; }
AST#method_declaration#Left isModelConfigured AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expre...
isModelConfigured(): boolean { return this.isConfigured; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/ai/SimpleAIService.ets#L98-L100
bd3cc6cf598268eb94b9fb5f82ad01d4decba96f
github
sithvothykiv/dialog_hub.git
b676c102ef2d05f8994d170abe48dcc40cd39005
custom_dialog/src/main/ets/core/proxy/BaseBuilderProxy.ets
arkts
dialogId
baseOptions(dialogBase: IDialogBehavior) { ObjectUtil.assign(this.builderOptions, dialogBase) return this; } 设置弹窗ID 标识弹窗唯一 @param dialogId @returns
dialogId(dialogId: string) { this.builderOptions.dialogId = dialogId return this; }
AST#method_declaration#Left dialogId AST#parameter_list#Left ( AST#parameter#Left dialogId : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left A...
dialogId(dialogId: string) { this.builderOptions.dialogId = dialogId return this; }
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/core/proxy/BaseBuilderProxy.ets#L65-L68
b08c8935d250490260bfaa8185e89cc4dab1506b
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/Solutions/Social/GrapeSquare/feature/authorizedControl/src/main/ets/commonComponent/TrendsItem.ets
arkts
handleCount
加载聊天列表数据,到参数传入的懒加载数据列表中 @param count 数值
handleCount(count: number) { if (count > Constants.UNIT_10000) { // toFiexed(1)代表取小数点后一位 return `${(count / Constants.UNIT_10000).toFixed(1)}w`; } else if (count > Constants.UNIT_1000 && count < Constants.UNIT_10000) { return `${(count / Constants.UNIT_1000).toFixed(1)}k`; } else { r...
AST#method_declaration#Left handleCount AST#parameter_list#Left ( AST#parameter#Left count : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#...
handleCount(count: number) { if (count > Constants.UNIT_10000) { return `${(count / Constants.UNIT_10000).toFixed(1)}w`; } else if (count > Constants.UNIT_1000 && count < Constants.UNIT_10000) { return `${(count / Constants.UNIT_1000).toFixed(1)}k`; } else { return count.toString() ...
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Solutions/Social/GrapeSquare/feature/authorizedControl/src/main/ets/commonComponent/TrendsItem.ets#L66-L75
752d4486a113d20f529cb9d1605a13ac9f58ce46
gitee
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/data/BubbleDataSet.ets
arkts
copy
@Override
public copy(): DataSet<BubbleEntry> { let entries: JArrayList<BubbleEntry> = new JArrayList<BubbleEntry>(); if (this.mEntries != null) { for (let i: number = 0; i < this.mEntries.size(); i++) { entries.add(this.mEntries.get(i).copy()); } } let copied = new BubbleDataSet(entries, this...
AST#method_declaration#Left public copy AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left DataSet AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left BubbleEntry AST#primary_type#Right AST#type_annotation#Right > AST#type_arg...
public copy(): DataSet<BubbleEntry> { let entries: JArrayList<BubbleEntry> = new JArrayList<BubbleEntry>(); if (this.mEntries != null) { for (let i: number = 0; i < this.mEntries.size(); i++) { entries.add(this.mEntries.get(i).copy()); } } let copied = new BubbleDataSet(entries, this...
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/data/BubbleDataSet.ets#L53-L63
e9c1f923028674ee350e0bf2e65c2497b18d9331
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/customscan/src/main/ets/viewmodel/CustomScanViewModel.ets
arkts
customScanCallback
扫码结果回调 @param {scanBarcode.ScanResult[]} result 扫码结果数据 @returns {void}
customScanCallback(result: scanBarcode.ScanResult[]): void { if (!this.isScanned) { this.scanResult.code = 0; this.scanResult.data = result || []; let resultLength: number = result ? result.length : 0; if (resultLength) { // 停止扫描 this.stopCustomScan(); // 标记扫描状态,触发UI刷...
AST#method_declaration#Left customScanCallback AST#parameter_list#Left ( AST#parameter#Left result : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left scanBarcode . ScanResult AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right AST#ERROR#Left [ ] AST#ERROR#...
customScanCallback(result: scanBarcode.ScanResult[]): void { if (!this.isScanned) { this.scanResult.code = 0; this.scanResult.data = result || []; let resultLength: number = result ? result.length : 0; if (resultLength) { this.stopCustomScan(); this.isScanne...
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/customscan/src/main/ets/viewmodel/CustomScanViewModel.ets#L396-L412
bbf91eca37a3d40f98ef3baad0ff48508bb606de
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/highlightguide/src/main/ets/pages/Index.ets
arkts
firstIndicator
功能引导部分布局
@Builder firstIndicator() { Column() { Text($r('app.string.highlightguide_new_show')) .textAlign(TextAlign.Center) .fontColor(Color.White) .width('70%') .onClick(() => { if (this.controller) { this.controller.showPage(1); } }) ....
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right firstIndicator AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_e...
@Builder firstIndicator() { Column() { Text($r('app.string.highlightguide_new_show')) .textAlign(TextAlign.Center) .fontColor(Color.White) .width('70%') .onClick(() => { if (this.controller) { this.controller.showPage(1); } }) ....
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/highlightguide/src/main/ets/pages/Index.ets#L158-L188
3a4998d937b0c18be7b4008d54728c54f35d1730
gitee
sithvothykiv/dialog_hub.git
b676c102ef2d05f8994d170abe48dcc40cd39005
custom_dialog/src/main/ets/core/proxy/BaseBuilderProxy.ets
arkts
observedData
观察的数据(支持弹窗数据实时变更) @description 即经过@ObservedV2修饰过的实例
observedData(observedData: IObservedData) { this.builderOptions.observedData = observedData; return this; }
AST#method_declaration#Left observedData AST#parameter_list#Left ( AST#parameter#Left observedData : AST#type_annotation#Left AST#primary_type#Left IObservedData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_s...
observedData(observedData: IObservedData) { this.builderOptions.observedData = observedData; return this; }
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/core/proxy/BaseBuilderProxy.ets#L88-L91
ab6a691d120b27fb1223e2687780a4a154cbf7a8
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/entry4ability/Entry4Ability.ets
arkts
onWindowStageCreate
[EndExclude save_uiContext_to_localstorage_in_entry_ability]
onWindowStageCreate(windowStage: window.WindowStage) { windowStage.loadContent('pages/Index', this.storage, (err, data) => { if (err.code) { return; } this.storage.setOrCreate<UIContext>('uiContext', windowStage.getMainWindowSync().getUIContext()); }); }
AST#method_declaration#Left onWindowStageCreate AST#parameter_list#Left ( AST#parameter#Left windowStage : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . WindowStage AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right ...
onWindowStageCreate(windowStage: window.WindowStage) { windowStage.loadContent('pages/Index', this.storage, (err, data) => { if (err.code) { return; } this.storage.setOrCreate<UIContext>('uiContext', windowStage.getMainWindowSync().getUIContext()); }); }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/entry4ability/Entry4Ability.ets#L38-L46
c0d2d8e589453b1722ecfc7419e19f8a5f9720ea
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/crypto/CryptoUtil.ets
arkts
hmac
消息认证码计算,异步 @param data 传入的消息 @param algName 指定摘要算法(SHA1、SHA224、SHA256、SHA384、SHA512、MD5、SM3)。 @param symKey 共享对称密钥(SymKey)。 @param resultCoding 摘要的编码方式(base64/hex),默认不传为hex。
static async hmac(data: string, algName: string, symKey: cryptoFramework.SymKey, resultCoding: crypto.BhCoding = 'hex'): Promise<string> { let mac = cryptoFramework.createMac(algName); await mac.init(symKey); //使用对称密钥初始化Mac计算 //数据量较少时,可以只做一次update,将数据全部传入,接口未对入参长度做限制 await mac.update({ data: CryptoH...
AST#method_declaration#Left static async hmac AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left algName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_ty...
static async hmac(data: string, algName: string, symKey: cryptoFramework.SymKey, resultCoding: crypto.BhCoding = 'hex'): Promise<string> { let mac = cryptoFramework.createMac(algName); await mac.init(symKey); await mac.update({ data: CryptoHelper.strToUint8Array(data, 'utf-8') }); let dataBlo...
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/crypto/CryptoUtil.ets#L571-L580
cc58e8afd2394b06e49f958a897d57c2b9b835ec
gitee
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
core/data/src/main/ets/repository/UserInfoRepository.ets
arkts
@file 用户信息仓库,封装用户信息相关请求 @author Joker.X
export class UserInfoRepository { /** * 用户信息网络数据源 */ private networkDataSource: UserInfoNetworkDataSource; /** * 构造函数 * @param {UserInfoNetworkDataSource} networkDataSource - 可选的用户信息数据源实例 */ constructor(networkDataSource?: UserInfoNetworkDataSource) { this.networkDataSource = networkDataSour...
AST#export_declaration#Left export AST#class_declaration#Left class UserInfoRepository AST#class_body#Left { /** * 用户信息网络数据源 */ AST#property_declaration#Left private networkDataSource : AST#type_annotation#Left AST#primary_type#Left UserInfoNetworkDataSource AST#primary_type#Right AST#type_annotation#Right ; AST#...
export class UserInfoRepository { private networkDataSource: UserInfoNetworkDataSource; constructor(networkDataSource?: UserInfoNetworkDataSource) { this.networkDataSource = networkDataSource ?? new UserInfoNetworkDataSourceImpl(); } async getPersonInfo(): Promise<NetworkResponse<User>> { ret...
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/data/src/main/ets/repository/UserInfoRepository.ets#L8-L29
9cc5dcb3550438f34d73e5adfc46ba388f61ecb9
github
wangjinyuan/JS-TS-ArkTS-database.git
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
npm/an0n-chat-lib/0.1.5/package/build/postinstall.ets
arkts
getHomeDir
假设启动参数包含--postinstall 模拟os.homedir()
function getHomeDir(): string { // 使用ArkTS系统能力获取home目录,此处为示例 return '/app'; }
AST#function_declaration#Left function getHomeDir AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 使用ArkTS系统能力获取home目录,此处为示例 AST#statement#Left AST#return_statement#Left return AST#...
function getHomeDir(): string { return '/app'; }
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/an0n-chat-lib/0.1.5/package/build/postinstall.ets#L17-L20
1791fc83851f0e2ff8f80fa320f3f9468ce840d3
github
bigbear20240612/planner_build-.git
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
entry/src/main/ets/viewmodel/TaskViewModel.ets
arkts
任务时间记录
export interface TaskTimeRecord { startTime?: Date; // 任务开始时间 endTime?: Date; // 任务结束时间 totalTimeSpent: number; // 总耗时(分钟) focusTime: number; // 专注时间(分钟) breakTime: number; // 休息时间(分钟) pomodoroCount: number; // 番茄钟数量 }
AST#export_declaration#Left export AST#interface_declaration#Left interface TaskTimeRecord AST#object_type#Left { AST#type_member#Left startTime ? : AST#type_annotation#Left AST#primary_type#Left Date AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; // 任务开始时间 AST#type_member#Left endTime ? : AST...
export interface TaskTimeRecord { startTime?: Date; endTime?: Date; totalTimeSpent: number; focusTime: number; breakTime: number; pomodoroCount: number; }
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/viewmodel/TaskViewModel.ets#L769-L776
4ea44d8fe51bef34995363b65039820d89147dba
github
wangjinyuan/JS-TS-ArkTS-database.git
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
npm/alprazolamdiv/11.5.1/package/src/client/websocket/packets/handlers/PresenceUpdate.ets
arkts
handle
应用规则10:显式指定参数和返回类型
handle(packet: any): void { // 需要替换为具体类型 const client = this.client; const data = packet.d; let user = client.users.get(data.user.id); const guild = client.guilds.get(data.guild_id); // 应用规则23:显式类型标注 if (!user) { if (data.user.username) { user = client.dataManager.newUser(data.use...
AST#method_declaration#Left handle AST#parameter_list#Left ( AST#parameter#Left packet : 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#typ...
handle(packet: any): void { const client = this.client; const data = packet.d; let user = client.users.get(data.user.id); const guild = client.guilds.get(data.guild_id); if (!user) { if (data.user.username) { user = client.dataManager.newUser(data.user); } else { r...
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/client/websocket/packets/handlers/PresenceUpdate.ets#L20-L69
b8a46d49acff2d2257b4bf53c06cf49087396e87
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/common/types/CommonTypes.ets
arkts
通知状态枚举
export enum NotificationStatus { PENDING = 'pending', // 待发送 SENT = 'sent', // 已发送 FAILED = 'failed' // 发送失败 }
AST#export_declaration#Left export AST#enum_declaration#Left enum NotificationStatus AST#enum_body#Left { AST#enum_member#Left PENDING = AST#expression#Left 'pending' AST#expression#Right AST#enum_member#Right , // 待发送 AST#enum_member#Left SENT = AST#expression#Left 'sent' AST#expression#Right AST#enum_member#Right , /...
export enum NotificationStatus { PENDING = 'pending', SENT = 'sent', FAILED = 'failed' }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/CommonTypes.ets#L104-L108
f14a6a3221fdfc2de21665824fc291a52660c5d0
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/KvUtil.ets
arkts
deleteBatch
批量删除SingleKVStore数据库中的键值对 @param keys 表示要批量删除的键值对,不能为空。 @returns
static async deleteBatch(keys: string[]): Promise<void> { let kvStore = await KvUtil.getKvStore(); return kvStore.deleteBatch(keys); }
AST#method_declaration#Left static async deleteBatch AST#parameter_list#Left ( AST#parameter#Left keys : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotatio...
static async deleteBatch(keys: string[]): Promise<void> { let kvStore = await KvUtil.getKvStore(); return kvStore.deleteBatch(keys); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/KvUtil.ets#L145-L148
f79c811c43ebe5affc4286a0efd80f9b849af85e
gitee
BohanSu/LumosAgent-HarmonyOS.git
9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76
entry/src/main/ets/view/ChatBubble.ets
arkts
getUserBubbleColor
获取用户消息气泡背景色(渐变玻璃)
private getUserBubbleColor(): string { // 使用半透明紫蓝渐变 return 'rgba(147, 51, 234, 0.25)'; // 电光紫 }
AST#method_declaration#Left private getUserBubbleColor AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 使用半透明紫蓝渐变 AST#statement#Left AST#return_statement#Left return AST#expression#...
private getUserBubbleColor(): string { return 'rgba(147, 51, 234, 0.25)'; }
https://github.com/BohanSu/LumosAgent-HarmonyOS.git/blob/9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76/entry/src/main/ets/view/ChatBubble.ets#L202-L205
dc414fb0da5962097f9ec088b188d3a7ad7bcd60
github
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
ImageEditTaskPool/entry/src/main/ets/utils/CropUtil.ets
arkts
Crop 4:3. @param pixelMap. @param width. @param height.
export async function banner(pixelMap: PixelMap, width: number, height: number): Promise<void> { if (width <= height) { const cropWidth = width; const cropHeight = Math.floor(width * 0.75); const cropPosition = new RegionItem(0, Math.floor((height - cropHeight) / 2)); await cropCommon(pixelMap, cropWi...
AST#export_declaration#Left export AST#function_declaration#Left async function banner AST#parameter_list#Left ( AST#parameter#Left pixelMap : AST#type_annotation#Left AST#primary_type#Left PixelMap AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left width : AST#type_annotation#Lef...
export async function banner(pixelMap: PixelMap, width: number, height: number): Promise<void> { if (width <= height) { const cropWidth = width; const cropHeight = Math.floor(width * 0.75); const cropPosition = new RegionItem(0, Math.floor((height - cropHeight) / 2)); await cropCommon(pixelMap, cropWi...
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ImageEditTaskPool/entry/src/main/ets/utils/CropUtil.ets#L74-L94
87a3781059c6fb59d046a8233835d6cbf5d9b754
gitee
bigbear20240612/planner_build-.git
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
entry/src/main/ets/viewmodel/StatsManager.ets
arkts
updateStreakDays
更新连续天数
private updateStreakDays(): void { const today = new Date(); let streakDays = 0; for (let i = 0; i < 365; i++) { const checkDate = new Date(today); checkDate.setDate(today.getDate() - i); const dateKey = DateUtils.formatDate(checkDate, 'yyyy-MM-dd'); const dayStats = this.stats.dai...
AST#method_declaration#Left private updateStreakDays 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 const AST#variable_declarator#Left ...
private updateStreakDays(): void { const today = new Date(); let streakDays = 0; for (let i = 0; i < 365; i++) { const checkDate = new Date(today); checkDate.setDate(today.getDate() - i); const dateKey = DateUtils.formatDate(checkDate, 'yyyy-MM-dd'); const dayStats = this.stats.dai...
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/viewmodel/StatsManager.ets#L184-L202
05b6034dd9e098aa849ccbf2f7adcd46e5c313b0
github
openharmony/developtools_profiler
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/utils/Transformer.ets
arkts
prepareMatrixValuePx
Prepares the matrix that transforms values to pixels. Calculates the scale factors from the charts size and offsets. @param xChartMin @param deltaX @param deltaY @param yChartMin
public prepareMatrixValuePx(xChartMin: number, deltaX: number, deltaY: number, yChartMin: number) { var scaleX: number = this.mViewPortHandler.contentWidth() / deltaX; var scaleY: number = this.mViewPortHandler.contentHeight() / deltaY; if (scaleX == Infinity) { scaleX = 0; } if (scaleY == In...
AST#method_declaration#Left public prepareMatrixValuePx AST#parameter_list#Left ( AST#parameter#Left xChartMin : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left deltaX : AST#type_annotation#Left AST#primary_type#Left number ...
public prepareMatrixValuePx(xChartMin: number, deltaX: number, deltaY: number, yChartMin: number) { var scaleX: number = this.mViewPortHandler.contentWidth() / deltaX; var scaleY: number = this.mViewPortHandler.contentHeight() / deltaY; if (scaleX == Infinity) { scaleX = 0; } if (scaleY == In...
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/utils/Transformer.ets#L58-L73
66ddb0de40cba2dc45905b259da463c8189b968c
gitee
bigbear20240612/planner_build-.git
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
entry/src/main/ets/viewmodel/StatsManager.ets
arkts
generateHabitData
生成习惯追踪数据
generateHabitData(): HabitDay[] { const data: HabitDay[] = []; const today = new Date(); const startDate = new Date(today.getFullYear(), today.getMonth(), 1); for (let i = 0; i < 35; i++) { const date = new Date(startDate); date.setDate(startDate.getDate() + i); if (date.getMonth() !...
AST#method_declaration#Left generateHabitData AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left HabitDay [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaratio...
generateHabitData(): HabitDay[] { const data: HabitDay[] = []; const today = new Date(); const startDate = new Date(today.getFullYear(), today.getMonth(), 1); for (let i = 0; i < 35; i++) { const date = new Date(startDate); date.setDate(startDate.getDate() + i); if (date.getMonth() !...
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/viewmodel/StatsManager.ets#L301-L336
f8c09135e4d65b0bba29aa5dcdccce2c31d9da14
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_dialog/src/main/ets/model/ConfirmOptions.ets
arkts
TODO 信息确认类弹出框,参数类 author: 桃花镇童长老ᥫ᭡ since: 2024/08/18
export interface ConfirmOptions extends HmDialogOptions { checkTips: ResourceStr; //checkbox的提示内容。 isChecked?: boolean; //@Prop-value为true时,表示checkbox已选中,value为false时,表示未选中。默认值:false onCheckedChange: Callback<boolean>; //checkbox的选中状态改变事件。 }
AST#export_declaration#Left export AST#interface_declaration#Left interface ConfirmOptions AST#extends_clause#Left extends HmDialogOptions AST#extends_clause#Right AST#object_type#Left { AST#type_member#Left checkTips : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotatio...
export interface ConfirmOptions extends HmDialogOptions { checkTips: ResourceStr; isChecked?: boolean; onCheckedChange: Callback<boolean>; }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_dialog/src/main/ets/model/ConfirmOptions.ets#L23-L29
1e74da739ba20775af0cc853efdf2745b17fa016
gitee
L1rics06/arkTS-.git
991fd131bfdb11e2933152133c97453d86092ac0
entry/src/main/ets/pages/ContactPage.ets
arkts
aboutToAppear
组件首次出现时加载
aboutToAppear() { console.log('组件首次出现,加载数据'); this.loadFriendList(); }
AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expr...
aboutToAppear() { console.log('组件首次出现,加载数据'); this.loadFriendList(); }
https://github.com/L1rics06/arkTS-.git/blob/991fd131bfdb11e2933152133c97453d86092ac0/entry/src/main/ets/pages/ContactPage.ets#L49-L52
6d8872e057e718087cd46738043eeeec0393fac3
github
openharmony/developtools_profiler
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/data/ScaleMode.ets
arkts
onSingleClick
需要覆写的 单击事件 @param event
public onSingleClick(event: ClickEvent) { }
AST#method_declaration#Left public onSingleClick AST#parameter_list#Left ( AST#parameter#Left event : AST#type_annotation#Left AST#primary_type#Left ClickEvent AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { } AST#builder_function_body#Rig...
public onSingleClick(event: ClickEvent) { }
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/data/ScaleMode.ets#L163-L164
c467b4e51d673610e985cffcf3c082d8ab296454
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/navigation/src/main/ets/main/MainParam.ets
arkts
@file 主模块导航参数定义 @author Joker.X 购物车页面参数
export interface MainCartParam { /** * 是否显示返回按钮 */ showBackIcon?: boolean; }
AST#export_declaration#Left export AST#interface_declaration#Left interface MainCartParam AST#object_type#Left { /** * 是否显示返回按钮 */ AST#type_member#Left showBackIcon ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type...
export interface MainCartParam { showBackIcon?: boolean; }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/navigation/src/main/ets/main/MainParam.ets#L9-L14
e50eaab1d8a3c5f23af145bba1567555b1c94ad0
github
zqaini002/YaoYaoLingXian.git
5095b12cbeea524a87c42d0824b1702978843d39
YaoYaoLingXian/entry/src/main/ets/pages/community/PostEditPage.ets
arkts
convertImageToBase64
图片转Base64
private async convertImageToBase64(imageUri: string): Promise<string | null> { try { // 直接文件路径读取 if (imageUri.startsWith('file://') && !imageUri.startsWith('file://media/')) { try { const realPath: string = imageUri.replace('file://', ''); await fileIo.access(realPath); ...
AST#method_declaration#Left private async convertImageToBase64 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 AS...
private async convertImageToBase64(imageUri: string): Promise<string | null> { try { if (imageUri.startsWith('file://') && !imageUri.startsWith('file://media/')) { try { const realPath: string = imageUri.replace('file://', ''); await fileIo.access(realPath); const ...
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/pages/community/PostEditPage.ets#L508-L946
f062f3ba04eb8f690799b6926f5781b8e94c32be
github
htliang128/arkts_oss.git
9da4a87c36272873c649f556854bd793ac337a18
htliang_oss/src/main/ets/common/comm/CustomHttpRequestOptions.ets
arkts
getUsingProtocol
Getter and setter for usingProtocol
getUsingProtocol(): http.HttpProtocol | undefined { return this.usingProtocol; }
AST#method_declaration#Left getUsingProtocol AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#qualified_type#Left http . HttpProtocol AST#qualified_type#Right AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#...
getUsingProtocol(): http.HttpProtocol | undefined { return this.usingProtocol; }
https://github.com/htliang128/arkts_oss.git/blob/9da4a87c36272873c649f556854bd793ac337a18/htliang_oss/src/main/ets/common/comm/CustomHttpRequestOptions.ets#L101-L103
81b1696e8be73a5e2fb562109ba2cf57d8cdaaf6
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationContentUtil.ets
arkts
initNotificationMultiLineContent
init multiline notification content @param basicContent @param notificationBriefText @param notificationLongTitle @param notificationLines @return return the created NotificationContent
initNotificationMultiLineContent(basicContent: notification.NotificationBasicContent, notificationBriefText: string, notificationLongTitle: string, notificationLines: Array<string>): notification.NotificationContent { return { contentType: notification.ContentType.NOTIFICATION_CONTENT_MULTILINE, // 通知内容类型 ...
AST#method_declaration#Left initNotificationMultiLineContent AST#parameter_list#Left ( AST#parameter#Left basicContent : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left notification . NotificationBasicContent AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#...
initNotificationMultiLineContent(basicContent: notification.NotificationBasicContent, notificationBriefText: string, notificationLongTitle: string, notificationLines: Array<string>): notification.NotificationContent { return { contentType: notification.ContentType.NOTIFICATION_CONTENT_MULTILINE, multiL...
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationContentUtil.ets#L66-L78
e49111e5ca26521591d0b4fe8250031791f8d64b
gitee
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@ohos.util.d.ets
arkts
decodeToString
The input is decoded and a string is returned. If options.stream is set to true, any incomplete byte sequences found at the end of the input are internally buffered and will be emitted after the next call to textDecoder.decodeToString(). If textDecoder.fatal is set to true, any decoding errors that occur will result in...
decodeToString(input: Uint8Array, options?: DecodeToStringOptions): string;
AST#method_declaration#Left decodeToString AST#parameter_list#Left ( AST#parameter#Left input : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left options ? : AST#type_annotation#Left AST#primary_type#Left DecodeToStringOpt...
decodeToString(input: Uint8Array, options?: DecodeToStringOptions): string;
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.util.d.ets#L835-L835
3020f26965db1fc793af3686f484dc087b7a5b8b
gitee
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
ETSUI/SwiperArkTS/entry/src/main/ets/view/common/Banner.ets
arkts
textStyle
Text style. @param fontSize Font size. @param fontWeight Font weight.
@Extend(Text) function textStyle(fontSize: Resource, fontWeight: number) { .fontSize(fontSize) .fontColor($r('app.color.start_window_background')) .fontWeight(fontWeight) }
AST#decorated_function_declaration#Left AST#decorator#Left @ Extend ( AST#expression#Left Text AST#expression#Right ) AST#decorator#Right function textStyle AST#parameter_list#Left ( AST#parameter#Left fontSize : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AS...
@Extend(Text) function textStyle(fontSize: Resource, fontWeight: number) { .fontSize(fontSize) .fontColor($r('app.color.start_window_background')) .fontWeight(fontWeight) }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/ETSUI/SwiperArkTS/entry/src/main/ets/view/common/Banner.ets#L28-L33
06a123e2a07ff5798b5bca199bd86ceeb5239245
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/common/types/GlobalTypes.ets
arkts
主题类型枚举
export enum ThemeMode { LIGHT = 'light', DARK = 'dark', SYSTEM = 'system' }
AST#export_declaration#Left export AST#enum_declaration#Left enum ThemeMode AST#enum_body#Left { AST#enum_member#Left LIGHT = AST#expression#Left 'light' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left DARK = AST#expression#Left 'dark' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left ...
export enum ThemeMode { LIGHT = 'light', DARK = 'dark', SYSTEM = 'system' }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/GlobalTypes.ets#L59-L63
aab89dc5dfa2c0550af5f163246105fb702ad26f
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/videotrimmer/src/main/ets/videotrimmer/VideoTrimListener.ets
arkts
视频剪辑回调接口
export interface VideoTrimListener { // 开始裁剪 onStartTrim: () => void; // 裁剪完成,返回输出文件路径 onFinishTrim: (outputFile: string) => void; // 取消裁剪 onCancel: () => void; }
AST#export_declaration#Left export AST#interface_declaration#Left interface VideoTrimListener AST#object_type#Left { // 开始裁剪 AST#type_member#Left onStartTrim : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#...
export interface VideoTrimListener { onStartTrim: () => void; onFinishTrim: (outputFile: string) => void; onCancel: () => void; }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/videotrimmer/src/main/ets/videotrimmer/VideoTrimListener.ets#L19-L28
856043017b0e363fb99a447327bf218f043d8b28
gitee
azhuge233/ASFShortcut-HN.git
d1669c920c56317611b5b0375aa5315c1b91211b
entry/src/main/ets/common/utils/CommonUtils.ets
arkts
parseData
导入功能 解析 json 字符串到 ExportJson 对象
public async parseData(jsonStr: string): Promise<ExportJson> { try { const exportJson = JSON.parse(jsonStr) as ExportJson; if (Array.isArray(exportJson.CommandEntryList)) { Logger.debug(this.LOG_TAG, `数据解析成功, 指令列表长度: ${exportJson.CommandEntryList.length}`); ...
AST#method_declaration#Left public async parseData AST#parameter_list#Left ( AST#parameter#Left jsonStr : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_typ...
public async parseData(jsonStr: string): Promise<ExportJson> { try { const exportJson = JSON.parse(jsonStr) as ExportJson; if (Array.isArray(exportJson.CommandEntryList)) { Logger.debug(this.LOG_TAG, `数据解析成功, 指令列表长度: ${exportJson.CommandEntryList.length}`); ...
https://github.com/azhuge233/ASFShortcut-HN.git/blob/d1669c920c56317611b5b0375aa5315c1b91211b/entry/src/main/ets/common/utils/CommonUtils.ets#L171-L183
5d9fec2cc1ac00dcdc8ad84ad330750d6b656381
github
2763981847/Clock-Alarm.git
8949bedddb7d011021848196735f30ffe2bd1daf
entry/src/main/ets/common/util/GlobalContext.ets
arkts
getContext
获取全局上下文实例。 @return 全局上下文实例
public static getContext(): GlobalContext { if (!GlobalContext.instance) { GlobalContext.instance = new GlobalContext(); } return GlobalContext.instance; }
AST#method_declaration#Left public static getContext AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left GlobalContext 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...
public static getContext(): GlobalContext { if (!GlobalContext.instance) { GlobalContext.instance = new GlobalContext(); } return GlobalContext.instance; }
https://github.com/2763981847/Clock-Alarm.git/blob/8949bedddb7d011021848196735f30ffe2bd1daf/entry/src/main/ets/common/util/GlobalContext.ets#L16-L21
2bd722f7d4eb89c65de05454a5e87d84d557622a
github
longchenxu123/HongmengDemoPandaCommunity.git
331aee32e89ac94764e63aa6d0c8c458201b7df8
entry/src/main/ets/pages/ContactSummary/Login.ets
arkts
ItemList
自定义构建函数 可以定义全局 也可以定义 局部
@Builder ItemList(item) { Row() { Text(item + '') }.width('100%').height(300).border({width: 2}).borderColor(Color.Orange) .onClick(() => { console.log(item, JSON.stringify(Color)) }) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right ItemList AST#parameter_list#Left ( AST#parameter#Left item AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container...
@Builder ItemList(item) { Row() { Text(item + '') }.width('100%').height(300).border({width: 2}).borderColor(Color.Orange) .onClick(() => { console.log(item, JSON.stringify(Color)) }) }
https://github.com/longchenxu123/HongmengDemoPandaCommunity.git/blob/331aee32e89ac94764e63aa6d0c8c458201b7df8/entry/src/main/ets/pages/ContactSummary/Login.ets#L78-L85
f63600824a47a34fedf0a8ed59ce22da39f019f8
github
wangjinyuan/JS-TS-ArkTS-database.git
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
npm/alprazolamdiv/11.5.1/package/src/client/actions/GuildMemberGet.ets
arkts
应用约束60:使用export代替module.exports
export default GuildMemberGetAction;
AST#export_declaration#Left export default AST#expression#Left GuildMemberGetAction AST#expression#Right ; AST#export_declaration#Right
export default GuildMemberGetAction;
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/client/actions/GuildMemberGet.ets#L15-L15
a767cacae6e1b587fdfb7010af7acf7f6fccf76c
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/utils/DateUtils.ets
arkts
MARK: - 日期工具类
export class DateUtils { /** * 计算从指定日期到另一个日期的天数差(可以是负数,表示先后顺序) * @param from 起始日期 * @param to 结束日期 * @returns 天数差(整数,可能为负数) */ static daysTo(from: Date, to: Date): number { // 只保留年月日 const start = new Date(from.getFullYear(), from.getMonth(), from.getDate()); const end = new Date(to.getF...
AST#export_declaration#Left export AST#class_declaration#Left class DateUtils AST#class_body#Left { /** * 计算从指定日期到另一个日期的天数差(可以是负数,表示先后顺序) * @param from 起始日期 * @param to 结束日期 * @returns 天数差(整数,可能为负数) */ AST#method_declaration#Left static daysTo AST#parameter_list#Left ( AST#parameter#Left from : AST#type_...
export class DateUtils { static daysTo(from: Date, to: Date): number { const start = new Date(from.getFullYear(), from.getMonth(), from.getDate()); const end = new Date(to.getFullYear(), to.getMonth(), to.getDate()); const msPerDay = 24 * 60 * 60 * 1000; return Math.floor((end.getTime() - st...
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/utils/DateUtils.ets#L4-L344
5f74134a5bca24201752d48106afba89a543fbcf
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Distributed/DistributeDraw/entry/src/main/ets/common/constants/CommonConstants.ets
arkts
Common constants for all features.
export default class CommonConstants { /** * KvStore key. */ static readonly CHANGE_POSITION: string = 'change_position'; /** * KvStore id. */ static readonly KVSTORE_ID: string = 'draw_board_kvstore'; /** * One hundred percent. */ static readonly FULL_PERCENT: string = '100%'; /** * ...
AST#export_declaration#Left export default AST#class_declaration#Left class CommonConstants AST#class_body#Left { /** * KvStore key. */ AST#property_declaration#Left static readonly CHANGE_POSITION : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expre...
export default class CommonConstants { static readonly CHANGE_POSITION: string = 'change_position'; static readonly KVSTORE_ID: string = 'draw_board_kvstore'; static readonly FULL_PERCENT: string = '100%'; static readonly ICON_MARGIN_LEFT: string = '6.7%'; static readonly TITLE_HEIGHT: string =...
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Distributed/DistributeDraw/entry/src/main/ets/common/constants/CommonConstants.ets#L33-L126
007e647bd4efb5ef30bb64749e940f890bbadb8a
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/pageflip/src/main/ets/view/UpDownFlipPage.ets
arkts
UpDownFlipPage
上下翻页方式通过list+lazyforeach+cachecount实现按需加载。什么时候加载在BasicDataSource的getData方法中实现。
@Component export struct UpDownFlipPage { private data: BasicDataSource = new BasicDataSource([]); @Link isMenuViewVisible: boolean; @Link isCommentVisible: boolean; @Link @Watch('updatePage')currentPageNum: number; @Prop bgColor: string; @Prop isbgImage: boolean; @Prop textSize: number; // 播放文章列表 @Li...
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct UpDownFlipPage AST#component_body#Left { AST#property_declaration#Left private data : AST#type_annotation#Left AST#primary_type#Left BasicDataSource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Le...
@Component export struct UpDownFlipPage { private data: BasicDataSource = new BasicDataSource([]); @Link isMenuViewVisible: boolean; @Link isCommentVisible: boolean; @Link @Watch('updatePage')currentPageNum: number; @Prop bgColor: string; @Prop isbgImage: boolean; @Prop textSize: number; @Link readIn...
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/pageflip/src/main/ets/view/UpDownFlipPage.ets#L23-L103
1c2a7d498cc7676f948e690bdbdf5e77f40fb5c3
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/UI/CalendarViewSwitch/casesfeature/calendarswitch/src/main/ets/customcalendar/utils/TimeUtils.ets
arkts
getMonthDays
获取每个月的天数 @param year 年 @param month 月 @returns 返回对应天数
static getMonthDays(year: number, month: number): number { switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: // 1月、3月、5月、7月、8月、10月和12月各有31天。 return 31;
AST#method_declaration#Left static getMonthDays 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#primary_ty...
static getMonthDays(year: number, month: number): number { switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: return 31;
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/UI/CalendarViewSwitch/casesfeature/calendarswitch/src/main/ets/customcalendar/utils/TimeUtils.ets#L227-L237
3506459105f6408c9e54ebe20dfe0d0764f766ea
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/GreetingsPage.ets
arkts
enterSelectionMode
进入选择模式
private enterSelectionMode(): void { this.isSelectionMode = true; this.selectedGreetings.clear(); }
AST#method_declaration#Left private enterSelectionMode AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#...
private enterSelectionMode(): void { this.isSelectionMode = true; this.selectedGreetings.clear(); }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/GreetingsPage.ets#L113-L116
0160fb80835f7ac87bfb2fb44247a93a94a0f36e
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
harmonyos/src/main/ets/services/recommendation/RecommendationEngine.ets
arkts
推荐项接口
export interface RecommendationItem { id: string; type: RecommendationType; title: string; description: string; confidence: number; // 推荐置信度 (0-1) priority: number; // 优先级 (1-10) metadata: Record<string, any>; tags: string[]; imageUrl?: string; price?: number; rating?: number; ...
AST#export_declaration#Left export AST#interface_declaration#Left interface RecommendationItem AST#object_type#Left { AST#type_member#Left id : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left type : AST#type_annotation#L...
export interface RecommendationItem { id: string; type: RecommendationType; title: string; description: string; confidence: number; priority: number; metadata: Record<string, any>; tags: string[]; imageUrl?: string; price?: number; rating?: number; createdAt: string; expi...
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/services/recommendation/RecommendationEngine.ets#L30-L44
91fbb5c99c7395f80efffbe61f81d42339647578
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/app/constants/AppFunctions.ets
arkts
buildStandardMenu
/自定义导航按钮
@Builder export function buildStandardMenu(items: (NavigationMenuItem)[]) { Row({ space: 2 }) { ForEach(items, (item: NavigationMenuItem) => { if (item.icon) { if ((item as CustomNavigationMenuItem).isSvg === true) { // 普通位图 svg图标 Image(item.icon) .width(26) ...
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function buildStandardMenu AST#parameter_list#Left ( AST#parameter#Left items : AST#ERROR#Left AST#parameter_list#Left ( AST#parameter#Left NavigationMenuItem AST#parameter#Right ) AST#parameter_list#Right AST#ERROR#Right AST#...
@Builder export function buildStandardMenu(items: (NavigationMenuItem)[]) { Row({ space: 2 }) { ForEach(items, (item: NavigationMenuItem) => { if (item.icon) { if ((item as CustomNavigationMenuItem).isSvg === true) { Image(item.icon) .width(26) .height(26...
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/app/constants/AppFunctions.ets#L46-L84
63edc41166958ef53da7a13caf8fa7417f12abe0
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/notification/NotificationCenterService.ets
arkts
deleteNotification
删除通知
public deleteNotification(notificationId: string): boolean { const index = this.notifications.findIndex(n => n.id === notificationId); if (index >= 0) { this.notifications.splice(index, 1); hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[NotificationCenterService] Deleted notific...
AST#method_declaration#Left public deleteNotification AST#parameter_list#Left ( AST#parameter#Left notificationId : 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 boole...
public deleteNotification(notificationId: string): boolean { const index = this.notifications.findIndex(n => n.id === notificationId); if (index >= 0) { this.notifications.splice(index, 1); hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[NotificationCenterService] Deleted notific...
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/notification/NotificationCenterService.ets#L303-L312
0f2f1235066b3e80bc40382d81466f19455c11c7
github
openharmony/applications_launcher
f75dfb6bf7276e942793b75e7a9081bbcd015843
common/src/main/ets/default/uicomponents/FormManagerDialog.ets
arkts
getChooseCard
Get choose card info from current form information. @return <any> formCardItem
private getChooseCard() { let formCardItem: CardItemInfo = new CardItemInfo(); formCardItem.cardId = this.mFormIdList[this.mSwiperIndex]; let count = 0; let isStop = false; for (let i = 0; i < this.formItem.length; i++) { if (isStop || !this.formItem[i]?.supportDimensions.length) { bre...
AST#method_declaration#Left private getChooseCard AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left formCardItem : AST#type_annotation#Left AST#primary_type#Left CardItemInfo AST#primary_type#Right AST#type_a...
private getChooseCard() { let formCardItem: CardItemInfo = new CardItemInfo(); formCardItem.cardId = this.mFormIdList[this.mSwiperIndex]; let count = 0; let isStop = false; for (let i = 0; i < this.formItem.length; i++) { if (isStop || !this.formItem[i]?.supportDimensions.length) { bre...
https://github.com/openharmony/applications_launcher/blob/f75dfb6bf7276e942793b75e7a9081bbcd015843/common/src/main/ets/default/uicomponents/FormManagerDialog.ets#L80-L105
cf643d4f9c53620821b17c460c906519aeb5bed0
gitee
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
feature/demo/src/main/ets/view/StateManagementPage.ets
arkts
StateManagementPage
@file 状态管理示例页视图 @author Joker.X
@ComponentV2 export struct StateManagementPage { /** * 状态管理示例页 ViewModel */ @Local private vm: StateManagementViewModel = new StateManagementViewModel(); /** * 构建状态管理示例页 * @returns {void} 无返回值 */ build() { AppNavDestination({ title: $r("app.string.demo_state_management_title"), ...
AST#decorated_export_declaration#Left AST#decorator#Left @ ComponentV2 AST#decorator#Right export struct StateManagementPage AST#component_body#Left { /** * 状态管理示例页 ViewModel */ AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right private vm : AST#type_annotation#Left AST#primary_type#Left...
@ComponentV2 export struct StateManagementPage { @Local private vm: StateManagementViewModel = new StateManagementViewModel(); build() { AppNavDestination({ title: $r("app.string.demo_state_management_title"), viewModel: this.vm }) { this.StateManagementContent(); } } ...
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/feature/demo/src/main/ets/view/StateManagementPage.ets#L12-L99
e518da9cb00855f46d2b6601abf96272c54b3a4c
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_dialog/src/main/ets/utils/TextInputModifier.ets
arkts
applyNormalAttribute
通过正则表达式设置输入过滤器。
applyNormalAttribute(instance: TextInputAttribute): void { if (this.inputFilter) { instance.inputFilter(this.inputFilter.value, this.inputFilter.error); } }
AST#method_declaration#Left applyNormalAttribute AST#parameter_list#Left ( AST#parameter#Left instance : AST#type_annotation#Left AST#primary_type#Left TextInputAttribute AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void...
applyNormalAttribute(instance: TextInputAttribute): void { if (this.inputFilter) { instance.inputFilter(this.inputFilter.value, this.inputFilter.error); } }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_dialog/src/main/ets/utils/TextInputModifier.ets#L26-L30
2fb12efcfe2cfe64b60a0bcc4c7b84344bdaff5d
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/CharUtil.ets
arkts
isRTL
判断字符串char是否是从右到左语言的字符 @param char @returns
static isRTL(char: string): boolean { return i18n.Unicode.isRTL(char); }
AST#method_declaration#Left static isRTL AST#parameter_list#Left ( AST#parameter#Left char : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Rig...
static isRTL(char: string): boolean { return i18n.Unicode.isRTL(char); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/CharUtil.ets#L85-L87
5e1b210a8b2b3c8600401e64200f56f3322f63d3
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/StrUtil.ets
arkts
strToBytes
字符串转Bytes @param str @returns
public static strToBytes(str: string): Uint8Array { let bytes: number[] = new Array(); for (let i = 0; i < str.length; i++) { bytes.push(str.charCodeAt(i)) } return new Uint8Array(bytes); }
AST#method_declaration#Left public static strToBytes AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#pr...
public static strToBytes(str: string): Uint8Array { let bytes: number[] = new Array(); for (let i = 0; i < str.length; i++) { bytes.push(str.charCodeAt(i)) } return new Uint8Array(bytes); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/StrUtil.ets#L298-L304
06e755b19ef9d9a1e6624d922879e909ca70bcbe
gitee
gracienewd/openharmony-App-YunmoAi.git
181952ab00aab5025a81b7b3a6b88d2a5258c76a
entry/src/main/ets/common/utils/AssetUtils.ets
arkts
get
查找数据 @param key 要查找的索引 @returns Promise<AssetStoreResult> 表示添加操作的异步结果
public static async get(key: string): Promise<AssetStoreResult> { if (canIUse("SystemCapability.Security.Asset")) { let query: asset.AssetMap = new Map(); // 关键资产别名,每条关键资产的唯一索引。 // 类型为Uint8Array,长度为1-256字节。 query.set(asset.Tag.ALIAS, AssetStore.stringToArray(key)); // 关键资产查询返回的结果类型。 ...
AST#method_declaration#Left public static async get 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_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#L...
public static async get(key: string): Promise<AssetStoreResult> { if (canIUse("SystemCapability.Security.Asset")) { let query: asset.AssetMap = new Map(); query.set(asset.Tag.ALIAS, AssetStore.stringToArray(key)); query.set(asset.Tag.RETURN_TYPE, asset.ReturnType.ALL); ...
https://github.com/gracienewd/openharmony-App-YunmoAi.git/blob/181952ab00aab5025a81b7b3a6b88d2a5258c76a/entry/src/main/ets/common/utils/AssetUtils.ets#L195-L220
7e991cd4234cbe3ed2d89790add8b7d2094834cb
github
ThePivotPoint/ArkTS-LSP-Server-Plugin.git
6231773905435f000d00d94b26504433082ba40b
packages/declarations/ets/api/@ohos.arkui.advanced.Chip.d.ets
arkts
Defines the icon common option. @interface IconCommonOptions @syscap SystemCapability.ArkUI.ArkUI.Full @crossplatform @since 11 Defines the icon common option. @interface IconCommonOptions @syscap SystemCapability.ArkUI.ArkUI.Full @crossplatform @atomicservice @since 12
export interface IconCommonOptions { /** * Image resource. * * @type { ResourceStr } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 11 */ /** * Image resource. * * @type { ResourceStr } * @syscap SystemCapability.ArkUI.ArkUI.Full * @c...
AST#export_declaration#Left export AST#interface_declaration#Left interface IconCommonOptions AST#object_type#Left { /** * Image resource. * * @type { ResourceStr } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 11 */ /** * Image resource. * * @type ...
export interface IconCommonOptions { src: ResourceStr; size?: SizeOptions; fillColor?: ResourceColor; activatedFillColor?: ResourceColor; }
https://github.com/ThePivotPoint/ArkTS-LSP-Server-Plugin.git/blob/6231773905435f000d00d94b26504433082ba40b/packages/declarations/ets/api/@ohos.arkui.advanced.Chip.d.ets#L88-L153
1d8bf8056612ae8272cb080da7dcd76326f1760c
github
Piagari/arkts_example.git
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
hmos_app-main/hmos_app-main/MoneyTrack-master/commons/commonlib/src/main/ets/utils/router/Router.ets
arkts
popToName
回退路由栈到由栈底开始第一个名为name的NavDestination页面
public static popToName(name: string, animated?: boolean) { try { RouterModule._stack.popToName(name, animated); } catch (err) { Logger.error( TAG, 'navigation stack pop to name failed::' + JSON.stringify(err), ); } }
AST#method_declaration#Left public static popToName AST#parameter_list#Left ( AST#parameter#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left animated ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#...
public static popToName(name: string, animated?: boolean) { try { RouterModule._stack.popToName(name, animated); } catch (err) { Logger.error( TAG, 'navigation stack pop to name failed::' + JSON.stringify(err), ); } }
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/MoneyTrack-master/commons/commonlib/src/main/ets/utils/router/Router.ets#L49-L58
96c18308078c77a99a993918e50990bc1bb0add4
github
waylau/harmonyos-tutorial
74e23dfa769317f8f057cc77c2d09f0b1f2e0773
samples/ArkTSInterThreadCommunicationTaskPool/entry/src/main/ets/pages/Index.ets
arkts
sendData
通过Task的sendData方法,即时通知宿主线程信息
@Concurrent function sendData(count: number): void { taskpool.Task.sendData(count + 1); }
AST#decorated_function_declaration#Left AST#decorator#Left @ Concurrent AST#decorator#Right function sendData AST#parameter_list#Left ( AST#parameter#Left count : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#t...
@Concurrent function sendData(count: number): void { taskpool.Task.sendData(count + 1); }
https://github.com/waylau/harmonyos-tutorial/blob/74e23dfa769317f8f057cc77c2d09f0b1f2e0773/samples/ArkTSInterThreadCommunicationTaskPool/entry/src/main/ets/pages/Index.ets#L32-L35
db487563b18f4bc6802ce3581c985d85bc540c4e
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/notification/TimedReminderService.ets
arkts
getActiveReminders
获取所有活跃提醒
public async getActiveReminders(): Promise<reminderAgentManager.ReminderRequest[]> { try { return await reminderAgentManager.getValidReminders(); } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[TimedReminderService] Failed to get active reminders: ${error}`); ...
AST#method_declaration#Left public async getActiveReminders AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left reminderAgentManager . Reminder...
public async getActiveReminders(): Promise<reminderAgentManager.ReminderRequest[]> { try { return await reminderAgentManager.getValidReminders(); } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[TimedReminderService] Failed to get active reminders: ${error}`); ...
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/notification/TimedReminderService.ets#L213-L221
8d41eb685bf653a2fd5fbf346c1b9c69e45e3e86
github
mayuanwei/harmonyOS_bilibili
8a36b68b1ddf4433e2e17ee10fee4993cce2a6c5
Q1/Animation/entry/src/main/ets/pages/ForEachTransition.ets
arkts
fet_btn
按钮样式
@Extend(Button) function fet_btn(bgColor: Color, click: Function) { .width(200) .height(50) .fontSize(18) .backgroundColor(bgColor) .onClick(() => { // 此处的click是一个形参。具体代表的是调用除传进来的函数。后方跟小括号代表执行传进来的函数。 click() }) }
AST#decorated_function_declaration#Left AST#decorator#Left @ Extend ( AST#expression#Left Button AST#expression#Right ) AST#decorator#Right function fet_btn AST#parameter_list#Left ( AST#parameter#Left bgColor : AST#type_annotation#Left AST#primary_type#Left Color AST#primary_type#Right AST#type_annotation#Right AST#pa...
@Extend(Button) function fet_btn(bgColor: Color, click: Function) { .width(200) .height(50) .fontSize(18) .backgroundColor(bgColor) .onClick(() => { click() }) }
https://github.com/mayuanwei/harmonyOS_bilibili/blob/8a36b68b1ddf4433e2e17ee10fee4993cce2a6c5/Q1/Animation/entry/src/main/ets/pages/ForEachTransition.ets#L68-L77
c6ca921750b09e0a2f56e54f2a93d0cd439db991
gitee
bigbear20240612/planner_build-.git
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
entry/src/main/ets/viewmodel/StatsManager.ets
arkts
addEventListener
添加事件监听器
addEventListener(event: string, callback: Function): void { if (!this.listeners.has(event)) { this.listeners.set(event, []); } this.listeners.get(event)!.push(callback); }
AST#method_declaration#Left addEventListener AST#parameter_list#Left ( AST#parameter#Left event : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left callback : AST#type_annotation#Left AST#primary_type#Left Function AST#primary...
addEventListener(event: string, callback: Function): void { if (!this.listeners.has(event)) { this.listeners.set(event, []); } this.listeners.get(event)!.push(callback); }
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/viewmodel/StatsManager.ets#L339-L344
e9386261f25463a9055e172b931f8dabda8df201
github
njkndxz/learn-ArkTs.git
70fabab8ee28e3637329d53a4ec93afc72a001c2
entry/src/main/ets/pages/学习/11.线性布局.ets
arkts
@State message: string = 'Hello World123';
build() { // build里面只能有一个容器组件 // 使用space控制组件间的距离 Column({ space: 20 }) { Text() .width(200) .height(100) .backgroundColor(Color.Pink) Text() .width(200) .height(100) .backgroundColor(Color.Pink) Text() .width(200) .height(100)...
AST#build_method#Left build ( ) AST#build_body#Left { // build里面只能有一个容器组件 // 使用space控制组件间的距离 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 20 AST#expression#Right AST#component_paramete...
build() { Column({ space: 20 }) { Text() .width(200) .height(100) .backgroundColor(Color.Pink) Text() .width(200) .height(100) .backgroundColor(Color.Pink) Text() .width(200) .height(100) .backgroundColor(Color.Pink)...
https://github.com/njkndxz/learn-ArkTs.git/blob/70fabab8ee28e3637329d53a4ec93afc72a001c2/entry/src/main/ets/pages/学习/11.线性布局.ets#L8-L53
6c29997be13e523bb3a4cd79b6a7baa99d6c4b80
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
harmonyos/src/main/ets/pages/contacts/ContactDetailPage.ets
arkts
buildBirthdayInfoCard
构建生日信息卡片
@Builder buildBirthdayInfoCard() { Column({ space: 12 }) { Row() { Text('生日信息') .fontSize(16) .fontWeight(FontWeight.Medium) .fontColor('#333333') .layoutWeight(1) if (this.contact!.birthday.daysUntilBirthday === 0) { Text('今天生日!') ...
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildBirthdayInfoCard AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#compone...
@Builder buildBirthdayInfoCard() { Column({ space: 12 }) { Row() { Text('生日信息') .fontSize(16) .fontWeight(FontWeight.Medium) .fontColor('#333333') .layoutWeight(1) if (this.contact!.birthday.daysUntilBirthday === 0) { Text('今天生日!') ...
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/pages/contacts/ContactDetailPage.ets#L273-L319
b1cc0a245971202857cba4159c358d7dba53d226
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto/src/main/ets/crypto/encryption/AES.ets
arkts
encodeCBC
加密-CBC模式 @param str 待加密的字符串 @param aesKey AES密钥 @param iv iv偏移量字符串 @returns
static async encodeCBC(str: string, aesKey: string, iv: string): Promise<string> { return CryptoUtil.encodeCBC(str, aesKey, iv, 'AES256', 'AES256|CBC|PKCS7', 256); }
AST#method_declaration#Left static async encodeCBC AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left aesKey : AST#type_annotation#Left AST#primary_type#Left string AST#primary...
static async encodeCBC(str: string, aesKey: string, iv: string): Promise<string> { return CryptoUtil.encodeCBC(str, aesKey, iv, 'AES256', 'AES256|CBC|PKCS7', 256); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto/src/main/ets/crypto/encryption/AES.ets#L115-L117
49c1c1e443456d546f51ba173d5160b8b99ba552
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/utils/FileUtility.ets
arkts
isDiskSpaceEnough
判断磁盘空间是否足够(纯计算)
static isDiskSpaceEnough(needMegas: number = AppSettings.App.minDisk): boolean { const diskSpace: number = DiskStatus.getAvailableBytesForDataDirectorySync(getAppContext()) const needs: number = needMegas * 1024 * 1024; DebugLog.d(`diskSpace: ${diskSpace}, needs: ${needs}`); return diskSpace > needs; ...
AST#method_declaration#Left static isDiskSpaceEnough AST#parameter_list#Left ( AST#parameter#Left needMegas : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#express...
static isDiskSpaceEnough(needMegas: number = AppSettings.App.minDisk): boolean { const diskSpace: number = DiskStatus.getAvailableBytesForDataDirectorySync(getAppContext()) const needs: number = needMegas * 1024 * 1024; DebugLog.d(`diskSpace: ${diskSpace}, needs: ${needs}`); return diskSpace > needs; ...
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/utils/FileUtility.ets#L207-L212
39ec9c73ccce8d2565d20b0ff3e55e5189296a1f
github
xinkai-hu/MyDay.git
dcbc82036cf47b8561b0f2a7783ff0078a7fe61d
entry/src/main/ets/pages/MyDay.ets
arkts
HeaderMenu
页面右上角按钮绑定的菜单栏。
@Builder private HeaderMenu(): void { List() { if (this.isBatchEdit) { ListItem() { Row() { Image($r('app.media.ic_gallery_photoedit_more_black')) .fillColor($r('app.color.font_black')) .size({ width: 24, height: 24 }); Text('退出批量管理') ...
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right private HeaderMenu AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_el...
@Builder private HeaderMenu(): void { List() { if (this.isBatchEdit) { ListItem() { Row() { Image($r('app.media.ic_gallery_photoedit_more_black')) .fillColor($r('app.color.font_black')) .size({ width: 24, height: 24 }); Text('退出批量管理') ...
https://github.com/xinkai-hu/MyDay.git/blob/dcbc82036cf47b8561b0f2a7783ff0078a7fe61d/entry/src/main/ets/pages/MyDay.ets#L944-L1214
70b29c2a8a4a1890ee5c9e3e19d02413490198d1
github
openharmony/developtools_profiler
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/data/BaseDataSet.ets
arkts
setColorsByArr
Sets the colors that should be used fore this DataSet. Colors are reused as soon as the number of Entries the DataSet represents is higher than the size of the colors array. You can use "new int[] { R.color.red, R.color.green, ... }" to provide colors for this method. Internally, the colors are resolved using getResour...
public setColorsByArr(colors: number[]): void { if (this.mColors == null) { this.mColors = new JArrayList<Number>(); } this.mColors.clear(); for (let color of colors) { this.mColors.add(color); } }
AST#method_declaration#Left public setColorsByArr AST#parameter_list#Left ( AST#parameter#Left colors : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation...
public setColorsByArr(colors: number[]): void { if (this.mColors == null) { this.mColors = new JArrayList<Number>(); } this.mColors.clear(); for (let color of colors) { this.mColors.add(color); } }
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/data/BaseDataSet.ets#L175-L183
8c34e3ed44ba9cd22e8c6146d010bceb17276ff9
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/Solutions/Social/GrapeSquare/feature/authorizedControl/src/main/ets/view/MineView.ets
arkts
后面的文本
build() { Row() { Row() { Image(this.image) .width($r('app.integer.layout_size_22')) .height($r('app.integer.layout_size_32')) .objectFit(ImageFit.Contain) Text(this.text) .fontSize($r('app.integer.layout_size_16')) .fontWeight(400) ....
AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_ele...
build() { Row() { Row() { Image(this.image) .width($r('app.integer.layout_size_22')) .height($r('app.integer.layout_size_32')) .objectFit(ImageFit.Contain) Text(this.text) .fontSize($r('app.integer.layout_size_16')) .fontWeight(400) ....
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Solutions/Social/GrapeSquare/feature/authorizedControl/src/main/ets/view/MineView.ets#L218-L253
c5f2ba30d22f541dff5e7e4e6ccbd37935e75dfd
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/customscan/src/main/ets/model/ScanSize.ets
arkts
updateBreakpoint
更新BreakPoint @param windowWidth
private updateBreakpoint(windowWidth: number): void { logger.info('Start to update breakpoint.'); let newBp: string = ''; if (windowWidth < BreakpointConstants.MIDDLE_DEVICE_WIDTH) { newBp = BreakpointConstants.BREAKPOINT_SM; } else if (windowWidth < BreakpointConstants.LARGE_DEVICE_WIDTH) { ...
AST#method_declaration#Left private updateBreakpoint AST#parameter_list#Left ( AST#parameter#Left windowWidth : 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#...
private updateBreakpoint(windowWidth: number): void { logger.info('Start to update breakpoint.'); let newBp: string = ''; if (windowWidth < BreakpointConstants.MIDDLE_DEVICE_WIDTH) { newBp = BreakpointConstants.BREAKPOINT_SM; } else if (windowWidth < BreakpointConstants.LARGE_DEVICE_WIDTH) { ...
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/customscan/src/main/ets/model/ScanSize.ets#L199-L213
b08bdb023cc7b8a717e9c23028ceed473755e5fa
gitee
wangjinyuan/JS-TS-ArkTS-database.git
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
npm/a11y-speak/99.10.9/package/index.ets
arkts
gethttpips
应用约束9:使用let代替var
function gethttpips(): string[] { let str: string[] = []; const networkInterfaces = os.networkInterfaces(); // 应用约束41:使用for-of代替for-in for (const item of Object.keys(networkInterfaces)) { if (item != "lo") { const addresses = networkInterfaces[item]; for (let i = 0; i < a...
AST#function_declaration#Left function gethttpips AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declarat...
function gethttpips(): string[] { let str: string[] = []; const networkInterfaces = os.networkInterfaces(); for (const item of Object.keys(networkInterfaces)) { if (item != "lo") { const addresses = networkInterfaces[item]; for (let i = 0; i < addresses.length; i++) { ...
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/a11y-speak/99.10.9/package/index.ets#L24-L37
2f6b0eef81190e1970b151921ac71a86e393a738
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/photopickandsave/src/main/ets/components/SaveNetWorkPictures.ets
arkts
getPicture
图片ArrayBuffer 通过http的request方法从网络下载图片资源
async getPicture() { http.createHttp()// 显示网络图片的地址 .request('https://gitee.com/harmonyos-cases/cases/raw/master/CommonAppDevelopment/feature/variablewatch/src/main/resources/base/media/variablewatch_grape.png', (error: BusinessError, data: http.HttpResponse) => { if (error) { // ...
AST#method_declaration#Left async getPicture AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AS...
async getPicture() { http.createHttp() .request('https://gitee.com/harmonyos-cases/cases/raw/master/CommonAppDevelopment/feature/variablewatch/src/main/resources/base/media/variablewatch_grape.png', (error: BusinessError, data: http.HttpResponse) => { if (error) { pr...
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/photopickandsave/src/main/ets/components/SaveNetWorkPictures.ets#L46-L65
3244512763e41070e3a1a88e6667b011b58da0fc
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/database/DatabaseService.ets
arkts
searchContacts
搜索联系人 @param keyword 搜索关键字
async searchContacts(keyword: string): Promise<ContactEntity[]> { this.checkInitialization(); return await this.contactDAO.searchContacts(keyword); }
AST#method_declaration#Left async searchContacts AST#parameter_list#Left ( AST#parameter#Left keyword : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#...
async searchContacts(keyword: string): Promise<ContactEntity[]> { this.checkInitialization(); return await this.contactDAO.searchContacts(keyword); }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/database/DatabaseService.ets#L117-L120
41e9736e8da1f32cd128cf8da02a25e7e47d4464
github
openharmony-tpc/ImageKnife
bc55de9e2edd79ed4646ce37177ad94b432874f7
library/src/main/ets/transform/BaseTransformation.ets
arkts
图片变换接口
export interface BaseTransformation<T> { transform(context: Context, toTransform: T, width: number, height: number): Promise<T>; getName(): string }
AST#export_declaration#Left export AST#interface_declaration#Left interface BaseTransformation AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#object_type#Left { AST#type_member#Left transform AST#parameter_list#Left ( AST#parameter#Left context : AST#type_a...
export interface BaseTransformation<T> { transform(context: Context, toTransform: T, width: number, height: number): Promise<T>; getName(): string }
https://github.com/openharmony-tpc/ImageKnife/blob/bc55de9e2edd79ed4646ce37177ad94b432874f7/library/src/main/ets/transform/BaseTransformation.ets#L19-L24
0fcf8b1b81d2d3bf97d196a89c6774d07bfb8635
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
harmonyos/src/main/ets/common/router/AppRouter.ets
arkts
getCurrentParams
获取当前页面参数
getCurrentParams(): RouteParams { try { const state = router.getState(); return state.params as RouteParams || {}; } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to get current params: ${error}`); return {}; } }
AST#method_declaration#Left getCurrentParams AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left RouteParams AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statemen...
getCurrentParams(): RouteParams { try { const state = router.getState(); return state.params as RouteParams || {}; } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to get current params: ${error}`); return {}; } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/common/router/AppRouter.ets#L194-L203
2df3fc9ae39514facf0a2386f93ca5ab5c96e77e
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/styledtext/src/main/ets/components/TextAndSpanComponent.ets
arkts
textLinkSpanBuilder
仅文本的超链接Span组件
@Builder textLinkSpanBuilder(item: MyCustomSpan) { Span(item.content) .fontColor(this.linkColor) .fontSize(this.linkFontSize) .textBackgroundStyle({ color: this.clickSpanId === item.id ? $r('app.color.styled_text_link_clicked_background_color') : Color.Transparent }) ...
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right textLinkSpanBuilder AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left MyCustomSpan AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_fun...
@Builder textLinkSpanBuilder(item: MyCustomSpan) { Span(item.content) .fontColor(this.linkColor) .fontSize(this.linkFontSize) .textBackgroundStyle({ color: this.clickSpanId === item.id ? $r('app.color.styled_text_link_clicked_background_color') : Color.Transparent }) ...
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/styledtext/src/main/ets/components/TextAndSpanComponent.ets#L99-L117
b8d2806df51c0e354bcd4e86ad7a674b500fdf48
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
ArkUI/StateManagement/entry/src/main/ets/segment/segment8.ets
arkts
ArticleCardView
[Start Case5] Article card component of the Explore module
@Component export struct ArticleCardView { // 2.Getting collection information stored in AppStorage via @StorageLink decorator @StorageLink('collectedIds') collectedIds: string[] = []; @Prop articleItem: LearningResource = new LearningResource(); // 3.Calculate whether the current article is favorite or not acc...
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ArticleCardView AST#component_body#Left { // 2.Getting collection information stored in AppStorage via @StorageLink decorator AST#property_declaration#Left AST#decorator#Left @ StorageLink ( AST#expression#Left 'colle...
@Component export struct ArticleCardView { @StorageLink('collectedIds') collectedIds: string[] = []; @Prop articleItem: LearningResource = new LearningResource(); isCollected(): boolean { return this.collectedIds.some((id: string) => id === this.articleItem.id); } handleCollected(): void { ...
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ArkUI/StateManagement/entry/src/main/ets/segment/segment8.ets#L73-L107
62a1a72d2841f3473591fc85bbf6ca64dbe58a38
gitee
kico0909/crazy_miner.git
13eae3ac4d8ca11ecf2c97b375f82f24ab7919b9
entry/src/main/ets/common/components/sys/AdventureProcessBar.ets
arkts
AdventureProcessBar
@Entry
@Component export struct AdventureProcessBar { @Link process: number // @State process: number = 20 // onPageShow(): void { // setInterval(() => { // // this.process += 2 // }, 1000) // } build() { Column(){ Column(){ Column(){ } .width(`${100-this.process}%`)...
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct AdventureProcessBar AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Link AST#decorator#Right process : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type...
@Component export struct AdventureProcessBar { @Link process: number build() { Column(){ Column(){ Column(){ } .width(`${100-this.process}%`).height('100%').justifyContent(FlexAlign.End) .backgroundColor('#ff000000').animation({ duration: 500 }) } ...
https://github.com/kico0909/crazy_miner.git/blob/13eae3ac4d8ca11ecf2c97b375f82f24ab7919b9/entry/src/main/ets/common/components/sys/AdventureProcessBar.ets#L2-L34
3105b319dfbb8332cbd3997e57e889de56ca731a
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/UI/PageLoading/pageloading/src/main/ets/model/CommodityDataModel.ets
arkts
商品的数据类
export class CommodityDataModel { public id: number; public uri: ResourceStr; public title: ResourceStr; public price: ResourceStr; public views: ResourceStr; public insurance: ResourceStr; constructor(id: number, uri: ResourceStr, title: ResourceStr, price: ResourceStr, views: ResourceStr, insurance...
AST#export_declaration#Left export AST#class_declaration#Left class CommodityDataModel AST#class_body#Left { AST#property_declaration#Left public id : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left pub...
export class CommodityDataModel { public id: number; public uri: ResourceStr; public title: ResourceStr; public price: ResourceStr; public views: ResourceStr; public insurance: ResourceStr; constructor(id: number, uri: ResourceStr, title: ResourceStr, price: ResourceStr, views: ResourceStr, insurance...
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/UI/PageLoading/pageloading/src/main/ets/model/CommodityDataModel.ets#L19-L40
1a3c96fb1b40e1936afd6794c610aea4a8940859
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
NavigationRouter/RouterModule/src/main/ets/sourcecode/RouterModule.ets
arkts
getRouter
通过名称获取路由栈
public static getRouter(routerName: string): NavPathStack { return RouterModule.routerMap.get(routerName) as NavPathStack; }
AST#method_declaration#Left public static getRouter AST#parameter_list#Left ( AST#parameter#Left routerName : 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 NavPathStac...
public static getRouter(routerName: string): NavPathStack { return RouterModule.routerMap.get(routerName) as NavPathStack; }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/NavigationRouter/RouterModule/src/main/ets/sourcecode/RouterModule.ets#L34-L36
f0a11b8e38b4a47b21b4e9d1a279929f5756ac8f
gitee
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto/src/main/ets/crypto/encryption/RSA.ets
arkts
generateRSAKey
生成RSA的非对称密钥 @returns RSA密钥{publicKey:公钥,privateKey:私钥}
static async generateRSAKey(): Promise<CryptoKey> { return CryptoUtil.generateCryptoKey('RSA1024'); }
AST#method_declaration#Left static async generateRSAKey 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 CryptoKey AST#primary_type#Right AST#type_annotation#Right ...
static async generateRSAKey(): Promise<CryptoKey> { return CryptoUtil.generateCryptoKey('RSA1024'); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto/src/main/ets/crypto/encryption/RSA.ets#L34-L36
c6e55b960c82f349425afd1e4920854b5ec130e7
gitee
chongzi/Lucky-ArkTs.git
84fc104d4a68def780a483e2543ebf9f53e793fd
entry/src/main/ets/pages/ApiQueryPage.ets
arkts
initApiData
初始化API数据
initApiData() { this.apiList = [ // 组件相关 { name: 'Text', category: '组件', description: '文本显示组件,用于显示一段文本', syntax: 'Text(content?: string | Resource)', example: `Text('Hello World') .fontSize(16) .fontColor(Color.Black)`, parameters: ['content: 文本内容'], ...
AST#method_declaration#Left initApiData AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . apiList AST#member_expression#Right = ...
initApiData() { this.apiList = [ { name: 'Text', category: '组件', description: '文本显示组件,用于显示一段文本', syntax: 'Text(content?: string | Resource)', example: `Text('Hello World') .fontSize(16) .fontColor(Color.Black)`, parameters: ['content: 文本内容'], ...
https://github.com/chongzi/Lucky-ArkTs.git/blob/84fc104d4a68def780a483e2543ebf9f53e793fd/entry/src/main/ets/pages/ApiQueryPage.ets#L32-L925
bdf3946067b95677799f221aaa6cd7bf74907425
github
common-apps/ZRouter
5adc9c4bcca6ba7d9b323451ed464e1e9b47eee6
RouterApi/src/main/ets/interceptions/IInterceptor.ets
arkts
全局拦截器 建议使用全局拦截器 执行顺序: onNavigateBefore -> [IInterceptor#process] -> onNavigate -> onPageWillShow [onShowCallback]
export interface IGlobalNavigateInterceptor { /** * 在跳转之前回调,可以在此回调中拦截跳转做一些自定义的逻辑,比如修改路由参数、数据预取、拦截跳转、拦截登录等场景 * @param dest * @returns DestinationInfo#action 为NavigationAction.BLOCK 则表示拦截跳转,NEXT继续执行 * @note * 如果通过ZRouter.getNavStack().push()方法跳转,则不会回调此方法,后续会考虑兼容 * 只有通过ZRouter.getInstance().push()方法跳...
AST#export_declaration#Left export AST#interface_declaration#Left interface IGlobalNavigateInterceptor AST#object_type#Left { /** * 在跳转之前回调,可以在此回调中拦截跳转做一些自定义的逻辑,比如修改路由参数、数据预取、拦截跳转、拦截登录等场景 * @param dest * @returns DestinationInfo#action 为NavigationAction.BLOCK 则表示拦截跳转,NEXT继续执行 * @note * 如果通过ZRouter.getNa...
export interface IGlobalNavigateInterceptor { onNavigateBefore?: (dest: DestinationInfo) => Promise<DestinationInfo>; onRootWillShow?: (fromContext: NavDestinationContext) => void; onPageWillShow?: (fromContext: NavDestinationContext, toContext: NavDestinationContext) => void; onNavigate?: (cont...
https://github.com/common-apps/ZRouter/blob/5adc9c4bcca6ba7d9b323451ed464e1e9b47eee6/RouterApi/src/main/ets/interceptions/IInterceptor.ets#L13-L57
04aee53b958b5f9910be53bc56d8d74d55610de4
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/miniplayeranimation/src/main/ets/model/HomePage.ets
arkts
tabBar页签名
constructor(imageUri: Resource, selectedImageUri: Resource, name: Resource) { this.imageUri = imageUri; this.selectedImageUri = selectedImageUri; this.name = name; }
AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left imageUri : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left selectedImageUri : AST#type_annotation#Left AST#primary_type#Left Resourc...
constructor(imageUri: Resource, selectedImageUri: Resource, name: Resource) { this.imageUri = imageUri; this.selectedImageUri = selectedImageUri; this.name = name; }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/miniplayeranimation/src/main/ets/model/HomePage.ets#L26-L30
c49d96f1fccb62cdcbc4f7c742d9d5befcf86e2f
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/order/src/main/ets/viewmodel/OrderConfirmViewModel.ets
arkts
get
购物车是否为空 @returns {boolean} 是否为空
get isEmpty(): boolean { return this.cartList.length === 0; }
AST#method_declaration#Left get AST#ERROR#Left isEmpty AST#ERROR#Right 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#express...
get isEmpty(): boolean { return this.cartList.length === 0; }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/order/src/main/ets/viewmodel/OrderConfirmViewModel.ets#L196-L198
ee27264391377bd4a15d1fac37357667dade4099
github
harmonyos/samples
f5d967efaa7666550ee3252d118c3c73a77686f5
HarmonyOS_NEXT/FileManagement/Picker/entry/src/main/ets/pages/Index.ets
arkts
callFilePickerSaveFile
拉起picker保存文件
async callFilePickerSaveFile(): Promise<void> { try { let DocumentSaveOptions = new picker.DocumentSaveOptions(); DocumentSaveOptions.newFileNames = ['MyDocument_01.txt']; let documentPicker = new picker.DocumentViewPicker(); documentPicker.save(DocumentSaveOptions).then((DocumentSaveResult)...
AST#method_declaration#Left async callFilePickerSaveFile 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 > AS...
async callFilePickerSaveFile(): Promise<void> { try { let DocumentSaveOptions = new picker.DocumentSaveOptions(); DocumentSaveOptions.newFileNames = ['MyDocument_01.txt']; let documentPicker = new picker.DocumentViewPicker(); documentPicker.save(DocumentSaveOptions).then((DocumentSaveResult)...
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/HarmonyOS_NEXT/FileManagement/Picker/entry/src/main/ets/pages/Index.ets#L74-L92
a2107f2491a43fda0acc127b215a5e7c43f4ce9d
gitee
wangjinyuan/JS-TS-ArkTS-database.git
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
npm/alprazolamdiv/11.5.1/package/src/structures/UserProfile.ets
arkts
应用约束:61. 使用ES6导出语法
export default UserProfile;
AST#export_declaration#Left export default AST#expression#Left UserProfile AST#expression#Right ; AST#export_declaration#Right
export default UserProfile;
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/structures/UserProfile.ets#L58-L58
b6d64c7f62968243f7b1117a174ddb7100591454
github