nwo
stringclasses
449 values
path
stringlengths
9
173
language
stringclasses
1 value
identifier
stringlengths
1
53
docstring
stringlengths
5
4.13k
function
stringlengths
10
87.2k
ast_function
stringlengths
351
354k
obf_function
stringlengths
10
87.2k
url
stringlengths
30
175
function_sha
stringlengths
40
40
source
stringclasses
3 values
Tencent-RTC/TUIKit_Harmony
call/src/main/ets/feature/AppStateObserver.ets
arkts
init
Idempotent; must be called from `TUICallKit.init`.
init(context: common.UIAbilityContext): void { if (this.context) { return; } this.context = context; try { context.getApplicationContext().on('applicationStateChange', this.callback); } catch (e) { Logger.warn('AppStateObserver.init: register applicationStateChange failed', e); ...
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left init AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left context AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#member_expression#Left AST#identifier#Left common AST#identifier...
init(context: common.UIAbilityContext): void { if (this.context) { return; } this.context = context; try { context.getApplicationContext().on('applicationStateChange', this.callback); } catch (e) { Logger.warn('AppStateObserver.init: register applicationStateChange failed', e); ...
https://github.com/Tencent-RTC/TUIKit_Harmony
efd39170f939d3cdec6edca5a10f5128797bf7b2
github
jjjjjjava/ffmpeg_tools
src/main/ets/ffmpeg/FFmpegFactory.ets
arkts
imageVStack
图片拼接(纵向) @param inputs 输入图片路径数组 @param output 输出图片路径
public static imageVStack(inputs: string[], output: string): string[] { const cmd: string[] = ['ffmpeg']; for (const input of inputs) { cmd.push('-i', input); } let filterInputs = ''; for (let i = 0; i < inputs.length; i++) { filterInputs += `[${i}:v]`; } cmd.push( ...
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#identifier#Left static AST#identifier#Right AST#call_expression#Left AST#identifier#Left imageVStack AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left inputs AST#identifier#Right AST#:#Left : AS...
public static imageVStack(inputs: string[], output: string): string[] { const cmd: string[] = ['ffmpeg']; for (const input of inputs) { cmd.push('-i', input); } let filterInputs = ''; for (let i = 0; i < inputs.length; i++) { filterInputs += `[${i}:v]`; } cmd.push( ...
https://github.com/jjjjjjava/ffmpeg_tools
bf5455069fc6218c0867a1d3476765fb31901428
github
cpdd5201314/harmonyOS-music-app
products/phone/src/main/ets/pages/AlbumService.ets
arkts
decodeName
解码名称(处理特殊字符)
private static decodeName(name: string): string { if (!name) return ''; try { return decodeURIComponent(name); } catch (e) { return name; } }
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#identifier#Left static AST#identifier#Right AST#call_expression#Left AST#identifier#Left decodeName AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left name AST#identifier#Right AST#:#Left : AS...
private static decodeName(name: string): string { if (!name) return ''; try { return decodeURIComponent(name); } catch (e) { return name; } }
https://github.com/cpdd5201314/harmonyOS-music-app
54f44fdada8d61b0d74bd712a564a33c46d4742b
github
wblxr408/SEU-SE-HarmonyExpense-App-
entry/src/main/ets/dao/TagDAO.ets
arkts
insert
插入新标签 @param tag 标签对象
static async insert(tag: Tag): Promise<void> { if (!tag.validate()) { throw new Error('[TagDAO] 无效标签数据'); } const store = DatabaseManager.getDatabase(); const now = new Date().toISOString(); const sql = ` INSERT INTO tags (user_id, name, color, usage_count, created_at, updated_...
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#identifier#Left async AST#identifier#Right AST#call_expression#Left AST#identifier#Left insert AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left tag AST#identifier#Right AST#:#Left : AST#:#Right...
static async insert(tag: Tag): Promise<void> { if (!tag.validate()) { throw new Error('[TagDAO] 无效标签数据'); } const store = DatabaseManager.getDatabase(); const now = new Date().toISOString(); const sql = ` INSERT INTO tags (user_id, name, color, usage_count, created_at, updated_...
https://github.com/wblxr408/SEU-SE-HarmonyExpense-App-
1682c2883fb9f2fa390809c9272201f61b69c512
github
1ilI/WebViewJavascriptBridge_harmony
webview_javascript_bridge/src/main/ets/WebViewJavascriptBridgeTools.ets
arkts
objToBool
传入任意 Object 类型,获得 boolean 布尔 类型 @param obj 任意类型数据 @param def 默认值 @returns 字符串
public static objToBool(obj: Object | undefined | null, def?: boolean): boolean { let result: boolean = def ?? false; // 传入的 obj 为空 if (obj === undefined || obj === null) { return result; } // 传入的是 字符串 if (typeof obj === 'boolean') { return obj; } // 是 字符串 类型的,"1"、"true"、"...
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#identifier#Left static AST#identifier#Right AST#call_expression#Left AST#identifier#Left objToBool AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left obj AST#identifier#Right AST#:#Left : AST#:#R...
public static objToBool(obj: Object | undefined | null, def?: boolean): boolean { let result: boolean = def ?? false; // 传入的 obj 为空 if (obj === undefined || obj === null) { return result; } // 传入的是 字符串 if (typeof obj === 'boolean') { return obj; } // 是 字符串 类型的,"1"、"true"、"...
https://github.com/1ilI/WebViewJavascriptBridge_harmony
77e5ddde939102581a87f6ff61e19d2791b5a709
github
openharmony/arkui_ace_engine
advanced_ui_component/treeviewv2/source/treeviewv2.ets
arkts
emitNodeDelete
Triggers all callbacks of node delete event. @since 26
public emitNodeDelete(argument: CallbackParamV2): void { this.triggerCallbacks(this.nodeDeleteEvents, argument); this.triggerOnceCallbacks(this.nodeDeleteOnceEvents, argument); }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left emitNodeDelete AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left argument AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Le...
public emitNodeDelete(argument: CallbackParamV2): void { this.triggerCallbacks(this.nodeDeleteEvents, argument); this.triggerOnceCallbacks(this.nodeDeleteOnceEvents, argument); }
https://gitcode.com/openharmony/arkui_ace_engine
2bfe76b125daa394413be16e00d0c64447e0de16
gitcode
openharmony-sig/arkcompiler_runtime_core
plugins/ets/stdlib/std/core/Byte.ets
arkts
compareTo
Compares this instance to other Byte object The result is less than 0 if this instance lesser than provided object 0 if they are equal and greater than 0 otherwise. @param other Byte object to compare with @returns result of the comparison
public override compareTo(other: Byte): int { return (this.value - other.unboxed()) as int; }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#identifier#Left override AST#identifier#Right AST#call_expression#Left AST#identifier#Left compareTo AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left other AST#identifier#Right AST#ERROR#Left AST#:#Left : AST...
public override compareTo(other: Byte): int { return (this.value - other.unboxed()) as int; }
https://gitee.com/openharmony-sig/arkcompiler_runtime_core.git
e84a8093b74e67b1d90c4b727bacb1ff90c06564
gitee
codelably/HCompass
core/network/src/main/ets/AxiosHttpClient.ets
arkts
get
GET 请求 @param url 请求地址 @param options 请求选项 @returns 响应数据
async get<T>(url: string, options?: RequestOptions): Promise<T> { this.logRequest('GET', url, options); const response: AxiosResponse<T> = await this.axiosInstance.get<T>(url, { headers: options?.headers, timeout: options?.timeout, params: options?.params }); this.logResponse('GET', ...
AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#member_expression#Left AST#identifier#Left async AST#identifier#Right AST#ERROR#Left AST#get#Left get AST#get#Right AST#type_parameters#Left AST#<#Left < AST#<#Right AST#type_parameter#Left AST#type_identifier#Left T AST#type_identifier#Right A...
async get<T>(url: string, options?: RequestOptions): Promise<T> { this.logRequest('GET', url, options); const response: AxiosResponse<T> = await this.axiosInstance.get<T>(url, { headers: options?.headers, timeout: options?.timeout, params: options?.params }); this.logResponse('GET', ...
https://github.com/codelably/HCompass
fcdba714f8652ad0402734668cb18fc15b51113a
github
openharmony-sig/arkcompiler_runtime_core
plugins/ets/stdlib/escompat/TypedUArrays.ets
arkts
internal
Creates a slice of current BigUint64Array using range [begin, this.length). @param begin start index to be taken into slice @returns a new BigUint64Array with elements of current BigUint64Array[begin, this.length) public
/* public */ internal slice(begin: int): BigUint64Array { return this.slice(begin, this.length) }
AST#program#Left AST#comment#Left /* public */ AST#comment#Right AST#ERROR#Left AST#call_expression#Left AST#identifier#Left internal AST#identifier#Right AST#ERROR#Left AST#identifier#Left slice AST#identifier#Right AST#ERROR#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left begin AST#identifier#Ri...
/* public */ internal slice(begin: int): BigUint64Array { return this.slice(begin, this.length) }
https://gitee.com/openharmony-sig/arkcompiler_runtime_core.git
afba8147cb05b35742f117f52ca1b011f964ee3f
gitee
DaLongZhuaZi/manxia
entry/src/main/ets/Framework/Data/DataManager.ets
arkts
getAllOnlinePagesByComicId
[性能优化] 批量获取漫画所有章节的页面信息(在线漫画) 单条SQL替代N次逐章节查询,返回按chapterId分组的Map
public async getAllOnlinePagesByComicId(comicId: string): Promise<Map<string, OnlinePageInfo[]>> { try { const sql = `SELECT op.id, op.chapterId, op.pageNumber, op.imageUrl, op.requestHeaders, op.localPath, op.width, op.height, op.fileSize, op.createTime FROM onl...
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#identifier#Left async AST#identifier#Right AST#call_expression#Left AST#identifier#Left getAllOnlinePagesByComicId AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left comicId AST#identifier#Right AST#ERROR#Left ...
public async getAllOnlinePagesByComicId(comicId: string): Promise<Map<string, OnlinePageInfo[]>> { try { const sql = `SELECT op.id, op.chapterId, op.pageNumber, op.imageUrl, op.requestHeaders, op.localPath, op.width, op.height, op.fileSize, op.createTime FROM onl...
https://github.com/DaLongZhuaZi/manxia
52049bfa970c2d0317634f795134eb598daaa6a3
github
iop123123/arkts-static-skills
cli/arkts-static-cli/runtime/ark/es2panda/linux/etc/sdk/api/@ohos.util.TreeSet.ets
arkts
clear
Delete all elements of the TreeSet
clear(): void { this.treeMap.clear(); }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left clear AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Left : AST#:#Right AST#void#Left void AST#void#Right AST#ERROR#Right AST#statement_block#Left A...
clear(): void { this.treeMap.clear(); }
https://gitcode.com/iop123123/arkts-static-skills
fda8aaeda9edeef17610442403691e2ce837f444
gitcode
iop123123/arkts-static-skills
docs/ArkTS-Language-Guide/08-Stdlib/stdlib-source/std/core/TypedArrays.ets
arkts
includes
Determines whether Float32Array includes a certain element, returning true or false as appropriate @param { float } searchElement - The element to search for @param { int } fromIndex - The position in this array at which to begin searching for searchElement @returns { boolean } - true if searchElement is in Float32Arra...
public includes(searchElement: float, fromIndex: int): boolean { return this.indexOf(searchElement.toInt(), fromIndex) != -1 }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left includes AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left searchElement AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#identifier#Left float AST#iden...
public includes(searchElement: float, fromIndex: int): boolean { return this.indexOf(searchElement.toInt(), fromIndex) != -1 }
https://gitcode.com/iop123123/arkts-static-skills
ed3e122f637aa22f1cb9564c18ca2287e79f1d68
gitcode
LongLiveY96/chatcube
entry/src/main/ets/services/ProviderShareCodec.ets
arkts
peekEnvelope
仅校验 envelope JSON 结构和 v/src 头,**不**解密。 用于扫到 QR 后立即拦截非 Cube Chat payload(URL QR / 名片 QR 等)。
peekEnvelope(envelopeJson: string): boolean { try { const parsed = JSON.parse(envelopeJson) as ProviderShareEnvelopeV1 if (parsed === null || typeof parsed !== 'object') { return false } if (parsed.v !== ENVELOPE_VERSION || parsed.src !== ENVELOPE_SOURCE) { return false ...
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left peekEnvelope AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left envelopeJson AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string AST#string#Right AST#ERROR#Right AST#)#Left ) AS...
peekEnvelope(envelopeJson: string): boolean { try { const parsed = JSON.parse(envelopeJson) as ProviderShareEnvelopeV1 if (parsed === null || typeof parsed !== 'object') { return false } if (parsed.v !== ENVELOPE_VERSION || parsed.src !== ENVELOPE_SOURCE) { return false ...
https://github.com/LongLiveY96/chatcube
622babcd5dde83fe81f415905917e31cd035bbb0
github
ZestBox-18/kitebook-frontend
commons/data_core/src/main/ets/services/BillManager.ets
arkts
applyTransferBill
将转账账单同步到转出和转入账户余额。
private static async applyTransferBill(bill: BillBean, reverse: boolean = false): Promise<void> { if (bill.targetAccount.trim().length === 0 || bill.targetAccount === bill.account) { return; } const sourceDelta: number = reverse ? bill.amount : -bill.amount; const targetDelta: number = reverse ?...
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#identifier#Left static AST#identifier#Right AST#async#Left async AST#async#Right AST#call_expression#Left AST#identifier#Left applyTransferBill AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Le...
private static async applyTransferBill(bill: BillBean, reverse: boolean = false): Promise<void> { if (bill.targetAccount.trim().length === 0 || bill.targetAccount === bill.account) { return; } const sourceDelta: number = reverse ? bill.amount : -bill.amount; const targetDelta: number = reverse ?...
https://github.com/ZestBox-18/kitebook-frontend
53f2b42a7c6ca970c741099f53bbb53093ccc5d8
github
openharmony/applications_contacts
entry/src/main/ets/presenter/contact/detail/DetailPresenter.ets
arkts
getTalkTimeMessage
Obtain the call details of the call record according to the call record. @param {Object} callLogElement Call log @return {string} resultMessage Status information
getTalkTimeMessage(callLogElement: CallLog) { let resultMessage: Resource | string | null = null; switch (callLogElement.callType) { case CallType.IN: resultMessage = this.getDescriptionByDuration(callLogElement.talkDuration); break; case CallType.OUT: resultMessage = callLogElement.talkDu...
AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left getTalkTimeMessage AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left callLogElement AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#identifier#Left CallLog AST#identifier#Right...
getTalkTimeMessage(callLogElement: CallLog) { let resultMessage: Resource | string | null = null; switch (callLogElement.callType) { case CallType.IN: resultMessage = this.getDescriptionByDuration(callLogElement.talkDuration); break; case CallType.OUT: resultMessage = callLogElement.talkDu...
https://gitee.com/openharmony/applications_contacts.git
9833ab41303f691af9f19e8c0890b1a93a57a24d
gitee
CLMC2025/Vignette
entry/src/main/ets/context/TemplateBuilder.ets
arkts
getClosestTemplate
获取最接近的模板
private getClosestTemplate( templates: ContextTemplate[], params: TemplateParams, seed: number = -1 ): ContextTemplate | null { if (templates.length === 0) { return null; } // 优先匹配词性和单词数量 const filtered = templates.filter( (template: ContextTemplate): boolean => { re...
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left getClosestTemplate AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left templates AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#subsc...
private getClosestTemplate( templates: ContextTemplate[], params: TemplateParams, seed: number = -1 ): ContextTemplate | null { if (templates.length === 0) { return null; } // 优先匹配词性和单词数量 const filtered = templates.filter( (template: ContextTemplate): boolean => { re...
https://github.com/CLMC2025/Vignette
c7d9d85184f16cf23d391adef328cb6546f324b7
github
robotzzh/AgricultureApp
entry/src/main/ets/DB/DistributedUtil.ets
arkts
deleteStoreData
删除指定键值的数据
async deleteStoreData(key: string) { if (!kvStore) { return; } try { kvStore.delete(key, (err) => { if (err !== undefined) { console.error(`Failed to delete data. Code:${err.code},message:${err.message}`); return; } console.info('Succeeded in deleti...
AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left deleteStoreData AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left key AST#identifier#Right AST#type_annotation#Left AST#:#Left : ...
async deleteStoreData(key: string) { if (!kvStore) { return; } try { kvStore.delete(key, (err) => { if (err !== undefined) { console.error(`Failed to delete data. Code:${err.code},message:${err.message}`); return; } console.info('Succeeded in deleti...
https://github.com/robotzzh/AgricultureApp
be4a7b8311a8fdb4c30204f4df741f8ca152e82b
github
TDCQCX/ShiHuaMusic-Harmony
entry/src/main/ets/utils/StorageUtil.ets
arkts
removeToken
删除Token
static async removeToken(): Promise<void> { try { const prefs: preferences.Preferences = await StorageUtil.getPreferences(); await prefs.delete(StorageUtil.TOKEN_KEY); await prefs.flush(); } catch (error) { console.error('删除Token失败:', error); } }
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#identifier#Left async AST#identifier#Right AST#call_expression#Left AST#identifier#Left removeToken AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Le...
static async removeToken(): Promise<void> { try { const prefs: preferences.Preferences = await StorageUtil.getPreferences(); await prefs.delete(StorageUtil.TOKEN_KEY); await prefs.flush(); } catch (error) { console.error('删除Token失败:', error); } }
https://github.com/TDCQCX/ShiHuaMusic-Harmony
6cbb7ec44205b4d697fd13a142c687d5751be8b4
github
Joker-x-dev/CoolMallArkTS
core/datastore/src/main/ets/datasource/account/AccountStoreDataSourceImpl.ets
arkts
getAccount
读取账号(默认返回空字符串) @returns {Promise<string>} 用户账号
async getAccount(): Promise<string> { const value: preferences.ValueType = await this.prefs.get(AccountStoreDataSourceImpl.KEY_ACCOUNT, ""); return typeof value === "string" ? value : ""; }
AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left getAccount AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#formal_parameters#Right AST#type_annotation#Left AST#:#Left : AST#:#Right AST#generic_t...
async getAccount(): Promise<string> { const value: preferences.ValueType = await this.prefs.get(AccountStoreDataSourceImpl.KEY_ACCOUNT, ""); return typeof value === "string" ? value : ""; }
https://github.com/Joker-x-dev/CoolMallArkTS
6580b46575862c1cb770d151658b85d3010a7dfc
github
ZHCOOL520/HarmonyOS-AUTOcall
entry/src/main/ets/utils/FileImportManager.ets
arkts
findColumnIndex
查找列索引
private static findColumnIndex(headers: string[], keywords: string[]): number { for (let i = 0; i < headers.length; i++) { const header = headers[i] if (keywords.some(keyword => header.includes(keyword))) { return i } } return -1 }
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#identifier#Left static AST#identifier#Right AST#call_expression#Left AST#identifier#Left findColumnIndex AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left headers AST#identifier#Right AST#:#L...
private static findColumnIndex(headers: string[], keywords: string[]): number { for (let i = 0; i < headers.length; i++) { const header = headers[i] if (keywords.some(keyword => header.includes(keyword))) { return i } } return -1 }
https://github.com/ZHCOOL520/HarmonyOS-AUTOcall
19dbaf4a2421ace82d70b1bf13f94a8606ec1451
github
aimilin6688/KeePassHO
entry/src/main/ets/services/RecentFilesService.ets
arkts
getRecentFiles
获取最近打开的文件列表
public async getRecentFiles(): Promise<RecentFile[]> { try { if (!this.preferences) { return []; } const recentFilesJson = await this.preferences.get(RecentFilesService.RECENT_FILES_KEY, '[]'); let localFiles: RecentFile[] = JSON.parse(recentFilesJson.toString()) as RecentFile[]; ...
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#identifier#Left async AST#identifier#Right AST#call_expression#Left AST#identifier#Left getRecentFiles AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:...
public async getRecentFiles(): Promise<RecentFile[]> { try { if (!this.preferences) { return []; } const recentFilesJson = await this.preferences.get(RecentFilesService.RECENT_FILES_KEY, '[]'); let localFiles: RecentFile[] = JSON.parse(recentFilesJson.toString()) as RecentFile[]; ...
https://github.com/aimilin6688/KeePassHO/blob/6ac299504782abfed903b23a13c736b0841388d9/entry/src/main/ets/services/RecentFilesService.ets#L157-L175
76ae5657508948d3811260f7a3fafe210c49923d
github
XHXYT/Pixark
entry/src/main/ets/viewmodel/FavoriteViewModel.ets
arkts
currentNovels
获取当前小说列表
get currentNovels(): PixivNovel[] { if (this.mainTabIndex === 0) return this.trendNovels; if (this.mainTabIndex === 1) return this.collectionNovels; return []; }
AST#program#Left AST#ERROR#Left AST#get#Left get AST#get#Right AST#call_expression#Left AST#identifier#Left currentNovels AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Left : AST#:#Right AST#identifier#Left PixivNovel AST#id...
get currentNovels(): PixivNovel[] { if (this.mainTabIndex === 0) return this.trendNovels; if (this.mainTabIndex === 1) return this.collectionNovels; return []; }
https://github.com/XHXYT/Pixark/blob/fd28e9760e7566d4db095653f7fc4664a819fa5c/entry/src/main/ets/viewmodel/FavoriteViewModel.ets#L400-L404
b9a1180574bfa4305cc616d571976cd4c1a71f19
github
DaLongZhuaZi/manxia
entry/src/main/ets/Framework/Managers/SettingsManager.ets
arkts
getBottomBarStyle
获取底栏样式 @returns 'custom'(经典自定义底栏)| 'hds'(HDS系统底栏)
getBottomBarStyle(): string { return this.getString(SettingKeys.BOTTOM_BAR_STYLE, 'custom'); }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left getBottomBarStyle AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Left : AST#:#Right AST#string#Left string AST#string#Right AST#ERROR#Right AST#stat...
getBottomBarStyle(): string { return this.getString(SettingKeys.BOTTOM_BAR_STYLE, 'custom'); }
https://github.com/DaLongZhuaZi/manxia
ed54fe26972632b2fa83b654cc4c97779f845a3f
github
Joker-x-dev/CoolMallArkTS
core/network/src/main/ets/datasource/cs/CustomerServiceNetworkDataSourceImpl.ets
arkts
getUnreadCount
获取未读消息数量 @returns {Promise<NetworkResponse<number>>} 未读数量
async getUnreadCount(): Promise<NetworkResponse<number>> { const resp: AxiosResponse<NetworkResponse<number>> = await NetworkClient.http.get("cs/msg/unreadCount"); return resp.data; }
AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left getUnreadCount AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#formal_parameters#Right AST#type_annotation#Left AST#:#Left : AST#:#Right AST#gener...
async getUnreadCount(): Promise<NetworkResponse<number>> { const resp: AxiosResponse<NetworkResponse<number>> = await NetworkClient.http.get("cs/msg/unreadCount"); return resp.data; }
https://github.com/Joker-x-dev/CoolMallArkTS
7a96eab53c574f3b5645efa74f1e5ffd8dfd1006
github
AlkaidLab/moonlight-harmony
entry/src/main/ets/utils/BackgroundImageUtil.ets
arkts
getBackgroundImageType
获取当前背景图类型
async getBackgroundImageType(): Promise<BackgroundImageType> { if (!this.isLoaded) { await this.getBackgroundImageUrl(); } return this.cachedType; }
AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left async AST#identifier#Right AST#ERROR#Left AST#identifier#Left getBackgroundImageType AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#formal_parameters#Right AST#type_annotati...
async getBackgroundImageType(): Promise<BackgroundImageType> { if (!this.isLoaded) { await this.getBackgroundImageUrl(); } return this.cachedType; }
https://github.com/AlkaidLab/moonlight-harmony
c9cc197a63da3a99f0bebd4a102a3b57828d73ea
github
dingzhilin1990/zhilinclaw
src/security/SandboxedExecutor.ets
arkts
performSecurityChecks
执行安全检查
private async performSecurityChecks(action: string): Promise<void> { // 检查是否在黑名单中 // 验证权限 // 记录审计日志 }
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#identifier#Left async AST#identifier#Right AST#call_expression#Left AST#identifier#Left performSecurityChecks AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left action AST#identifier#Right AST...
private async performSecurityChecks(action: string): Promise<void> { // 检查是否在黑名单中 // 验证权限 // 记录审计日志 }
https://github.com/dingzhilin1990/zhilinclaw
124b37f1dab9b002e37e56b7d46a8b33d7aff24e
github
openharmony/codelabs
ETSUI/MediaReview/entry/src/main/ets/utils/RdbUtil.ets
arkts
getPosts
社区:帖子与评论
static async getPosts(context: Context, currentUserName?: string): Promise<DbPost[]> { try { const store = await RdbUtil.getStore(context) const user = currentUserName ?? (RdbUtil.currentUser ? RdbUtil.currentUser.name : undefined) if (!store) { const outList = [...RdbUtil.postMemory] ...
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#identifier#Left async AST#identifier#Right AST#call_expression#Left AST#identifier#Left getPosts AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left context AST#identifier#Right AST#:#Left : AST#:...
static async getPosts(context: Context, currentUserName?: string): Promise<DbPost[]> { try { const store = await RdbUtil.getStore(context) const user = currentUserName ?? (RdbUtil.currentUser ? RdbUtil.currentUser.name : undefined) if (!store) { const outList = [...RdbUtil.postMemory] ...
https://gitcode.com/openharmony/codelabs
87c0a565d56dc3db1c73ef3ba928aa8ecc121cd7
gitcode
CLMC2025/Vignette
entry/src/main/ets/sync/WebDavSyncManager.ets
arkts
serializeEventsJsonl
序列化事件为 JSON Lines
private serializeEventsJsonl(events: ReviewEventRow[]): string { let out = ''; for (const e of events) { // 使用 Record<string, Object> 类型来避免对象字面量类型检查问题 const obj: Record<string, Object> = { 'id': e.id, 'wordId': e.wordId, 'rating': e.rating, 'timestamp': e.timestamp,...
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left serializeEventsJsonl AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left events AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#subscr...
private serializeEventsJsonl(events: ReviewEventRow[]): string { let out = ''; for (const e of events) { // 使用 Record<string, Object> 类型来避免对象字面量类型检查问题 const obj: Record<string, Object> = { 'id': e.id, 'wordId': e.wordId, 'rating': e.rating, 'timestamp': e.timestamp,...
https://github.com/CLMC2025/Vignette
a89762f8f0e587e2e7b84e50fe8e48e6ddb8b001
github
openharmony/codelabs
ETSUI/PositioningDemo/entry/src/main/ets/service/StatisticsService.ets
arkts
calculateWeeklyFrequency
计算运动频率(每周平均运动几次)
async calculateWeeklyFrequency(): Promise<number> { const records = await this.historyService.getSportRecords(); if (records.length === 0) { return 0; } const sortedRecords = records.sort((a, b) => a.startTime - b.startTime); const firstTime = sortedRecords[0].startTime; const lastTime ...
AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left calculateWeeklyFrequency AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#formal_parameters#Right AST#type_annotation#Left AST#:#Left : AST#:#Right...
async calculateWeeklyFrequency(): Promise<number> { const records = await this.historyService.getSportRecords(); if (records.length === 0) { return 0; } const sortedRecords = records.sort((a, b) => a.startTime - b.startTime); const firstTime = sortedRecords[0].startTime; const lastTime ...
https://gitcode.com/openharmony/codelabs
848c61121279565c24d8031ee3f8fb0d9245ec26
gitcode
killetom/ktretrofit
ktretrofit/src/main/ets/retrofit/util/Semaphore.ets
arkts
constructor
Create a new Semaphore with the specified initial count. @param initialCount The initial count of the semaphore (default: 0).
constructor(initialCount: number = 0) { this.count = initialCount; }
AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left constructor AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left initialCount AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#assignment_expression#Left AST#identi...
constructor(initialCount: number = 0) { this.count = initialCount; }
https://github.com/killetom/ktretrofit
3e76e90bf917273e0ed7e322869ba3937ab4b86f
github
LongLiveY96/chatcube
entry/src/main/ets/services/WebSearchService.ets
arkts
stripHtmlTags
移除 HTML 标签
private stripHtmlTags(text: string): string { return text .replace(/<[^>]+>/g, '') .replace(/&nbsp;/g, ' ') .replace(/&amp;/g, '&') .replace(/&lt;/g, '<') .replace(/&gt;/g, '>') .replace(/&quot;/g, '"') .replace(/&#39;/g, "'") .replace(/\s+/g, ' ') .trim() }
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left stripHtmlTags AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left text AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left...
private stripHtmlTags(text: string): string { return text .replace(/<[^>]+>/g, '') .replace(/&nbsp;/g, ' ') .replace(/&amp;/g, '&') .replace(/&lt;/g, '<') .replace(/&gt;/g, '>') .replace(/&quot;/g, '"') .replace(/&#39;/g, "'") .replace(/\s+/g, ' ') .trim() }
https://github.com/LongLiveY96/chatcube
ac434ebbac4ff9bcbd7b28f8d483fabf889ea019
github
Yebingiscn/SweetVideo
entry/src/main/ets/utils/VideoInfoUtil.ets
arkts
setVideoInfoOptimized
设置存储的视频信息(优化版:减少文件打开次数)
static async setVideoInfoOptimized(date: string, uri: string, file_name: string, metadata: media.AVMetadata, sandbox_video: string, sandbox_path: string, fileSize: number, pixelMap: image.PixelMap | undefined) { let time = '0' let hdr_type = media.HdrType.AV_HDR_TYPE_NONE let duration = '0' if (ca...
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#identifier#Left async AST#identifier#Right AST#call_expression#Left AST#identifier#Left setVideoInfoOptimized AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left date AST#identifier#Right AST#:#Le...
static async setVideoInfoOptimized(date: string, uri: string, file_name: string, metadata: media.AVMetadata, sandbox_video: string, sandbox_path: string, fileSize: number, pixelMap: image.PixelMap | undefined) { let time = '0' let hdr_type = media.HdrType.AV_HDR_TYPE_NONE let duration = '0' if (ca...
https://github.com/Yebingiscn/SweetVideo
0226c2361620e22ac9437fccd9bd2c6288545309
github
HarmonyOS_Samples/BestPracticeSnippets
ArkUI/StateManagement/entry/src/main/ets/segment/segment8.ets
arkts
handleCollected
6.Handling interface like interaction logic: when the state collectedIds received using the @StorageLink decorator are modified, the new values are synchronized to AppStorage
handleCollected(): void { // [StartExclude Case5] const resourceId = this.articleItem.id; // [EndExclude Case5] const index = this.collectedIds.findIndex((id: string) => id === this.articleItem.id); if (index === -1) { this.collectedIds.push(resourceId); } else { this.collectedIds....
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left handleCollected AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Left : AST#:#Right AST#void#Left void AST#void#Right AST#ERROR#Right AST#statement_bl...
handleCollected(): void { // [StartExclude Case5] const resourceId = this.articleItem.id; // [EndExclude Case5] const index = this.collectedIds.findIndex((id: string) => id === this.articleItem.id); if (index === -1) { this.collectedIds.push(resourceId); } else { this.collectedIds....
https://gitcode.com/HarmonyOS_Samples/BestPracticeSnippets
6b8c38f179e070b3187cfa732d14c7c5612876fb
gitcode
LJ666-ui/harmony-health-care
entry/src/main/ets/rag/VectorRetriever.ets
arkts
normalize
向量归一化
private normalize(vector: number[]): number[] { const norm = Math.sqrt( vector.reduce((sum, val) => sum + val * val, 0) ); return vector.map(val => val / norm); }
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left normalize AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left vector AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#subscript_express...
private normalize(vector: number[]): number[] { const norm = Math.sqrt( vector.reduce((sum, val) => sum + val * val, 0) ); return vector.map(val => val / norm); }
https://github.com/LJ666-ui/harmony-health-care
c49f22244ffe7b05740d57b20c2f7d8c72229a66
github
openharmony-sig/arkcompiler_runtime_core
plugins/ets/stdlib/escompat/TypedArrays.ets
arkts
forEach
Applies a function over all elements of BigInt64Array @param fn function to apply @returns undefined
public forEach(fn: (val: long, index: int, array: BigInt64Array) => long): void { for (let i = 0; i < this.length; ++i) { this.set(i, fn(this.at(i), i, this)) } throw new Error("BigInt64Array.forEach: has to return undefined, but returns void for now") }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left forEach AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#binary_expression#Left AST#call_expression#Left AST#identifier#Left fn AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#...
public forEach(fn: (val: long, index: int, array: BigInt64Array) => long): void { for (let i = 0; i < this.length; ++i) { this.set(i, fn(this.at(i), i, this)) } throw new Error("BigInt64Array.forEach: has to return undefined, but returns void for now") }
https://gitee.com/openharmony-sig/arkcompiler_runtime_core.git
aeb1b5282fd731c4ce0c5b3c0c268dcc1da2fd2c
gitee
Joker-x-dev/CoolMallArkTS
entry/src/main/ets/view/EntryPage.ets
arkts
build
渲染根导航容器 @returns {void} 无返回值
build() { Column() { NavigationHost() } }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left build AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#ERROR#Right AST#expression_statement#Left AST#object#Left AST#{#Left { AST#{#Right AST#method_def...
build() { Column() { NavigationHost() } }
https://github.com/Joker-x-dev/CoolMallArkTS
cba1ee897e92a9ea8b3bd3d6b0b720f3ce56c116
github
DaLongZhuaZi/manxia
entry/src/main/ets/Framework/Database/DatabaseManager.ets
arkts
convertRecordToDbFormat
将记录转换为数据库格式 - 支持UpdateRecordData接口
private convertRecordToDbFormat(tableName: string, record: DatabaseRecord | UpdateRecordData): Record<string, DatabaseValue> { // 更精确的UpdateRecordData类型判断:检查是否只包含更新相关的字段 // UpdateRecordData通常只包含少数几个字段,而DatabaseRecord包含完整的数据结构 const recordKeys = Object.keys(record); // 增加字段数量限制到10,因为刮削结果可能包含多个字段(id, up...
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left convertRecordToDbFormat AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left tableName AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left stri...
private convertRecordToDbFormat(tableName: string, record: DatabaseRecord | UpdateRecordData): Record<string, DatabaseValue> { // 更精确的UpdateRecordData类型判断:检查是否只包含更新相关的字段 // UpdateRecordData通常只包含少数几个字段,而DatabaseRecord包含完整的数据结构 const recordKeys = Object.keys(record); // 增加字段数量限制到10,因为刮削结果可能包含多个字段(id, up...
https://github.com/DaLongZhuaZi/manxia
290a305734ffe199e5b6c7e4644c5dbf00cbde40
github
CPF-ApplicationTPC/openharmony_tpc_samples
SwipeMenuListView/library/src/main/ets/model/SwipeMenu.ets
arkts
getTotalWidth
计算菜单总宽度
getTotalWidth(): number { return this.items.reduce((sum, item) => sum + item.width, 0); }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left getTotalWidth AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Left : AST#:#Right AST#number#Left number AST#number#Right AST#ERROR#Right AST#statemen...
getTotalWidth(): number { return this.items.reduce((sum, item) => sum + item.width, 0); }
https://gitcode.com/CPF-ApplicationTPC/openharmony_tpc_samples
722e889c782e5c16c167259caf2c77438cb5db96
gitcode
LambdaYH/ScrcpyForHarmonyOS
app/src/main/ets/helper/Logger.ets
arkts
processQueue
处理日志队列 (Async)
private static async processQueue() { if (Logger.isWriting || Logger.logQueue.length === 0) return; Logger.isWriting = true; try { // 取出当前所有待写入的日志,清空队列 // 这样可以一次性写入,减少IO次数 const logsToWrite = [...Logger.logQueue]; Logger.logQueue = []; // 清空 if (logsToWrite.length === 0) {...
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#identifier#Left static AST#identifier#Right AST#async#Left async AST#async#Right AST#call_expression#Left AST#identifier#Left processQueue AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#argument...
private static async processQueue() { if (Logger.isWriting || Logger.logQueue.length === 0) return; Logger.isWriting = true; try { // 取出当前所有待写入的日志,清空队列 // 这样可以一次性写入,减少IO次数 const logsToWrite = [...Logger.logQueue]; Logger.logQueue = []; // 清空 if (logsToWrite.length === 0) {...
https://github.com/LambdaYH/ScrcpyForHarmonyOS
ce8c054b092c15a1768a41d6780881ddf94d04e5
github
richshaw2015/nds
ohos/entry/src/main/ets/utils/RAManager.ets
arkts
onRomLoaded
ROM 加载后调用: 计算哈希 → 查询 API → 加载到 Native 运行时 对齐 Android: EmulatorManager.setupRetroAchievements() @param romPath ROM 文件的沙箱路径
async onRomLoaded(romPath: string): Promise<void> { if (!this.apiClient.isAuthenticated()) { this.loadState = RALoadState.NOT_AUTHENTICATED; hilog.info(DOMAIN, TAG, 'Not authenticated, skipping RA setup'); return; } try { // 1. 计算 ROM 哈希 this.loadState = RALoadState.COMPUTIN...
AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left async AST#identifier#Right AST#ERROR#Left AST#identifier#Left onRomLoaded AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left romPath AST#identifier#Right AST#...
async onRomLoaded(romPath: string): Promise<void> { if (!this.apiClient.isAuthenticated()) { this.loadState = RALoadState.NOT_AUTHENTICATED; hilog.info(DOMAIN, TAG, 'Not authenticated, skipping RA setup'); return; } try { // 1. 计算 ROM 哈希 this.loadState = RALoadState.COMPUTIN...
https://github.com/richshaw2015/nds
005e88aed4dac3ab37d12d846fa6f2668efb30ff
github
LJ666-ui/harmony-health-care
entry/src/main/ets/ar/ARRenderer.ets
arkts
roundRect
绘制圆角矩形
private roundRect( ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius: number ): void { ctx.beginPath(); ctx.moveTo(x + radius, y); ctx.lineTo(x + width - radius, y); ctx.quadraticCurveTo(x + width, y, x + width, y + radius); ctx.li...
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left roundRect AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left ctx AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left Canv...
private roundRect( ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius: number ): void { ctx.beginPath(); ctx.moveTo(x + radius, y); ctx.lineTo(x + width - radius, y); ctx.quadraticCurveTo(x + width, y, x + width, y + radius); ctx.li...
https://github.com/LJ666-ui/harmony-health-care
43686daf3ee020be1b59de39bf20598a7cd34cd5
github
DaLongZhuaZi/manxia
entry/src/main/ets/Framework/Source/SourceManager.ets
arkts
importFromJSON
从JSON字符串导入图源
async importFromJSON(jsonContent: string): Promise<ImportResult> { try { // 解析JSON const config: ESObject = SafeUtils.parseObj(jsonContent) as ESObject; // 检查metadata if (!config.metadata) { return { success: false, error: '缺少metadata配置' }; ...
AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left importFromJSON AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left jsonContent AST#identifier#Right AST#type_annotation#Left AST#:#...
async importFromJSON(jsonContent: string): Promise<ImportResult> { try { // 解析JSON const config: ESObject = SafeUtils.parseObj(jsonContent) as ESObject; // 检查metadata if (!config.metadata) { return { success: false, error: '缺少metadata配置' }; ...
https://github.com/DaLongZhuaZi/manxia
410072952d7dbafa4cc70120f36818cf469bb038
github
daugf2527/harmonyos-libretro-emulator
entry/src/main/ets/common/ErrorCodes.ets
arkts
findByCode
根据字符串错误码查找错误定义
static findByCode(code: string): ErrorCodeDefinition | undefined { for (const definition of ALL_ERROR_CODE_DEFINITIONS) { if (definition.code === code) { return definition; } } return undefined; }
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left findByCode AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left code AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left strin...
static findByCode(code: string): ErrorCodeDefinition | undefined { for (const definition of ALL_ERROR_CODE_DEFINITIONS) { if (definition.code === code) { return definition; } } return undefined; }
https://github.com/daugf2527/harmonyos-libretro-emulator
1a0bbfa29e60bf75b6e51a005b5ff13a59a44193
github
LJ666-ui/harmony-health-care
entry/src/main/ets/common/utils/AccessibilityConfig.ets
arkts
getRelativeLuminance
计算相对亮度
private static getRelativeLuminance(color: string): number { // 解析RGB值 const hex = color.replace('#', ''); const r = parseInt(hex.substring(0, 2), 16) / 255; const g = parseInt(hex.substring(2, 4), 16) / 255; const b = parseInt(hex.substring(4, 6), 16) / 255; // 计算相对亮度 const R = r <= ...
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#identifier#Left static AST#identifier#Right AST#call_expression#Left AST#identifier#Left getRelativeLuminance AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left color AST#identifier#Right AST#...
private static getRelativeLuminance(color: string): number { // 解析RGB值 const hex = color.replace('#', ''); const r = parseInt(hex.substring(0, 2), 16) / 255; const g = parseInt(hex.substring(2, 4), 16) / 255; const b = parseInt(hex.substring(4, 6), 16) / 255; // 计算相对亮度 const R = r <= ...
https://github.com/LJ666-ui/harmony-health-care
a0fec381223fe521537203353588ccbd857d4910
github
HarmonyOS_Samples/MusicHome
features/player/src/main/ets/viewmodel/PlayerViewModel.ets
arkts
pushPlaylistDetail
Navigates the given stack to the playlist detail route by name.
public pushPlaylistDetail(pageIndexInfos: NavPathStack): void { pageIndexInfos.replacePathByName(RouterUrlConstants.PLAYLIST_DETAIL, null); }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left pushPlaylistDetail AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left pageIndexInfos AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#identifier#Left Nav...
public pushPlaylistDetail(pageIndexInfos: NavPathStack): void { pageIndexInfos.replacePathByName(RouterUrlConstants.PLAYLIST_DETAIL, null); }
https://gitcode.com/HarmonyOS_Samples/MusicHome
6cfd05e795603fdd56c63a1ded701747c7645342
gitcode
iop123123/arkts-static-skills
docs/ArkTS-Language-Guide/08-Stdlib/stdlib-source/std/core/Jsonx.ets
arkts
tryAsBoolean
Attempts to get a boolean value from an object by key. Returns undefined if the key is not found or if the value is not a boolean. @param {string} key - The key to look up @returns {boolean} The boolean value if found, undefined otherwise
tryAsBoolean(): boolean | undefined { return this.jsonType == JsonType.JsonTrue || this.jsonType == JsonType.JsonFalse ? this.maybeBoolValue : undefined }
AST#program#Left AST#expression_statement#Left AST#binary_expression#Left AST#call_expression#Left AST#identifier#Left tryAsBoolean AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#boolean#...
tryAsBoolean(): boolean | undefined { return this.jsonType == JsonType.JsonTrue || this.jsonType == JsonType.JsonFalse ? this.maybeBoolValue : undefined }
https://gitcode.com/iop123123/arkts-static-skills
297eb47ca03edce0b11cc8c252aa865a04ebba37
gitcode
openharmony/applications_mms
entry/src/main/ets/service/ConversationListService.ets
arkts
insertSessionDraft
Adding a session draft list @param valueBucket New Data @callback callback
public insertSessionDraft(actionData, callback, context): void { let param: LooseObject = this.dealSendResults(actionData); // Check whether a session list has been created this.querySessionByTelephone(param.telephone, res => { if (res.code == common.int.SUCCESS && res.response.i...
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left insertSessionDraft AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left actionData AST#identifier#Right AST#,#Left , AST#,#Right AST#identifier#Left callback AST#identifie...
public insertSessionDraft(actionData, callback, context): void { let param: LooseObject = this.dealSendResults(actionData); // Check whether a session list has been created this.querySessionByTelephone(param.telephone, res => { if (res.code == common.int.SUCCESS && res.response.i...
https://gitee.com/openharmony/applications_mms.git
f437c976ad66209df8104c3471968833839b79b5
gitee
Joker-x-dev/CoolMallArkTS
core/navigation/src/main/ets/order/OrderNavigator.ets
arkts
toLogistics
跳转到订单物流 @param {number} orderId - 订单 ID @returns {void} 无返回值
static toLogistics(orderId: number): void { const params: OrderIdParam = { orderId }; navigateTo(OrderRoutes.Logistics, params); }
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left toLogistics AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left orderId AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#number#Left number AST#number#Rig...
static toLogistics(orderId: number): void { const params: OrderIdParam = { orderId }; navigateTo(OrderRoutes.Logistics, params); }
https://github.com/Joker-x-dev/CoolMallArkTS
7a5d5a3b6d460b714aed0ac209c1db7e447e1c60
github
751496032/ZRouter
RouterApi/src/main/ets/lifecycle/LifecycleRegistry.ets
arkts
addObserver
添加生命周期观察者 @param observer @param inRootView 当前页面是否是Navigation根视图中 可选参数
public addObserver<T extends ILifecycleObserver>(observer: T, inRootView: boolean = false) { RouterMgr.getInstance().lifecycleMgr.addObserver(observer, this.targetClassName, inRootView); }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#identifier#Left addObserver AST#identifier#Right AST#<#Left < AST#<#Right AST#type_identifier#Left T AST#type_identifier#Right AST#extends#Left extends AST#extends#Right AST#ERROR#Left AST#type_identifier#Left ILifecycleObserver AST#type_identi...
public addObserver<T extends ILifecycleObserver>(observer: T, inRootView: boolean = false) { RouterMgr.getInstance().lifecycleMgr.addObserver(observer, this.targetClassName, inRootView); }
https://github.com/751496032/ZRouter/blob/bacb12ccf3187546fe287cff3c63f2925ce941d6/RouterApi/src/main/ets/lifecycle/LifecycleRegistry.ets#L31-L34
e17e4fadf987b5153277d411f8dd1f5594407d01
github
HarmonyOS_Samples/BestPracticeSnippets
WaterFlowSample/entry/src/main/ets/pages/FadingEdgePage.ets
arkts
initSections
5、Initialise group data.
initSections(): void { let sectionOptions: SectionOptions[] = []; let count: number = 0; let oneOrTwo: number = 0; let dataCount: number = this.dataSource.totalCount(); while (count < dataCount) { if (dataCount - count < 96) { this.dataSection.itemsCount = dataCount - count; ...
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left initSections AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Left : AST#:#Right AST#void#Left void AST#void#Right AST#ERROR#Right AST#statement_block...
initSections(): void { let sectionOptions: SectionOptions[] = []; let count: number = 0; let oneOrTwo: number = 0; let dataCount: number = this.dataSource.totalCount(); while (count < dataCount) { if (dataCount - count < 96) { this.dataSection.itemsCount = dataCount - count; ...
https://gitcode.com/HarmonyOS_Samples/BestPracticeSnippets
dac1b69063a556db1c65380a5df68c73e90ed49d
gitcode
openharmony/codelabs
Security/AccessPermission/entry/src/main/ets/common/util/PermissionUtil.ets
arkts
applyPermission
Applying for Permissions. @returns Permission application result.
async applyPermission() { let atManager = abilityAccessCtrl.createAtManager(); let data = await atManager.requestPermissionsFromUser(getContext(this), [CommonConstants.PERMISSION]); let grantStatus: Array<number> = data.authResults; let length: number = grantStatus.length; if (length === 0) { ...
AST#program#Left AST#expression_statement#Left AST#identifier#Left async AST#identifier#Right AST#ERROR#Left AST#identifier#Left applyPermission AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#formal_parameters#Right AST#{#Left { AST#{#Right AST#ERROR#Right AST#expr...
async applyPermission() { let atManager = abilityAccessCtrl.createAtManager(); let data = await atManager.requestPermissionsFromUser(getContext(this), [CommonConstants.PERMISSION]); let grantStatus: Array<number> = data.authResults; let length: number = grantStatus.length; if (length === 0) { ...
https://gitee.com/openharmony/codelabs.git
a4c11fc8c93187f4e7a954ca5669bbb5bb9ad023
gitee
RedRackham-R/WanAndroidHarmoney
entry/src/main/ets/global/viewmodel/GlobalUserViewModel.ets
arkts
login
登录 @param username wanandroid账号 @param password 密码
async login(username: string, password: string) { try { const result = await WanHttpClient.login(username, password); if (result.response.errorCode === 0) { await this.updateLoginInfo(result.response.data, result.cookies.join(';'), password); EventBus.getInstance().post(WanEventId.EVEN...
AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left login AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left username AST#identifier#Right AST#type_annotation#Left AST#:#Left : AST#:...
async login(username: string, password: string) { try { const result = await WanHttpClient.login(username, password); if (result.response.errorCode === 0) { await this.updateLoginInfo(result.response.data, result.cookies.join(';'), password); EventBus.getInstance().post(WanEventId.EVEN...
https://github.com/RedRackham-R/WanAndroidHarmoney
8aaac42078519b68ff9d7bfeb2f0224e10928364
github
who7708/harmonyos-codelabs
HmosWorld/commons/common/src/main/ets/service/repository/ResourcesRepository.ets
arkts
getHomeResources
Get resource data on home page @param pageNum @returns
getHomeResources(): Promise<NetworkNewsResources> { return this.funNetwork.getHomeResources(); }
AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#member_expression#Left AST#member_expression#Left AST#binary_expression#Left AST#call_expression#Left AST#identifier#Left getHomeResources AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#R...
getHomeResources(): Promise<NetworkNewsResources> { return this.funNetwork.getHomeResources(); }
https://github.com/who7708/harmonyos-codelabs
960b4b00bb156c8f7b0ec344c528b2ed4d161a47
github
DaLongZhuaZi/manxia
entry/src/main/ets/Framework/Managers/ChangelogManager.ets
arkts
shouldShowChangelog
检查是否需要显示更新日志(新版本首次启动) 使用 versionCode 进行比较,确保数字版本号变更也能触发 注意:首次安装时不显示更新日志,只在版本升级时显示
shouldShowChangelog(): boolean { if (!this.currentVersionCode) { return false; } // 首次安装时不显示更新日志 if (this.isFirstInstall()) { return false; } // 使用 versionCode 比较,只要版本号增加就显示更新日志 return this.currentVersionCode > this.lastShownVersionCode; }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left shouldShowChangelog AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Left : AST#:#Right AST#boolean#Left boolean AST#boolean#Right AST#ERROR#Right AST...
shouldShowChangelog(): boolean { if (!this.currentVersionCode) { return false; } // 首次安装时不显示更新日志 if (this.isFirstInstall()) { return false; } // 使用 versionCode 比较,只要版本号增加就显示更新日志 return this.currentVersionCode > this.lastShownVersionCode; }
https://github.com/DaLongZhuaZi/manxia
b41210cbb547d1f4185c440ba43af513d4530e03
github
dingzhilin1990/zhilinclaw
src/agents/HanwudiWorkflow.ets
arkts
step4_Execution
步骤 4: 任务执行
private async step4_Execution(strategyResult: any): Promise<any> { this.addLog(4, 'Coordinator', '开始任务协调', 'started'); // 4.1 协调官拆解任务 const coordInput = JSON.stringify(strategyResult.documents); const coordResult = await this.coordinator.process(coordInput); this.addLog(4, 'Coordinator',...
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#identifier#Left async AST#identifier#Right AST#call_expression#Left AST#identifier#Left step4_Execution AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left strategyResult AST#identifier#Right AST#ERROR#Left A...
private async step4_Execution(strategyResult: any): Promise<any> { this.addLog(4, 'Coordinator', '开始任务协调', 'started'); // 4.1 协调官拆解任务 const coordInput = JSON.stringify(strategyResult.documents); const coordResult = await this.coordinator.process(coordInput); this.addLog(4, 'Coordinator',...
https://github.com/dingzhilin1990/zhilinclaw
cb68933655804dcc509670724a33fd518ff06759
github
revalue-o/HarmonyOS-Next-Hook-demo
source_codes/ArkTS-inject/entry/src/main/ets/utils/LocationUtil.ets
arkts
getPriorityDescription
获取位置优先级描述
static getPriorityDescription(priority: number): string { switch (priority) { case geoLocationManager.LocationRequestPriority.LOW_POWER: return '低功耗'; case geoLocationManager.LocationRequestPriority.FIRST_FIX: return '快速定位'; case geoLocationManager.LocationRequestPriority.ACCURAC...
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left getPriorityDescription AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left priority AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#number#Left number AS...
static getPriorityDescription(priority: number): string { switch (priority) { case geoLocationManager.LocationRequestPriority.LOW_POWER: return '低功耗'; case geoLocationManager.LocationRequestPriority.FIRST_FIX: return '快速定位'; case geoLocationManager.LocationRequestPriority.ACCURAC...
https://github.com/revalue-o/HarmonyOS-Next-Hook-demo
dddb52e83a95c68b2c5e3e74b173dde98dfe0ca3
github
HarmonyOS_Samples/guide-snippets
ArkGraphics3D/entry/src/main/ets/common/utils.ets
arkts
length
Get length
function length(quat: Quaternion): number { return Math.sqrt(quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w); }
AST#program#Left AST#function_declaration#Left AST#function#Left function AST#function#Right AST#identifier#Left length AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left quat AST#identifier#Right AST#type_annotation#Left AST#:#Left : AST#:#Right AST...
function length(quat: Quaternion): number { return Math.sqrt(quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w); }
https://gitcode.com/HarmonyOS_Samples/guide-snippets
b7e0537d334ec0aff58925587f346e561d67724f
gitcode
tdcare/tdwebrtc
src/main/ets/AudioCapture.ets
arkts
getIsRunning
是否正在采集
public getIsRunning(): boolean { return this.isRunning; }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left getIsRunning AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Left : AST#:#Right AST#boolean#Left boolean AST#...
public getIsRunning(): boolean { return this.isRunning; }
https://github.com/tdcare/tdwebrtc
118462a2f9185cf0f3fda93241b30b6261398063
github
openharmony/app_samples
ETSUI/Gallery/entry/src/main/ets/MainAbility/common/components/getColor.ets
arkts
getColor
点击获取颜色
getColor(event) { let data = this.context.getImageData(Math.round(event.x), Math.round(event.y), 2, 2) return `rgb(${data.data[0]},${data.data[1]},${data.data[2]})` }
AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left getColor AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left event AST#identifier#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#;#Left AST#;#Right AST#expressio...
getColor(event) { let data = this.context.getImageData(Math.round(event.x), Math.round(event.y), 2, 2) return `rgb(${data.data[0]},${data.data[1]},${data.data[2]})` }
https://gitee.com/openharmony/app_samples.git
900282154b07c4750442cb7989974290bca0953e
gitee
Mydstiny/RemoteDeskHarmonyOS
entry/src/main/ets/services/LightSensingService.ets
arkts
onLightChange
注册光感变化监听
onLightChange(callback: (lux: number) => void): void { this.listeners.push({ callback: callback }); }
AST#program#Left AST#ERROR#Left AST#identifier#Left onLightChange AST#identifier#Right AST#(#Left ( AST#(#Right AST#call_expression#Left AST#identifier#Left callback AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#ERROR#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Lef...
onLightChange(callback: (lux: number) => void): void { this.listeners.push({ callback: callback }); }
https://github.com/Mydstiny/RemoteDeskHarmonyOS
f8308fedcf3ecc9b888164f071e4457fcded04ba
github
DaLongZhuaZi/manxia
entry/src/main/ets/Framework/Cache/DiskCacheManager.ets
arkts
getCacheFilePath
获取缓存文件路径(用于同步到数据库)
public async getCacheFilePath(url: string): Promise<string | null> { if (!this.initialized) { return null; } try { const cacheKey = await this.generateCacheKey(url); const entry = this.cacheIndex.get(cacheKey); if (entry) { const fileExists = await fs.access(entry.filePat...
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#identifier#Left async AST#identifier#Right AST#call_expression#Left AST#identifier#Left getCacheFilePath AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left url AST#identifier#Right AST#:#Left : A...
public async getCacheFilePath(url: string): Promise<string | null> { if (!this.initialized) { return null; } try { const cacheKey = await this.generateCacheKey(url); const entry = this.cacheIndex.get(cacheKey); if (entry) { const fileExists = await fs.access(entry.filePat...
https://github.com/DaLongZhuaZi/manxia
9beb4ae1e787fcaecb569532541760f26477546d
github
iop123123/arkts-static-skills
docs/ArkTS-Language-Guide/08-Stdlib/stdlib-source/std/core/json.ets
arkts
createFloatFromJSONValue
Creates a Float instance based on JSONValue @param { Float } this JSONValue - a JSON representation @param { JSONValue } json @returns { Float } - true if JSON encodes true literal, false if JSON encodes false literal @throws { JSONTypeError } if json does not encode a valid boolean literal
function createFloatFromJSONValue(json: JSONValue): Float { if (json instanceof JSONNumber) { let val = (json as JSONNumber).value if (-Float.MAX_VALUE <= val && val <= Float.MAX_VALUE) { return val.toFloat() } } throw new JSONTypeError('Cannot create Double from JSON', {...
AST#program#Left AST#function_declaration#Left AST#function#Left function AST#function#Right AST#identifier#Left createFloatFromJSONValue AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left json AST#identifier#Right AST#type_annotation#Left AST#:#Left...
function createFloatFromJSONValue(json: JSONValue): Float { if (json instanceof JSONNumber) { let val = (json as JSONNumber).value if (-Float.MAX_VALUE <= val && val <= Float.MAX_VALUE) { return val.toFloat() } } throw new JSONTypeError('Cannot create Double from JSON', {...
https://gitcode.com/iop123123/arkts-static-skills
8c7b01f75d63bbe16ef417555e041b80e715c8e0
gitcode
Explore-In-HMOS-Wearable/stack-game-with-unity-tuanjie
StackGameWithUnityDevEcoExport/tuanjieLib/src/main/ets/workers/WorkerProxy.ets
arkts
postMessage
post message to worker thread. For now we have only one worker - TuanjieMainWorker @param msg
public static postMessage(msg: ESObject, targetWorker: string | undefined) { if (targetWorker === undefined) WorkerProxy.Instance().threadWorker.postMessage(msg); // for now we have only worker }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#identifier#Left static AST#identifier#Right AST#call_expression#Left AST#identifier#Left postMessage AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left msg AST#identifier#Right AST#:#Left : AST#:...
public static postMessage(msg: ESObject, targetWorker: string | undefined) { if (targetWorker === undefined) WorkerProxy.Instance().threadWorker.postMessage(msg); // for now we have only worker }
https://github.com/Explore-In-HMOS-Wearable/stack-game-with-unity-tuanjie
5a01827cb6cad6fef1f66e97cf3a30d8942edcc7
github
openharmony-sig/arkcompiler_runtime_core
plugins/ets/stdlib/escompat/TypedUArrays.ets
arkts
constructor
Creates a copy of BigUint64Array. @param other data initializer
public constructor(other: BigUint64Array) { this.buffer = other.buffer.slice(0, other.buffer.byteLength) this.byteLength = other.byteLength this.length = other.length }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left constructor AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left other AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left Big...
public constructor(other: BigUint64Array) { this.buffer = other.buffer.slice(0, other.buffer.byteLength) this.byteLength = other.byteLength this.length = other.length }
https://gitee.com/openharmony-sig/arkcompiler_runtime_core.git
6e8186d75b9cfd6f349b2b4f6b15e427020868df
gitee
iop123123/arkts-static-skills
docs/ArkTS-Language-Guide/08-Stdlib/stdlib-source/std/core/Date.ets
arkts
setUTCMonth
Sets the month for a specified date according to universal time. @param { int } month new month @returns { long } get new date value @syscap SystemCapability.Utils.Lang @FaAndStageModel
public setUTCMonth(month: int): long { let yearsNow: int = this.getUTCFullYear(); let yearsOffSet: int = Math.floor(month / 12.0).toInt(); let yearsNew: int = yearsNow + yearsOffSet; let adjustedMonth: int = ((month % 12) + 12) % 12; if (yearsNew !== yearsNow) { t...
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left setUTCMonth AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left month AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#identifier#Left int AST#identifier#...
public setUTCMonth(month: int): long { let yearsNow: int = this.getUTCFullYear(); let yearsOffSet: int = Math.floor(month / 12.0).toInt(); let yearsNew: int = yearsNow + yearsOffSet; let adjustedMonth: int = ((month % 12) + 12) % 12; if (yearsNew !== yearsNow) { t...
https://gitcode.com/iop123123/arkts-static-skills
eb2fc57bd7f94759ef6cc139dfa0cc4850e46264
gitcode
openharmony/codelabs
ETSUI/LifeTrack/entry/src/main/ets/pages/ContactManager.ets
arkts
addContact
添加联系人
public async addContact(name: string, phone: string): Promise<OperationResult> { // 验证输入 if (!name || name.trim() === '') { return { success: false, message: '姓名不能为空' }; } if (!phone || phone.trim() === '') { return { success: false, message: '电话号码不能为空' }; } // 验证电话号码格式(简单验证) ...
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#identifier#Left async AST#identifier#Right AST#call_expression#Left AST#identifier#Left addContact AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left name AST#identifier#Right AST#:#Left : AST#:#...
public async addContact(name: string, phone: string): Promise<OperationResult> { // 验证输入 if (!name || name.trim() === '') { return { success: false, message: '姓名不能为空' }; } if (!phone || phone.trim() === '') { return { success: false, message: '电话号码不能为空' }; } // 验证电话号码格式(简单验证) ...
https://gitcode.com/openharmony/codelabs
96312076e88d9223d04ca313392235891422233c
gitcode
DaLongZhuaZi/manxia
entry/src/main/ets/Framework/Managers/EnhancedBackupManager.ets
arkts
restoreSourceIcons
恢复图源icon文件
private async restoreSourceIcons(iconsDir: string): Promise<void> { const filesDir = this.sandboxManager.getDirectory('files'); const targetDir = `${filesDir}/extensions-source/icons`; // 确保目标目录存在 const parentDir = `${filesDir}/extensions-source`; if (!SafeFileUtils.accessSync(parentDir)) { ...
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#identifier#Left async AST#identifier#Right AST#call_expression#Left AST#identifier#Left restoreSourceIcons AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left iconsDir AST#identifier#Right AST#ERROR#Left AST#...
private async restoreSourceIcons(iconsDir: string): Promise<void> { const filesDir = this.sandboxManager.getDirectory('files'); const targetDir = `${filesDir}/extensions-source/icons`; // 确保目标目录存在 const parentDir = `${filesDir}/extensions-source`; if (!SafeFileUtils.accessSync(parentDir)) { ...
https://github.com/DaLongZhuaZi/manxia
f8871ceff99adace46aa8dd1d2a33214ce04d4be
github
DaLongZhuaZi/manxia
entry/src/main/ets/Utils/MetadataXmlGenerator.ets
arkts
generateComicInfoXml
生成ComicInfo.xml内容(漫画元数据) 遵循ComicInfo.xml标准格式
static generateComicInfoXml(metadata: MangaMetadata): string { const lines: string[] = []; lines.push('<?xml version="1.0" encoding="UTF-8"?>'); lines.push('<ComicInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">'); if (metadata.title) { ...
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left generateComicInfoXml AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left metadata AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identif...
static generateComicInfoXml(metadata: MangaMetadata): string { const lines: string[] = []; lines.push('<?xml version="1.0" encoding="UTF-8"?>'); lines.push('<ComicInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">'); if (metadata.title) { ...
https://github.com/DaLongZhuaZi/manxia
c60c6016224f33ade733d5fbe0ae0a2834aac3bb
github
openharmony-tpc/ohos_mpchart
library/src/main/ets/components/renderer/PieChartRenderer.ets
arkts
drawCenterText
draws the description text in the center of the pie chart makes most sense when center-hole is enabled
protected drawCenterText(c: CanvasRenderingContext2D): void { let centerText: string = this.mChart.getCenterText(); if (this.mChart.isDrawCenterTextEnabled() && centerText != null) { let center: MPPointF = this.mChart.getCenterCircleBox(); let offset: MPPointF = this.mChart.getCenterTextOffset(...
AST#program#Left AST#ERROR#Left AST#protected#Left protected AST#protected#Right AST#call_expression#Left AST#identifier#Left drawCenterText AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left c AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#...
protected drawCenterText(c: CanvasRenderingContext2D): void { let centerText: string = this.mChart.getCenterText(); if (this.mChart.isDrawCenterTextEnabled() && centerText != null) { let center: MPPointF = this.mChart.getCenterCircleBox(); let offset: MPPointF = this.mChart.getCenterTextOffset(...
https://gitee.com/openharmony-tpc/ohos_mpchart.git
986af3cd8a255f189935d5928caaf2dceff50119
gitee
HateCodingHateCoding/Bullying-detection-system-v2-public
frontend/AnQ/entry/src/main/ets/common/WaterFlowDataSource.ets
arkts
notifyDataReload
通知控制器数据重新加载
notifyDataReload(): void { this.listeners.forEach(listener => { listener.onDataReloaded() }) }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left notifyDataReload AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Left : AST#:#Right AST#void#Left void AST#void#Right AST#ERROR#Right AST#statement_b...
notifyDataReload(): void { this.listeners.forEach(listener => { listener.onDataReloaded() }) }
https://github.com/HateCodingHateCoding/Bullying-detection-system-v2-public
719a92cc9168611d9bfdc2b8fa731deb306c3416
github
AlkaidLab/moonlight-harmony
entry/src/main/ets/service/input/GamepadVibrationService.ets
arkts
triggerTimeVibration
使用时长模式实现持续震动
private triggerTimeVibration(lowIntensity: number, highIntensity: number): void { const combinedIntensity = Math.max(lowIntensity, highIntensity); if (combinedIntensity < 5) return; vibrator.startVibration({ type: 'time', duration: 500 }, { id: 0, usage: 'physicalFeedback' ...
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left triggerTimeVibration AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left lowIntensity AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#number#Left numb...
private triggerTimeVibration(lowIntensity: number, highIntensity: number): void { const combinedIntensity = Math.max(lowIntensity, highIntensity); if (combinedIntensity < 5) return; vibrator.startVibration({ type: 'time', duration: 500 }, { id: 0, usage: 'physicalFeedback' ...
https://github.com/AlkaidLab/moonlight-harmony
3f4c92960e2399e53e5300efe1799a9bef6b4abb
github
openharmony/codelabs
ETSUI/LifeTrack/entry/src/main/ets/pages/StepTrackerPage.ets
arkts
formatDateDisplay
格式化日期显示
formatDateDisplay(dateStr: string): string { const date = new Date(dateStr); const today = new Date(); if (date.toDateString() === today.toDateString()) { return '今天'; } const yesterday = new Date(today); yesterday.setDate(yesterday.getDate() - 1); if (date.toDateString() === yest...
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left formatDateDisplay AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left dateStr AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string AST#string#Right AST#ERROR#Right AST#)#Left ) AS...
formatDateDisplay(dateStr: string): string { const date = new Date(dateStr); const today = new Date(); if (date.toDateString() === today.toDateString()) { return '今天'; } const yesterday = new Date(today); yesterday.setDate(yesterday.getDate() - 1); if (date.toDateString() === yest...
https://gitcode.com/openharmony/codelabs
3c33e916ad3600acb9894889a368f63d355348ee
gitcode
DaLongZhuaZi/manxia
entry/src/main/ets/Framework/Novel/LegadoRuleAnalyzer.ets
arkts
parseRule
解析规则字符串,识别规则模式
parseRule(ruleStr: string): LegadoParsedRule { if (!ruleStr || ruleStr.trim() === '') { return { mode: LegadoRuleMode.Default, rule: '' }; } const parseCacheKey = `${this.isJSON ? '1' : '0'}|${ruleStr}`; const cachedRule = LegadoRuleAnalyzer.PARSED_RULE_CACHE.get(parseCach...
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left parseRule AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left ruleStr AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string AST#string#Right AST#ERROR#Right AST#)#Left ) AST#)#Righ...
parseRule(ruleStr: string): LegadoParsedRule { if (!ruleStr || ruleStr.trim() === '') { return { mode: LegadoRuleMode.Default, rule: '' }; } const parseCacheKey = `${this.isJSON ? '1' : '0'}|${ruleStr}`; const cachedRule = LegadoRuleAnalyzer.PARSED_RULE_CACHE.get(parseCach...
https://github.com/DaLongZhuaZi/manxia
553570c75c45a12627a28bd39a138ff8eb871bab
github
openharmony-sig/flutter_audioplayers
packages/audioplayers_ohos/ohos/src/main/ets/components/plugin/player/SoundPoolPlayer.ets
arkts
dispose
For the onLoadComplete listener, track which sound id is associated with which player. An entry only exists until it has been loaded. This is to keep track of the players which share the same sound id, referenced by url. When a player release()s, it is removed from the associated player list. The last player to be remo...
dispose() { this.soundPool.off('loadComplete'); this.soundPool.release(); this.soundIdToPlayer.clear(); this.urlToPlayers.clear(); }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left dispose AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#ERROR#Right AST#statement_block#Left AST#{#Left { AST#{#Right AST#expression_statement#Left AST...
dispose() { this.soundPool.off('loadComplete'); this.soundPool.release(); this.soundIdToPlayer.clear(); this.urlToPlayers.clear(); }
https://gitee.com/openharmony-sig/flutter_audioplayers.git
3fe31be83ab5b2dca844bb510fb8776a6d85db89
gitee
xblLab/HarmonyProjectTemplate
commons/lib_account/src/main/ets/services/AccountApi.ets
arkts
getHuaweiUserAgreeInfo
查询华为用户协议内容 @returns
public getHuaweiUserAgreeInfo() { return ProtocolData.huaweiUserProtocol; }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left getHuaweiUserAgreeInfo AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#ERROR#Right AST#statement_block#Left AST...
public getHuaweiUserAgreeInfo() { return ProtocolData.huaweiUserProtocol; }
https://github.com/xblLab/HarmonyProjectTemplate
8b0a58c523cb174b94da5f916af3234333d1cfef
github
codelably/HCompass
core/network/src/main/ets/RequestHelper.ets
arkts
loading
配置是否展示 loading @param enable 是否展示 @returns 当前实例
loading(enable: boolean = true): RequestHelper<T> { this.useLoading = enable; return this; }
AST#program#Left AST#expression_statement#Left AST#binary_expression#Left AST#binary_expression#Left AST#call_expression#Left AST#identifier#Left loading AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left enable AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Rig...
loading(enable: boolean = true): RequestHelper<T> { this.useLoading = enable; return this; }
https://github.com/codelably/HCompass
8f3c7ad847e1a29d023f79db92f6e9980b289741
github
LongLiveY96/chatcube
entry/src/main/ets/services/ModelCapabilityMatcher.ets
arkts
savePersistedLogoIndex
保存模型图标索引到偏好设置
async savePersistedLogoIndex(): Promise<void> { const entries: PersistedLogoIndexEntry[] = [] this.persistedLogoIndex.forEach((logoUrl: string, modelId: string) => { if (modelId !== '' && logoUrl !== '') { entries.push({ modelId: modelId, logoUrl: logoUrl }) } ...
AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left savePersistedLogoIndex AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#formal_parameters#Right AST#type_annotation#Left AST#:#Left : AST#:#Right A...
async savePersistedLogoIndex(): Promise<void> { const entries: PersistedLogoIndexEntry[] = [] this.persistedLogoIndex.forEach((logoUrl: string, modelId: string) => { if (modelId !== '' && logoUrl !== '') { entries.push({ modelId: modelId, logoUrl: logoUrl }) } ...
https://github.com/LongLiveY96/chatcube
58e7b36775f6d2810dac3522bfa24376fef6fc77
github
who7708/harmonyos-codelabs
HmosWorld/commons/common/src/main/ets/service/repository/TopicsRepository.ets
arkts
getTopics
Get Topic List by the userid. @param userId @returns
getTopics(userId: string): Promise<Topic[]> { return this.topicService.getTopics(userId); }
AST#program#Left AST#expression_statement#Left AST#instantiation_expression#Left AST#call_expression#Left AST#identifier#Left getTopics AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left userId AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#...
getTopics(userId: string): Promise<Topic[]> { return this.topicService.getTopics(userId); }
https://github.com/who7708/harmonyos-codelabs
90c62ab173dc9c23a8f03a1039a25c246184c5bb
github
openharmony-sig/fluttertpc_qr_code_scanner
ohos/ohos/src/main/ets/components/plugin/libs/CameraService.ets
arkts
isTorchSupported
支持手电筒
isTorchSupported(): boolean { let isSupported = this.cameraManager!.isTorchSupported(); return isSupported; }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left isTorchSupported AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Left : AST#:#Right AST#boolean#Left boolean AST#boolean#Right AST#ERROR#Right AST#st...
isTorchSupported(): boolean { let isSupported = this.cameraManager!.isTorchSupported(); return isSupported; }
https://gitee.com/openharmony-sig/fluttertpc_qr_code_scanner.git
0bec10d88f99fd94385d50aab0a80119bd0027be
gitee
iop123123/arkts-static-skills
docs/ArkTS-Language-Guide/08-Stdlib/stdlib-source/std/core/TypedArrays.ets
arkts
findLastIndex
Finds an index of the last element in the Float64Array that satisfies the condition @param { function } fn - condition @returns { int } - the index of the last element that satisfies fn, -1 otherwise @syscap SystemCapability.Utils.Lang @FaAndStageModel
public findLastIndex(fn: (val: number, index: int, array: Float64Array) => boolean): int { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) if (fn((val).toDouble(), i, this)) { return i } } return -1 }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left findLastIndex AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#binary_expression#Left AST#call_expression#Left AST#identifier#Left fn AST#identifier#Right AST#ERROR#Left AST#:#Left : ...
public findLastIndex(fn: (val: number, index: int, array: Float64Array) => boolean): int { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) if (fn((val).toDouble(), i, this)) { return i } } return -1 }
https://gitcode.com/iop123123/arkts-static-skills
93ab251f3de2cd9340688e754c2a7547142914b1
gitcode
CPF-ApplicationTPC/openharmony_tpc_samples
SwipeMenuListView/library/src/main/ets/utils/SwipeStateController.ets
arkts
unregisterItemController
注销列表项控制器
public unregisterItemController(position: number): void { this._itemControllers.delete(position); }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left unregisterItemController AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left position AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#number#Left number ...
public unregisterItemController(position: number): void { this._itemControllers.delete(position); }
https://gitcode.com/CPF-ApplicationTPC/openharmony_tpc_samples
0f97f7a25da251c9797d6ed597271786857eb765
gitcode
AlkaidLab/moonlight-harmony
entry/src/main/ets/service/SettingsService.ets
arkts
shouldResumeStream
是否恢复上次串流
async shouldResumeStream(): Promise<boolean> { return await this.getBoolean(SettingsKeys.RESUME_STREAM, false); }
AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left shouldResumeStream AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#formal_parameters#Right AST#type_annotation#Left AST#:#Left : AST#:#Right AST#g...
async shouldResumeStream(): Promise<boolean> { return await this.getBoolean(SettingsKeys.RESUME_STREAM, false); }
https://github.com/AlkaidLab/moonlight-harmony
0f9850d3bb5933b2a3f30a9a7bec519e9c7cb578
github
Joker-x-dev/CoolMallArkTS
feature/launch/src/main/ets/viewmodel/GuideViewModel.ets
arkts
onPageChange
页码切换 @param {number} index - 当前页索引 @returns {void} 无返回值
onPageChange(index: number): void { this.currentPageIndex = index; }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left onPageChange AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left index AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left number AST#identifier#Right AST#)#Left ) A...
onPageChange(index: number): void { this.currentPageIndex = index; }
https://github.com/Joker-x-dev/CoolMallArkTS
7a31639c8cc92fa5d079edc059d27d7e8b33b668
github
openharmony/applications_calendar_data
datamanager/src/main/ets/processor/alerts/AlertsSubscriber.ets
arkts
unSubscribe
取消订阅公共事件
unSubscribe() { if (this.subscriber != null) { commonEventManager.unsubscribe(this.subscriber, (err: BusinessError) => { if (err?.code) { Log.error(TAG, `UnsubscribeCallBack err= = ${JSON.stringify(err)}`); } else { Log.info(TAG, "Unsubscribe"); this.subscriber ...
AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left unSubscribe AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#;#Left AST#;#Right AST#expression_statement#Right AST#statement_block#Left A...
unSubscribe() { if (this.subscriber != null) { commonEventManager.unsubscribe(this.subscriber, (err: BusinessError) => { if (err?.code) { Log.error(TAG, `UnsubscribeCallBack err= = ${JSON.stringify(err)}`); } else { Log.info(TAG, "Unsubscribe"); this.subscriber ...
https://gitee.com/openharmony/applications_calendar_data.git
9d06212c7b52a58527c818fdaf2c2a122a3e41d1
gitee
aimilin6688/KeePassHO
entry/src/main/ets/services/SupportService.ets
arkts
isSupported
查询账户是否已经支持过 @returns
private static isSupported(): Promise<boolean> { try { const parameter: iap.QueryPurchasesParameter = { productType: iap.ProductType.CONSUMABLE, queryType: iap.PurchaseQueryType.ALL } return iap.queryPurchases(CommonUtils.getContext(), parameter).then((data: iap...
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#identifier#Left static AST#identifier#Right AST#call_expression#Left AST#identifier#Left isSupported AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#...
private static isSupported(): Promise<boolean> { try { const parameter: iap.QueryPurchasesParameter = { productType: iap.ProductType.CONSUMABLE, queryType: iap.PurchaseQueryType.ALL } return iap.queryPurchases(CommonUtils.getContext(), parameter).then((data: iap...
https://github.com/aimilin6688/KeePassHO/blob/6ac299504782abfed903b23a13c736b0841388d9/entry/src/main/ets/services/SupportService.ets#L136-L155
c5281d3ebc522d50b75c5925a1b0872556c3dc07
github
openharmony/codelabs
ETSUI/Habit/entry/src/main/ets/view/component/PieChart.ets
arkts
draw
🎨 核心绘图逻辑 (保持不变)
draw() { // 1. 计算总数 let total = 0; this.data.forEach(item => total += item.count); // 如果没有数据,画个灰色的圆 if (total === 0) { this.context.clearRect(0, 0, 140, 140); this.context.beginPath(); this.context.arc(70, 70, 60, 0, 2 * Math.PI); this.context.fillStyle = '#F0F0F0'; ...
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left draw AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#ERROR#Right AST#statement_block#Left AST#{#Left { AST#{#Right AST#comment#Left // 1. 计算总数 AST#comm...
draw() { // 1. 计算总数 let total = 0; this.data.forEach(item => total += item.count); // 如果没有数据,画个灰色的圆 if (total === 0) { this.context.clearRect(0, 0, 140, 140); this.context.beginPath(); this.context.arc(70, 70, 60, 0, 2 * Math.PI); this.context.fillStyle = '#F0F0F0'; ...
https://gitcode.com/openharmony/codelabs
9c255803090b00f8e845a0c4d5389c86d7e55200
gitcode
chendi126/harmonyOS-TCP
entry/src/main/ets/common/SafeAreaUtils.ets
arkts
initialize
初始化安全区域信息
public static async initialize(): Promise<void> { if (isInitialized) { return; } try { const windowClass = await window.getLastWindow(getContext()); const avoidArea = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); // 获取状态栏高度 statusBarHeight = avoidArea.to...
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#identifier#Left static AST#identifier#Right AST#async#Left async AST#async#Right AST#call_expression#Left AST#identifier#Left initialize AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Rig...
public static async initialize(): Promise<void> { if (isInitialized) { return; } try { const windowClass = await window.getLastWindow(getContext()); const avoidArea = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); // 获取状态栏高度 statusBarHeight = avoidArea.to...
https://github.com/chendi126/harmonyOS-TCP
06e2ff0f04a1f80f9cc5444d3ef3dc668ee06c33
github
DaLongZhuaZi/manxia
entry/src/main/ets/Framework/Components/ConsolePanel.ets
arkts
getMemoryInfo
获取内存信息
getMemoryInfo(): string { return [ '=== 内存信息 ===', `当前内存: ${typeof this.performanceMetrics?.memory?.used === 'number' ? this.performanceMetrics.memory.used.toFixed(1) : '未知'} MB`, `峰值内存: ${typeof this.performanceMetrics?.memory?.peak === 'number' ? this.performanceMetrics.memory.peak.toFixed(1) ...
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left getMemoryInfo AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Left : AST#:#Right AST#string#Left string AST#string#Right AST#ERROR#Right AST#statemen...
getMemoryInfo(): string { return [ '=== 内存信息 ===', `当前内存: ${typeof this.performanceMetrics?.memory?.used === 'number' ? this.performanceMetrics.memory.used.toFixed(1) : '未知'} MB`, `峰值内存: ${typeof this.performanceMetrics?.memory?.peak === 'number' ? this.performanceMetrics.memory.peak.toFixed(1) ...
https://github.com/DaLongZhuaZi/manxia
5399301eae87da6ed620549964aa7f8cfdd98fc1
github
the-wwyang/kids-learning-app
src/main/ets/services/StatisticsService.ets
arkts
generateSuggestions
生成学习建议 @param report 学习报告 @returns 建议列表
static generateSuggestions(report: LearningReport): string[] { const suggestions: string[] = []; // 学习频率建议 if (report.activeDays < report.totalDays * 0.5) { suggestions.push('💡 建议增加学习频率,保持每天至少学习一次'); } // 学习时长建议 if (report.averageDailyTime < 10) { suggestions.push('⏰ 每天学习时间较短,建议...
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left generateSuggestions AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left report AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier...
static generateSuggestions(report: LearningReport): string[] { const suggestions: string[] = []; // 学习频率建议 if (report.activeDays < report.totalDays * 0.5) { suggestions.push('💡 建议增加学习频率,保持每天至少学习一次'); } // 学习时长建议 if (report.averageDailyTime < 10) { suggestions.push('⏰ 每天学习时间较短,建议...
https://github.com/the-wwyang/kids-learning-app
5afd7d6301e6974ec11ebf4ebd150e912c94dbda
github
openharmony/multimedia_camera_framework
frameworks/js/camera_napi/cameraAnimSample/entry/src/main/ets/mode/CameraService.ets
arkts
offCameraStatusChange
停止监听相机状态变化 @returns 无返回值
offCameraStatusChange(): void { Logger.info(TAG, 'offCameraStatusChange is called'); this.cameraManager?.off('cameraStatus', this.registerCameraStatusChange); }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left offCameraStatusChange AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Left : AST#:#Right AST#void#Left void AST#void#Right AST#ERROR#Right AST#statem...
offCameraStatusChange(): void { Logger.info(TAG, 'offCameraStatusChange is called'); this.cameraManager?.off('cameraStatus', this.registerCameraStatusChange); }
https://gitee.com/openharmony/multimedia_camera_framework.git
03558b061a2c644215f4bf89f24c28e349d5a238
gitee
pangpang20/antennaPodHM
entry/src/main/ets/service/DatabaseService.ets
arkts
getEpisodeById
根据ID查询单个Episode
async getEpisodeById(episodeId: string): Promise<Episode | null> { if (!this.rdbStore) return null; try { const predicates = new relationalStore.RdbPredicates(Constants.TABLE_EPISODE); predicates.equalTo('id', episodeId); const resultSet = await this.rdbStore.query(predicates); let e...
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left async AST#identifier#Right AST#ERROR#Left AST#identifier#Left getEpisodeById AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left episodeId AST#identifier#Right AST#type_annot...
async getEpisodeById(episodeId: string): Promise<Episode | null> { if (!this.rdbStore) return null; try { const predicates = new relationalStore.RdbPredicates(Constants.TABLE_EPISODE); predicates.equalTo('id', episodeId); const resultSet = await this.rdbStore.query(predicates); let e...
https://github.com/pangpang20/antennaPodHM
ba829d210f4eecfa5591ff15c7314964714dcd83
github
DaLongZhuaZi/manxia
entry/src/main/ets/Framework/WebView/WebViewSourceManager.ets
arkts
cleanupUnusedInstances
清理未使用的WebView实例
private cleanupUnusedInstances(): void { const now = Date.now(); const maxIdleTime = 10 * 60 * 1000; // 10分钟 const instancesToRemove: string[] = []; this.webViewInstances.forEach((instanceInfo, sourceId) => { if (!instanceInfo.isInUse && (now - instanceInfo.lastUsedTime) > maxIdleTime) { ...
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left cleanupUnusedInstances AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Left : AST#:#Right AST#void#Left vo...
private cleanupUnusedInstances(): void { const now = Date.now(); const maxIdleTime = 10 * 60 * 1000; // 10分钟 const instancesToRemove: string[] = []; this.webViewInstances.forEach((instanceInfo, sourceId) => { if (!instanceInfo.isInUse && (now - instanceInfo.lastUsedTime) > maxIdleTime) { ...
https://github.com/DaLongZhuaZi/manxia
05406e3f8dee58e0a1038a248d38a7e7bed77107
github
wblxr408/SEU-SE-HarmonyExpense-App-
entry/src/main/ets/model/SmartCategory.ets
arkts
extractKeywords
从文本中提取关键词
static extractKeywords(text: string): string[] { // 简单的分词实现 const result: string[] = []; const words = text.split(/[\s,,。.!!??]+/); for (let i = 0; i < words.length; i++) { const word = words[i].trim(); if (word.length >= 2) { result.push(word); } } return result; }
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left extractKeywords AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left text AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left ...
static extractKeywords(text: string): string[] { // 简单的分词实现 const result: string[] = []; const words = text.split(/[\s,,。.!!??]+/); for (let i = 0; i < words.length; i++) { const word = words[i].trim(); if (word.length >= 2) { result.push(word); } } return result; }
https://github.com/wblxr408/SEU-SE-HarmonyExpense-App-
6184018d9fd041bd0e51136aaa89157edce6d6fd
github
openharmony/applications_settings
product/phone/src/main/ets/model/accessibilityImpl/ExtensionServiceManagementModel.ets
arkts
setExtensionServiceManagementListener
get extensionService data
setExtensionServiceManagementListener() { this.serviceInfoList = []; accessibility.getAccessibilityExtensionList('all', 'install').then((data) => { LogUtil.info(`${MODULE_TAG} extensionService data.length: ${data.length} data: ${JSON.stringify(data)}`); if (!data || data.length < 1) { rou...
AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left setExtensionServiceManagementListener AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#;#Left AST#;#Right AST#expression_statement#Right ...
setExtensionServiceManagementListener() { this.serviceInfoList = []; accessibility.getAccessibilityExtensionList('all', 'install').then((data) => { LogUtil.info(`${MODULE_TAG} extensionService data.length: ${data.length} data: ${JSON.stringify(data)}`); if (!data || data.length < 1) { rou...
https://gitee.com/openharmony/applications_settings.git
e6deaedece1bd4636b0041ddb0b1b7654a608f0a
gitee
openharmony-sig/commons-cli
library/src/main/ets/components/cli/JMap.ets
arkts
containsKey
判断MAP中是否含有指定KEY的元素
containsKey(_key:T1):boolean { let bln = false; try { for (let i = 0; i < this.elements.length; i++) { if (this.elements[i].key == _key) { bln = true; } } } catch (e) { bln = false; } return bln; };
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left containsKey AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left _key AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#identifier#Left T1 AST#identifier#Right AST#ERROR#Right AST#)#Left ) AST#)#R...
containsKey(_key:T1):boolean { let bln = false; try { for (let i = 0; i < this.elements.length; i++) { if (this.elements[i].key == _key) { bln = true; } } } catch (e) { bln = false; } return bln; };
https://gitee.com/openharmony-sig/commons-cli.git
421f725fe360e7be1b2a9c723ed06d755bf7360a
gitee
iop123123/arkts-static-skills
docs/ArkTS-Language-Guide/08-Stdlib/stdlib-source/std/core/String.ets
arkts
split
split @param { RegExp } separator RegExp to split by @param { int } [limit] max length of the returned array. If it's negative then there is no limit. @returns { String[] } string array contains substrings from this String @syscap SystemCapability.Utils.Lang @FaAndStageModel
public split(separator: RegExp, limit?: int): String[] { return separator.split(this, limit); }
AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#member_expression#Left AST#call_expression#Left AST#identifier#Left public AST#identifier#Right AST#ERROR#Left AST#identifier#Left split AST#identifier#Right AST#ERROR#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left separa...
public split(separator: RegExp, limit?: int): String[] { return separator.split(this, limit); }
https://gitcode.com/iop123123/arkts-static-skills
b65ac50e26bade24a2151f92784fa2cd36904694
gitcode
Yebingiscn/SweetVideo
entry/src/main/ets/component/PlayerComponent/AudioTrackComponent.ets
arkts
getTrackLanguage
获取轨道语言
getTrackLanguage(item: TrackType): string { if (this.isAudioTrack(item)) { return (item as AudioTrack).language } else if (this.isMpvAudioTrack(item)) { return (item as MpvAudioTrack).lang } return '' }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left getTrackLanguage AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left item AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left TrackType AST#identifier#Right AST#)#Le...
getTrackLanguage(item: TrackType): string { if (this.isAudioTrack(item)) { return (item as AudioTrack).language } else if (this.isMpvAudioTrack(item)) { return (item as MpvAudioTrack).lang } return '' }
https://github.com/Yebingiscn/SweetVideo
37a5873ff76b3a849bb1f02021f85ae57745b219
github
Yebingiscn/SweetVideo
entry/src/main/ets/controller/MpvController/MpvController.ets
arkts
syncOsdSurfaceSize
解决字幕模糊问题:使用视频原生分辨率而非显示区域尺寸
syncOsdSurfaceSize(): void { if (!this.osdSurfaceId) { return } // 使用视频原生分辨率,而不是 playAreaWidth/Height(显示区域尺寸) const videoWidth = this.getPlayAreaWidth() const videoHeight = this.getPlayAreaHeight() if (videoWidth > 0 && videoHeight > 0) { this.setOsdSurface(this.osdSurfaceId, vide...
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left syncOsdSurfaceSize AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Left : AST#:#Right AST#void#Left void AST#void#Right AST#ERROR#Right AST#statement...
syncOsdSurfaceSize(): void { if (!this.osdSurfaceId) { return } // 使用视频原生分辨率,而不是 playAreaWidth/Height(显示区域尺寸) const videoWidth = this.getPlayAreaWidth() const videoHeight = this.getPlayAreaHeight() if (videoWidth > 0 && videoHeight > 0) { this.setOsdSurface(this.osdSurfaceId, vide...
https://github.com/Yebingiscn/SweetVideo
ba7ae6669730d1d0ff6535bbcd9bb3079afeb0ec
github
AetheriumSimulator/qemu-hmos
entry/src/main/ets/components/DownloadManager.ets
arkts
formatFileSize
格式化文件大小
public static formatFileSize(bytes: number): string { if (bytes === 0) return '0 B'; const k = 1024; const sizes = ['B', 'KB', 'MB', 'GB', 'TB']; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#identifier#Left static AST#identifier#Right AST#call_expression#Left AST#identifier#Left formatFileSize AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left bytes AST#identifier#Right AST#:#Left : ...
public static formatFileSize(bytes: number): string { if (bytes === 0) return '0 B'; const k = 1024; const sizes = ['B', 'KB', 'MB', 'GB', 'TB']; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; }
https://github.com/AetheriumSimulator/qemu-hmos
ffe4f88850de8ebf92c8f7938e09b58d11bd330c
github
openharmony/codelabs
ETSUI/PositioningDemo/entry/src/main/ets/service/StatisticsService.ets
arkts
calculateUserStatistics
计算用户总体统计数据
async calculateUserStatistics(): Promise<UserStatistics> { const statistics = new UserStatistics(); const records = await this.historyService.getSportRecords(); console.log('[统计调试] 总记录数:', records.length); if (records.length === 0) { console.log('[统计调试] 没有运动记录'); return statistics; }...
AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left calculateUserStatistics AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#formal_parameters#Right AST#type_annotation#Left AST#:#Left : AST#:#Right ...
async calculateUserStatistics(): Promise<UserStatistics> { const statistics = new UserStatistics(); const records = await this.historyService.getSportRecords(); console.log('[统计调试] 总记录数:', records.length); if (records.length === 0) { console.log('[统计调试] 没有运动记录'); return statistics; }...
https://gitcode.com/openharmony/codelabs
f5dc44c83967663dd06ab8ddb21dc6994d0a1232
gitcode