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
openharmony/codelabs
ETSUI/PassNote/entry/src/main/ets/pages/ProfilePage.ets
arkts
openNoteDialog
打开便签弹窗(新增或编辑)
openNoteDialog(note?: Note) { if (note) { this.currentNoteId = note.id; this.currentNoteTitle = note.title; this.currentNoteContent = note.content; this.currentNotePinned = note.isPinned; } else { this.currentNoteId = ''; this.currentNoteTitle = ''; this.currentNoteCo...
AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left openNoteDialog AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left note AST#identifier#Right AST#?#Left ? AST#?#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left N...
openNoteDialog(note?: Note) { if (note) { this.currentNoteId = note.id; this.currentNoteTitle = note.title; this.currentNoteContent = note.content; this.currentNotePinned = note.isPinned; } else { this.currentNoteId = ''; this.currentNoteTitle = ''; this.currentNoteCo...
https://gitcode.com/openharmony/codelabs
fa455d2d07b92d7812fe723ce1ba2a0797e9bb3f
gitcode
LongLiveY96/chatcube
entry/src/main/ets/services/FavoriteModelsService.ets
arkts
getFavoriteKey
生成收藏复合键 @param providerId 供应商 ID @param modelId 模型 ID @returns 复合键(providerId::modelId 格式)
getFavoriteKey(providerId: string, modelId: string): string { return `${providerId}::${modelId}` }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left getFavoriteKey AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left providerId AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string AST#string#Right AST#ERROR#Right AST#,#Left , AS...
getFavoriteKey(providerId: string, modelId: string): string { return `${providerId}::${modelId}` }
https://github.com/LongLiveY96/chatcube
f66d9884ddf0b76ea867fa5de1a295a07a911135
github
LJ666-ui/harmony-health-care
entry/src/main/ets/ar/ARRenderer.ets
arkts
drawNavigationInfo
绘制导航信息叠加
private drawNavigationInfo(info: NavigationInfo): void { if (!this.canvasContext) return; const ctx = this.canvasContext; const panelHeight = 200; const panelY = this.canvasHeight - panelHeight - 50; // 绘制半透明背景面板 ctx.fillStyle = 'rgba(0, 0, 0, 0.7)'; this.roundRect( ctx, 50, ...
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left drawNavigationInfo AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left info AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier...
private drawNavigationInfo(info: NavigationInfo): void { if (!this.canvasContext) return; const ctx = this.canvasContext; const panelHeight = 200; const panelY = this.canvasHeight - panelHeight - 50; // 绘制半透明背景面板 ctx.fillStyle = 'rgba(0, 0, 0, 0.7)'; this.roundRect( ctx, 50, ...
https://github.com/LJ666-ui/harmony-health-care
454d3935cf62fd913a6344b0e4a758b620189b83
github
OSpark-Team/Free-PCM
entry/src/main/ets/pages/components/FftSpectrum.ets
arkts
getBars01
bars 0~1 (copy)
public getBars01(): number[] { return Array.from(this.bars01); }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left getBars01 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 number AST#i...
public getBars01(): number[] { return Array.from(this.bars01); }
https://github.com/OSpark-Team/Free-PCM/blob/3440e7220d07d28815d172b4b3237145434075ee/entry/src/main/ets/pages/components/FftSpectrum.ets#L475-L477
65621f03f6ad83cb1de576c3bf938912f68e30a4
github
RedRackham-R/WanAndroidHarmoney
entry/src/main/ets/utils/ByteConverter.ets
arkts
convertBytes
byte转换文本
static convertBytes(bytes: number): string { const units = ['Byte', 'KB', 'MB', 'GB', 'TB'] let unitIndex = 0 while (bytes >= 1024 && unitIndex < units.length - 1) { bytes /= 1024 unitIndex++ } return `${bytes.toFixed(2)} ${units[unitIndex]}` }
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left convertBytes AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left bytes AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left nu...
static convertBytes(bytes: number): string { const units = ['Byte', 'KB', 'MB', 'GB', 'TB'] let unitIndex = 0 while (bytes >= 1024 && unitIndex < units.length - 1) { bytes /= 1024 unitIndex++ } return `${bytes.toFixed(2)} ${units[unitIndex]}` }
https://github.com/RedRackham-R/WanAndroidHarmoney
5d063fccf5209d1b77aa2c273e597012040a94b3
github
daugf2527/harmonyos-libretro-emulator
entry/src/main/ets/common/LibraryMetadataMigration.ets
arkts
shouldMigrateRecord
判断是否需要迁移
function shouldMigrateRecord(record: LibraryRecord, metadata: GameMetadataRecord): boolean { // 如果 LibraryRecord 已有非空值,且与 metadata 一致,则跳过 const hasReleaseYear = record.releaseYear !== undefined && record.releaseYear > 0 const hasPublisher = record.publisher !== undefined && record.publisher.length > 0 const me...
AST#program#Left AST#function_declaration#Left AST#function#Left function AST#function#Right AST#identifier#Left shouldMigrateRecord AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left record AST#identifier#Right AST#type_annotation#Left AST#:#Left : ...
function shouldMigrateRecord(record: LibraryRecord, metadata: GameMetadataRecord): boolean { // 如果 LibraryRecord 已有非空值,且与 metadata 一致,则跳过 const hasReleaseYear = record.releaseYear !== undefined && record.releaseYear > 0 const hasPublisher = record.publisher !== undefined && record.publisher.length > 0 const me...
https://github.com/daugf2527/harmonyos-libretro-emulator
d920cd19e9bebc19f50816f55b17728d7becb633
github
popsiclelmlm/Hey
entry/src/main/ets/core/SingboxConfig.ets
arkts
buildServerTls
anytls 这类把 TLS 字段内联在 server 对象(而非 streamSettings)里的协议:直接从 server 组 sing-box TLS。 anytls 协议本身即「any TLS」,链路恒走 TLS,所以这里恒为 enabled。
function buildServerTls(server: JsonObject): SbTls { const tls: SbTls = { enabled: true }; const sni = asString(server['sni']); if (sni.length > 0) { tls.server_name = sni; } if (server['insecure'] === true) { tls.insecure = true; } const alpn = splitCsv(asString(server['alpn'])); if (alpn.lengt...
AST#program#Left AST#function_declaration#Left AST#function#Left function AST#function#Right AST#identifier#Left buildServerTls AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left server AST#identifier#Right AST#type_annotation#Left AST#:#Left : AST#:...
function buildServerTls(server: JsonObject): SbTls { const tls: SbTls = { enabled: true }; const sni = asString(server['sni']); if (sni.length > 0) { tls.server_name = sni; } if (server['insecure'] === true) { tls.insecure = true; } const alpn = splitCsv(asString(server['alpn'])); if (alpn.lengt...
https://github.com/popsiclelmlm/Hey
eeb5b2cc854666ef66703f2ed5fc6f36d3b2af52
github
DaLongZhuaZi/manxia
entry/src/main/ets/Framework/Data/DataManager.ets
arkts
updateComicCoverUrl
更新漫画封面路径
public async updateComicCoverUrl(comicId: string, coverUrl: string): Promise<void> { try { const updateData: UpdateRecordData = { id: comicId, coverUrl: coverUrl }; await this.databaseManager.update( 'comic_info', updateData, 'id = ?', [comicId] ...
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 updateComicCoverUrl AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left comicId AST#identifier#Right AST#ERROR#Left AST#:#L...
public async updateComicCoverUrl(comicId: string, coverUrl: string): Promise<void> { try { const updateData: UpdateRecordData = { id: comicId, coverUrl: coverUrl }; await this.databaseManager.update( 'comic_info', updateData, 'id = ?', [comicId] ...
https://github.com/DaLongZhuaZi/manxia
8c0aa7f82ce78d16a26f0a7555f8e456ba9bf5b2
github
LJ666-ui/harmony-health-care
entry/src/main/ets/core/SmartLightController.ets
arkts
getDeviceStatus
获取灯光设备状态
public async getDeviceStatus(deviceId: string): Promise<DeviceStatus> { let status = this.statusCache.get(deviceId); // 如果没有缓存状态,创建默认状态 if (!status) { const properties: Map<string, DeviceProperty> = new Map(); properties.set('brightness', { key: 'brightness', value: 50, ...
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 getDeviceStatus AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left deviceId AST#identifier#Right AST#ERROR#Left AST#:#Left...
public async getDeviceStatus(deviceId: string): Promise<DeviceStatus> { let status = this.statusCache.get(deviceId); // 如果没有缓存状态,创建默认状态 if (!status) { const properties: Map<string, DeviceProperty> = new Map(); properties.set('brightness', { key: 'brightness', value: 50, ...
https://github.com/LJ666-ui/harmony-health-care
a55a00e22aa90a57013aaf36681ee1dcc33f3be6
github
HarmonyOS_Samples/scankit-samplecode-clientdemo-arkts
products/phone/src/main/ets/pages/customScan/model/DeviceService.ets
arkts
refreshDisplayInfoAndSelectSuitableRatio
Update the latest display information and match the proper portrait resolution of the camera preview stream.
public static refreshDisplayInfoAndSelectSuitableRatio() { let displayClass: display.Display | null = DeviceService.getDisplayInfoSync(); DeviceService.setDisplayInfo(displayClass); DeviceService.selectSuitableRatio(); }
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 refreshDisplayInfoAndSelectSuitableRatio AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#...
public static refreshDisplayInfoAndSelectSuitableRatio() { let displayClass: display.Display | null = DeviceService.getDisplayInfoSync(); DeviceService.setDisplayInfo(displayClass); DeviceService.selectSuitableRatio(); }
https://gitcode.com/HarmonyOS_Samples/scankit-samplecode-clientdemo-arkts
c494e9b851fade8ddd7a79d0b12ebebba4bd9503
gitcode
openharmony-sig/ohos_circle_indicator
library/src/main/ets/components/BannerIndicator.ets
arkts
refreshOffsetForFling
flingIndex: 当前下标 offset: 当前offset direction: 动画滑动方向 1: 滑到下一页 -1: 滑到上一页 0: 滑回当前页 offsetPerFrame: 每次更新的offset变化值
refreshOffsetForFling(flingIndex: number, offset: number, direction: number, offsetPerFrame: number) { if (direction === 0) { if (Math.abs(offset) <= offsetPerFrame) { this.indicatorOffset = 0 } else { this.indicatorOffset = (Math.abs(offset) - offsetPerFrame) * Math.sign(offset) ...
AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left refreshOffsetForFling AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left flingIndex AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#number#Left number AST#number#Right AST#ERROR...
refreshOffsetForFling(flingIndex: number, offset: number, direction: number, offsetPerFrame: number) { if (direction === 0) { if (Math.abs(offset) <= offsetPerFrame) { this.indicatorOffset = 0 } else { this.indicatorOffset = (Math.abs(offset) - offsetPerFrame) * Math.sign(offset) ...
https://gitee.com/openharmony-sig/ohos_circle_indicator.git
c1902612c9da9d4b6d187bc30d3c8209be341e27
gitee
openharmony-sig/arkcompiler_runtime_core
plugins/ets/stdlib/escompat/TypedUArrays.ets
arkts
map
Creates a new Uint8ClampedArray using fn(arr[i]) over all elements of current Uint8ClampedArray. @param fn a function to apply for each element of current Uint8ClampedArray @returns a new Uint8ClampedArray where for each element from current Uint8ClampedArray fn was applied
public map(fn: (val: number, index: int) => number): Uint8ClampedArray { let resBuf = new ArrayBuffer(this.length * Uint8ClampedArray.BYTES_PER_ELEMENT) let res = new Uint8ClampedArray(resBuf) for (let i = 0; i < this.length; ++i) { res.set(i, fn(this.at(i), i)) } ...
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left public AST#identifier#Right AST#ERROR#Left AST#identifier#Left map AST#identifier#Right AST#ERROR#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#binary_expression#Left AST#call_expression#Left AST#identifier#Left fn AST#identifier#Right...
public map(fn: (val: number, index: int) => number): Uint8ClampedArray { let resBuf = new ArrayBuffer(this.length * Uint8ClampedArray.BYTES_PER_ELEMENT) let res = new Uint8ClampedArray(resBuf) for (let i = 0; i < this.length; ++i) { res.set(i, fn(this.at(i), i)) } ...
https://gitee.com/openharmony-sig/arkcompiler_runtime_core.git
8bd11c839c736c9126be02b867021f17a7737668
gitee
DaLongZhuaZi/manxia
entry/src/main/ets/Framework/Cache/CoverCacheManager.ets
arkts
downloadAndCacheCover
下载并缓存封面
async downloadAndCacheCover( sourceId: number, externalId: string, coverUrl: string, headers?: Record<string, string> ): Promise<string | null> { const isPhotos18 = await this.isPhotos18Source(sourceId); const referer = this.resolvePhotos18Referer(headers); const cacheKey = isPhotos18 ? ...
AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left downloadAndCacheCover AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left sourceId AST#identifier#Right AST#type_annotation#Left AS...
async downloadAndCacheCover( sourceId: number, externalId: string, coverUrl: string, headers?: Record<string, string> ): Promise<string | null> { const isPhotos18 = await this.isPhotos18Source(sourceId); const referer = this.resolvePhotos18Referer(headers); const cacheKey = isPhotos18 ? ...
https://github.com/DaLongZhuaZi/manxia
b55d7b467460b7fc6b136d15f922a70824316c6a
github
wblxr408/SEU-SE-HarmonyExpense-App-
entry/src/main/ets/service/SmartBudgetService.ets
arkts
generateCategoryBudgets
生成分类预算分配
private static async generateCategoryBudgets( historicalData: CategoryHistoricalData[], config: ForecastEngineConfig, totalBudget?: number ): Promise<CategoryBudgetAllocation[]> { const allocations: CategoryBudgetAllocation[] = []; // 为每个分类预测下月支出 for (const data of historicalData) { i...
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 generateCategoryBudgets AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identif...
private static async generateCategoryBudgets( historicalData: CategoryHistoricalData[], config: ForecastEngineConfig, totalBudget?: number ): Promise<CategoryBudgetAllocation[]> { const allocations: CategoryBudgetAllocation[] = []; // 为每个分类预测下月支出 for (const data of historicalData) { i...
https://github.com/wblxr408/SEU-SE-HarmonyExpense-App-
05f0deae233e701a11593d3ebf0cc5a2b23f8505
github
Joker-x-dev/HarmonyKit
feature/demo/src/main/ets/view/LocalStoragePage.ets
arkts
build
构建本地存储示例页 @returns {void} 无返回值
build() { AppNavDestination({ title: $r("app.string.demo_local_storage_title"), viewModel: this.vm }) { this.LocalStorageContent(); } }
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#statement_block#Left AST#{#Left { AST#{#Right AST#expression_statement#Left AST#c...
build() { AppNavDestination({ title: $r("app.string.demo_local_storage_title"), viewModel: this.vm }) { this.LocalStorageContent(); } }
https://github.com/Joker-x-dev/HarmonyKit
b0eb867edebd52f317f73597296284be8b8e9f5a
github
openharmony-sig/arkcompiler_runtime_core
plugins/ets/tests/ets-templates/06.conversions_and_contexts/05.casting_contexts/wide_narr_prim.ets
arkts
main
--- desc: Casting contexts allow the use of the widening and narrowing primitive conversion. ---
function main(): int { {%- for t in c['types'] %} let v{{loop.index}}: {{t.src_type}} = {{t.src_val|safe}}; if (v{{loop.index}} as {{t.dst_type}} != {{t.dst_val}}) {
AST#program#Left AST#ERROR#Left AST#function_expression#Left AST#function#Left function AST#function#Right AST#identifier#Left main AST#identifier#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#type_ide...
function main(): int { {%- for t in c['types'] %} let v{{loop.index}}: {{t.src_type}} = {{t.src_val|safe}}; if (v{{loop.index}} as {{t.dst_type}} != {{t.dst_val}}) {
https://gitee.com/openharmony-sig/arkcompiler_runtime_core.git
f0ce01266213390b12e35d4c6d5c018cc8b9fd6a
gitee
DaLongZhuaZi/NGF
ngf_framework/src/main/ets/utils/StringUtils.ets
arkts
capitalize
首字母大写,其余保持不变
static capitalize(value: string): string { if (value.length === 0) { return value; } return value.charAt(0).toUpperCase() + value.substring(1); }
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left capitalize AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left value AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left stri...
static capitalize(value: string): string { if (value.length === 0) { return value; } return value.charAt(0).toUpperCase() + value.substring(1); }
https://github.com/DaLongZhuaZi/NGF
788edfdc33efe775de730cf185b10b8f14ed23ee
github
Tencent-RTC/TUIKit_Harmony
atomic_x/src/main/ets/call/common/CallStore.ets
arkts
updateNetworkQuality
更新网络质量
updateNetworkQuality(userId: string, quality: NetworkQuality): void { this.networkQualities.set(userId, quality); this.networkQualities = new Map(this.networkQualities); }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left updateNetworkQuality 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#Left string AST#identifier#Right AST#,...
updateNetworkQuality(userId: string, quality: NetworkQuality): void { this.networkQualities.set(userId, quality); this.networkQualities = new Map(this.networkQualities); }
https://github.com/Tencent-RTC/TUIKit_Harmony
eea55a1d650d98840805c6a2464e20029a9f6a5d
github
cheinlu/HarmonyOS-groundhog-charging-system
TbsChargeHarmonyOs/feature/charge/src/main/ets/page/ChargePage.ets
arkts
onChangeName
监听输入框的输入内容的变化,若为空时再调接口
onChangeName() { if (this.name == '') { this.getStationData() } }
AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left onChangeName 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 ...
onChangeName() { if (this.name == '') { this.getStationData() } }
https://github.com/cheinlu/HarmonyOS-groundhog-charging-system
c9792f0b7a20fda0cafca0d0174e07c08744a6a2
github
openharmony/security_privacy_center
entry/src/main/ets/common/utils/StringUtil.ets
arkts
isEmpty
Determine whether a character is an empty string @Param stringValue character string
public static isEmpty(stringValue: string | null | undefined): boolean { return stringValue === undefined || stringValue === null || stringValue.length === 0; }
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 isEmpty AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#binary_expression#Left AST#binary_expression#Left AST#identifier#Left stringVa...
public static isEmpty(stringValue: string | null | undefined): boolean { return stringValue === undefined || stringValue === null || stringValue.length === 0; }
https://gitee.com/openharmony/security_privacy_center.git
5333bae18882e5da081a52fac3a3b6124aed39b6
gitee
AlkaidLab/moonlight-harmony
entry/src/main/ets/service/network/QrShareService.ets
arkts
decodeSimpleAction
解码简单动作字符串(不含 |)
function decodeSimpleAction(s: string): KeyAction { if (s.startsWith('K')) { const vk = parseInt(s.substring(1)); if (!isNaN(vk)) { return { type: 'keyboard', vk: vk } as KeyboardAction; } } if (s.startsWith('M')) { const btn = parseInt(s.substring(1)); if (!isNaN(btn)) { return { ...
AST#program#Left AST#function_declaration#Left AST#function#Left function AST#function#Right AST#identifier#Left decodeSimpleAction AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left s AST#identifier#Right AST#type_annotation#Left AST#:#Left : AST#:#...
function decodeSimpleAction(s: string): KeyAction { if (s.startsWith('K')) { const vk = parseInt(s.substring(1)); if (!isNaN(vk)) { return { type: 'keyboard', vk: vk } as KeyboardAction; } } if (s.startsWith('M')) { const btn = parseInt(s.substring(1)); if (!isNaN(btn)) { return { ...
https://github.com/AlkaidLab/moonlight-harmony
23e7f50d635f0657c3fff58cd2ec00f9d8d8917e
github
midori52000/ArkPilot
Agent/entry/src/main/ets/skills/SkillsBackendService.ets
arkts
setSkillEnabled
切换 Skill 启用/禁用状态(通过 Rust host)
async setSkillEnabled(id: string, enabled: boolean): Promise<InstalledSkill> { const json = setSkillEnabledNative(this.codexHome, id, enabled); const parsed = JSON.parse(json) as SkillEntryJson; if (parsed.id === undefined || parsed.id.length === 0) { throw new SkillError( SkillErrorCode.SKI...
AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left setSkillEnabled AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left id AST#identifier#Right AST#type_annotation#Left AST#:#Left : A...
async setSkillEnabled(id: string, enabled: boolean): Promise<InstalledSkill> { const json = setSkillEnabledNative(this.codexHome, id, enabled); const parsed = JSON.parse(json) as SkillEntryJson; if (parsed.id === undefined || parsed.id.length === 0) { throw new SkillError( SkillErrorCode.SKI...
https://github.com/midori52000/ArkPilot
12ac39d4e8b7b6306fcb5db73f8e31e913945116
github
Joker-x-dev/CoolMallArkTS
core/data/src/main/ets/repository/BannerRepository.ets
arkts
constructor
构造函数 @param networkDataSource 可选的数据源实例,便于单元测试注入
constructor(networkDataSource?: BannerNetworkDataSource) { this.networkDataSource = networkDataSource ?? new BannerNetworkDataSourceImpl(); }
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 networkDataSource AST#identifier#Right AST#?#Left ? AST#?#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identif...
constructor(networkDataSource?: BannerNetworkDataSource) { this.networkDataSource = networkDataSource ?? new BannerNetworkDataSourceImpl(); }
https://github.com/Joker-x-dev/CoolMallArkTS
40d217e0e6ae4d2d27d8ea9ba9684a94d7cc6b59
github
offlinecat-dev/OCNetORM
src/main/ets/query/QueryBuilder.ets
arkts
withLazy
指定需要延迟加载的关联关系 @param relationName 关联属性名 @returns 当前实例(支持链式调用) @throws RelationNotFoundError 如果关联关系未注册
withLazy(relationName: string): QueryBuilder { this.relationStrategySupport.registerWithLazy(relationName) return this }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left withLazy AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left relationName AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string AST#string#Right AST#ERROR#Right AST#)#Left ) AST#)#...
withLazy(relationName: string): QueryBuilder { this.relationStrategySupport.registerWithLazy(relationName) return this }
https://github.com/offlinecat-dev/OCNetORM
e79063468d5f67482cbc9bc95357276754e172c9
github
awaLiny2333/LinysBrowser_NEXT
home/src/main/ets/hosts/system/windows/classes/meowUiHost.ets
arkts
submitSearchOrLoad
The universal gateway to submit search on CURRENT TAB! @param url If set, then load the URL. If not, then loads the searchUnifyResult.url
submitSearchOrLoad(url?: string) { if (url) { this.addressBarContentMajor = url; this.refreshKeywordEntries(); this.refreshDestination(); } const target = this.searchUnifyResult?.url || concatSearchWithEngine('').result; const myTabs = AppStorageV2.connect(meowTabsBunch, `meowTabsBun...
AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left submitSearchOrLoad AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left url AST#identifier#Right AST#?#Left ? AST#?#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Lef...
submitSearchOrLoad(url?: string) { if (url) { this.addressBarContentMajor = url; this.refreshKeywordEntries(); this.refreshDestination(); } const target = this.searchUnifyResult?.url || concatSearchWithEngine('').result; const myTabs = AppStorageV2.connect(meowTabsBunch, `meowTabsBun...
https://github.com/awaLiny2333/LinysBrowser_NEXT
2d7de924c887f30e841b67f5df06a4b78dcdb17d
github
AlkaidLab/moonlight-harmony
entry/src/main/ets/service/usbdriver/GenericHidController.ets
arkts
processInputReport
处理通用 HID 输入报告 尝试解析标准的 USB HID 游戏手柄格式 针对 VID 0x413D 等通用手柄的格式: [0] = Report ID (0x01) [1] = 左摇杆 X (0x00-0xFF, 0x80=中心) [2] = 左摇杆 Y [3] = 右摇杆 X [4] = 右摇杆 Y [5] = 扳机或其他数据 [6] = HAT 方向键 (0-8, 8或15=中心) [7] = 按钮字节 1 [8] = 按钮字节 2
private processInputReport(data: Uint8Array, length: number): void { if (length < 8) { return; } // 检测是否有报告ID(第一字节是否看起来像报告ID) let offset = 0; if (data[0] === 0x01 || data[0] === 0x07 || data[0] === 0x20) { offset = 1; } // 打印完整的原始数据以调试按钮映射 const hexStr = Array.fro...
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left processInputReport AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left data AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier...
private processInputReport(data: Uint8Array, length: number): void { if (length < 8) { return; } // 检测是否有报告ID(第一字节是否看起来像报告ID) let offset = 0; if (data[0] === 0x01 || data[0] === 0x07 || data[0] === 0x20) { offset = 1; } // 打印完整的原始数据以调试按钮映射 const hexStr = Array.fro...
https://github.com/AlkaidLab/moonlight-harmony
115e52185f55538aeda148fae18cc26e8efab218
github
openharmony/multimedia_camera_framework
frameworks/js/camera_napi/cameraAnimSample/entry/src/main/ets/mode/CameraService.ets
arkts
getCameraManagerFn
获取相机管理器实例
getCameraManagerFn(): camera.CameraManager | undefined { if (this.cameraManager) { return this.cameraManager; } let cameraManager: camera.CameraManager | undefined = undefined; try { cameraManager = camera.getCameraManager(GlobalContext.get().getCameraSettingContext()); Logger.info(T...
AST#program#Left AST#expression_statement#Left AST#binary_expression#Left AST#member_expression#Left AST#call_expression#Left AST#identifier#Left getCameraManagerFn 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#...
getCameraManagerFn(): camera.CameraManager | undefined { if (this.cameraManager) { return this.cameraManager; } let cameraManager: camera.CameraManager | undefined = undefined; try { cameraManager = camera.getCameraManager(GlobalContext.get().getCameraSettingContext()); Logger.info(T...
https://gitee.com/openharmony/multimedia_camera_framework.git
e0eb3aa44763c996d7483322d1087cbff14bd73c
gitee
NissonCX/CQU-HarmonyOS-APP-Dev-Final
entry/src/main/ets/utils/ReminderManager.ets
arkts
saveReminderConfig
保存提醒配置
private async saveReminderConfig(reminder: ReminderSettings): Promise<void> { try { const key = `reminder_config_${reminder.id}`; AppStorage.setOrCreate(key, JSON.stringify(reminder)); } catch (error) { console.error('保存提醒配置失败:', JSON.stringify(error)); } }
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 saveReminderConfig AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left reminder AST#identifier#Right AST#...
private async saveReminderConfig(reminder: ReminderSettings): Promise<void> { try { const key = `reminder_config_${reminder.id}`; AppStorage.setOrCreate(key, JSON.stringify(reminder)); } catch (error) { console.error('保存提醒配置失败:', JSON.stringify(error)); } }
https://github.com/NissonCX/CQU-HarmonyOS-APP-Dev-Final
6ef9ab5da2ea13b04edfaaf20bd74e96b9b5018b
github
Octo-o-o-o/harmonyos-ai-workspace
samples/templates/error-event-builder/ErrorEventBuilder.ets
arkts
startUpload
Call-site demo: 4 fail states, each ONE line. Compare to the anti-pattern in §12 where each `if` branch contained 5 lines of `new Payload + assign + assign + assign + emit`. With helpers the branching reads as policy ("what's invalid → what code → cleanup?"), not as boilerplate.
async startUpload( corrId: string, request: BridgeUploadStartRequestPayload, ): Promise<void> { // State 1 — pre-registration fail: validation if (!this.isAllowed(request.endpoint)) { this.reportError(corrId, 'BRIDGE.INVALID_PAYLOAD', 'endpoint not allowed', false) return } // S...
AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left startUpload AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left corrId AST#identifier#Right AST#type_annotation#Left AST#:#Left : A...
async startUpload( corrId: string, request: BridgeUploadStartRequestPayload, ): Promise<void> { // State 1 — pre-registration fail: validation if (!this.isAllowed(request.endpoint)) { this.reportError(corrId, 'BRIDGE.INVALID_PAYLOAD', 'endpoint not allowed', false) return } // S...
https://github.com/Octo-o-o-o/harmonyos-ai-workspace
47658263b6a1db2d5d7ed6bfdaf19693aed279c7
github
openharmony/codelabs
ETSUI/LifeTrack/entry/src/main/ets/services/ReminderService.ets
arkts
formatError
格式化错误信息
private formatError(error: Error | string | object): string { if (error instanceof Error) { return error.message; } if (typeof error === 'string') { return error; } try { return JSON.stringify(error); } catch { return '未知错误'; } }
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left formatError AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left error AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#binary_expressio...
private formatError(error: Error | string | object): string { if (error instanceof Error) { return error.message; } if (typeof error === 'string') { return error; } try { return JSON.stringify(error); } catch { return '未知错误'; } }
https://gitcode.com/openharmony/codelabs
76c9ebc1858c68ce6a3e392abc939deaae17a280
gitcode
Joker-x-dev/CoolMallArkTS
core/navigation/src/main/ets/goods/GoodsNavigator.ets
arkts
toDetail
跳转到商品详情 @param {number} goodsId - 商品 ID @returns {void} 无返回值
static toDetail(goodsId: number): void { const params: GoodsIdParam = { goodsId }; navigateTo(GoodsRoutes.Detail, params); }
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left toDetail AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left goodsId AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#number#Left number AST#number#Right ...
static toDetail(goodsId: number): void { const params: GoodsIdParam = { goodsId }; navigateTo(GoodsRoutes.Detail, params); }
https://github.com/Joker-x-dev/CoolMallArkTS
763e7e6f6931efc6cc62e3243f13b0936e59f3f8
github
DaLongZhuaZi/manxia
entry/src/main/ets/Framework/Animation/GlobalAnimationSystem.ets
arkts
createRotateState
创建旋转动画状态
public createRotateState(angle: number): AnimationState { return { isPlaying: false, isCompleted: false, currentIteration: 0, progress: 0, rotate: angle }; }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left createRotateState AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left angle AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Le...
public createRotateState(angle: number): AnimationState { return { isPlaying: false, isCompleted: false, currentIteration: 0, progress: 0, rotate: angle }; }
https://github.com/DaLongZhuaZi/manxia
8acc87b9a6dbeb9c6b55a3da18c1e1b41fb0deb7
github
LongLiveY96/chatcube
entry/src/main/ets/services/DatabaseService.ets
arkts
addSortOrderColumnIfNeeded
添加 sort_order 字段(用于数据库升级)
private async addSortOrderColumnIfNeeded(): Promise<void> { if (this.rdbStore === null) { return } try { await this.rdbStore.executeSql(`ALTER TABLE ${TableNames.PROVIDERS} ADD COLUMN sort_order INTEGER DEFAULT 0`) } catch (error) { // 如果字段已存在,会抛出错误,忽略即可 console.info('DatabaseS...
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 addSortOrderColumnIfNeeded AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_express...
private async addSortOrderColumnIfNeeded(): Promise<void> { if (this.rdbStore === null) { return } try { await this.rdbStore.executeSql(`ALTER TABLE ${TableNames.PROVIDERS} ADD COLUMN sort_order INTEGER DEFAULT 0`) } catch (error) { // 如果字段已存在,会抛出错误,忽略即可 console.info('DatabaseS...
https://github.com/LongLiveY96/chatcube
b6b0bb8291e3fe4368fad1bbff7cc8c4d6a86f02
github
XHXYT/Pixark
entry/src/main/ets/viewmodel/IllustDetailViewModel.ets
arkts
detailImageUrls
详情页图片 URL 列表 (受 image_detail_quality 控制)
get detailImageUrls(): string[] { return this.imageList.map(img => ImageUtils.getImageUrlByQuality(img, appSettings.image_detail_quality)); }
AST#program#Left AST#ERROR#Left AST#get#Left get AST#get#Right AST#call_expression#Left AST#identifier#Left detailImageUrls 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#ERROR#Right AST#expression_stat...
get detailImageUrls(): string[] { return this.imageList.map(img => ImageUtils.getImageUrlByQuality(img, appSettings.image_detail_quality)); }
https://github.com/XHXYT/Pixark/blob/fd28e9760e7566d4db095653f7fc4664a819fa5c/entry/src/main/ets/viewmodel/IllustDetailViewModel.ets#L171-L173
cc363d5983d951f749b5d21509030374d3b959bd
github
AlkaidLab/moonlight-harmony
entry/src/main/ets/service/network/PairingManager.ets
arkts
getHttpsUrl
获取 HTTPS URL(匹配 Android getHttpsUrl 行为) 优先使用 serverinfo 返回的 HttpsPort,兜底用 httpPort - 5
private async getHttpsUrl(): Promise<string> { try { const response = await this.fetchServerInfo(); const httpsPortStr = XmlUtil.getValue(response, 'HttpsPort'); if (httpsPortStr) { const httpsPort = parseInt(httpsPortStr); if (httpsPort > 0) { console.info(`PairingMana...
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 getHttpsUrl AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:...
private async getHttpsUrl(): Promise<string> { try { const response = await this.fetchServerInfo(); const httpsPortStr = XmlUtil.getValue(response, 'HttpsPort'); if (httpsPortStr) { const httpsPort = parseInt(httpsPortStr); if (httpsPort > 0) { console.info(`PairingMana...
https://github.com/AlkaidLab/moonlight-harmony
3e39b921c650fe9725f78d4a8fd07a73285cf831
github
openharmony-sig/fluttertpc_wakelock_plus
wakelock_plus/ohos/ohos/src/main/ets/components/plugin/WakelockApi.ets
arkts
setup
Sets up an instance of `WakelockApi` to handle messages through the `binaryMessenger`.
static setup(binaryMessenger: BinaryMessenger, api: WakelockApi | null): void { { let channel: BasicMessageChannel<Object> = new BasicMessageChannel( binaryMessenger, "dev.flutter.pigeon.WakelockPlusApi.toggle", WakelockApi.getCodec()); if (api != null) { channel.setMessageHa...
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left static AST#identifier#Right AST#ERROR#Left AST#identifier#Left setup AST#identifier#Right AST#ERROR#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left binaryMessenger AST#identifier#Right AST#:#Left : AST#:#Ri...
static setup(binaryMessenger: BinaryMessenger, api: WakelockApi | null): void { { let channel: BasicMessageChannel<Object> = new BasicMessageChannel( binaryMessenger, "dev.flutter.pigeon.WakelockPlusApi.toggle", WakelockApi.getCodec()); if (api != null) { channel.setMessageHa...
https://gitee.com/openharmony-sig/fluttertpc_wakelock_plus.git
3da62d9c1c34dfffe385ae61aea92a6cd925bc5f
gitee
AlkaidLab/moonlight-harmony
entry/src/main/ets/service/input/GamepadManager.ets
arkts
handleAxisEvent
处理轴事件 (InputKit)
handleAxisEvent(deviceId: number, axisCode: number, value: number): void { if (!this.connectedDevices.has(deviceId)) return; const state = this.deviceStates.get(deviceId); if (!state) return; switch (axisCode) { case 0: { // ABS_X - 左摇杆 X const dz = this.applyStickDeadzone(valu...
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left handleAxisEvent AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left deviceId AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#number#Left number AST#number#Right AST#ERROR#Right AST#,#Left , AST...
handleAxisEvent(deviceId: number, axisCode: number, value: number): void { if (!this.connectedDevices.has(deviceId)) return; const state = this.deviceStates.get(deviceId); if (!state) return; switch (axisCode) { case 0: { // ABS_X - 左摇杆 X const dz = this.applyStickDeadzone(valu...
https://github.com/AlkaidLab/moonlight-harmony
323bae734bdabe0397e2eb8467f34d4ca699bd3f
github
LJ666-ui/harmony-health-care
5-skill离线包/星云智联–分布式AI全周期智慧健康管理平台_skills/skills/MedicalRiskAssessSkill.ets
arkts
calculateOverallRisk
计算综合风险评分
private static calculateOverallRisk( riskFactors: RiskFactor[], chronicRisks: ChronicDiseaseRisk[] ): { score: number; level: 'low' | 'medium' | 'high' | 'very_high' } { if (riskFactors.length === 0) { return { score: 0, level: 'low' }; } // 加权计算:风险因子占60%,慢性病风险占40% const factorSc...
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 calculateOverallRisk AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left riskFactors AST#identifier#Righ...
private static calculateOverallRisk( riskFactors: RiskFactor[], chronicRisks: ChronicDiseaseRisk[] ): { score: number; level: 'low' | 'medium' | 'high' | 'very_high' } { if (riskFactors.length === 0) { return { score: 0, level: 'low' }; } // 加权计算:风险因子占60%,慢性病风险占40% const factorSc...
https://github.com/LJ666-ui/harmony-health-care
d2f3e204a12696cc86f5ba2e917db7453de49a43
github
wblxr408/SEU-SE-HarmonyExpense-App-
entry/src/main/ets/dao/OCRRecognitionDAO.ets
arkts
softDelete
软删除识别记录
static async softDelete(recordId: number): Promise<boolean> { try { const store = DatabaseManager.getDatabase(); const values: relationalStore.ValuesBucket = { is_deleted: 1, updated_at: new Date().toISOString() }; const predicates = new relationalStore.RdbPredicates(OCRRe...
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 softDelete AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left recordId AST#identifier#Right AST#ERROR#Left AST#:#Left : AS...
static async softDelete(recordId: number): Promise<boolean> { try { const store = DatabaseManager.getDatabase(); const values: relationalStore.ValuesBucket = { is_deleted: 1, updated_at: new Date().toISOString() }; const predicates = new relationalStore.RdbPredicates(OCRRe...
https://github.com/wblxr408/SEU-SE-HarmonyExpense-App-
0d7c52cb4af4af4fca1ab6b08b12f4ae72363d69
github
DaLongZhuaZi/manxia
entry/src/main/ets/Framework/Cache/ImageCacheManager.ets
arkts
evictMemoryCacheIfNeeded
内存缓存淘汰
private evictMemoryCacheIfNeeded(newImageSize: number): void { const maxSize = this.config.memoryCache.maxSize; const maxCount = this.config.memoryCache.maxCount; // 检查大小限制 while (this.memoryCacheSize + newImageSize > maxSize || this.memoryCache.size >= maxCount) { if (this.memoryCache.size...
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left evictMemoryCacheIfNeeded AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left newImageSize AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#number#Left ...
private evictMemoryCacheIfNeeded(newImageSize: number): void { const maxSize = this.config.memoryCache.maxSize; const maxCount = this.config.memoryCache.maxCount; // 检查大小限制 while (this.memoryCacheSize + newImageSize > maxSize || this.memoryCache.size >= maxCount) { if (this.memoryCache.size...
https://github.com/DaLongZhuaZi/manxia
f79be7eda20a75c3275cff3c5b56b99e6e868d6e
github
aimilin6688/KeePassHO
entry/src/main/ets/services/CrashLogService.ets
arkts
clearCrashLog
清除所有崩溃日志
public async clearCrashLog(): Promise<boolean> { try { if (!this.logDirPath) { return false; } const files = await this.getCrashLogFiles(); for (const fileName of files) { const filePath = `${this.logDirPath}/${fileName}`; await fileIo.unlink(filePath); hilo...
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 clearCrashLog AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#...
public async clearCrashLog(): Promise<boolean> { try { if (!this.logDirPath) { return false; } const files = await this.getCrashLogFiles(); for (const fileName of files) { const filePath = `${this.logDirPath}/${fileName}`; await fileIo.unlink(filePath); hilo...
https://github.com/aimilin6688/KeePassHO/blob/6ac299504782abfed903b23a13c736b0841388d9/entry/src/main/ets/services/CrashLogService.ets#L489-L506
85030cc509c5226276e7d06bd61c45912df6d488
github
offlinecat-dev/OCNetORM
src/main/ets/query/RelationLoader.ets
arkts
constructor
构造函数 @param sourceEntityName 源实体名称
constructor(sourceEntityName: string, storeProvider?: () => relationalStore.RdbStore) { this.sourceEntityName = sourceEntityName this.relationStrategies = new Map<RelationType, RelationLoadStrategy>() this.storeProvider = storeProvider ? storeProvider : null this.relationStrategies.set( Relation...
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#identifier#Left sourceEntityName AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string AST#string#Right AST#ERROR#Rig...
constructor(sourceEntityName: string, storeProvider?: () => relationalStore.RdbStore) { this.sourceEntityName = sourceEntityName this.relationStrategies = new Map<RelationType, RelationLoadStrategy>() this.storeProvider = storeProvider ? storeProvider : null this.relationStrategies.set( Relation...
https://github.com/offlinecat-dev/OCNetORM
003fb011f1098ebe6d7894dea1db1d59f6057998
github
openharmony/applications_calendar_data
datamanager/src/main/ets/processor/alerts/AlertsProcessor.ets
arkts
removeScheduledAlarmsLocked
移除状态为0的Alarms @param rdbStore
async function removeScheduledAlarmsLocked(rdbStore: data_rdb.RdbStore) { Log.info(TAG, 'removeScheduledAlarmsLocked start.'); let predicates = new dataSharePredicates.DataSharePredicates(); predicates.equalTo(CalendarAlertsColumns.STATE, CalendarAlertStateType.STATE_SCHEDULED) try { await rdbStore.delete(C...
AST#program#Left AST#function_declaration#Left AST#async#Left async AST#async#Right AST#function#Left function AST#function#Right AST#identifier#Left removeScheduledAlarmsLocked AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left rdbStore AST#identifi...
async function removeScheduledAlarmsLocked(rdbStore: data_rdb.RdbStore) { Log.info(TAG, 'removeScheduledAlarmsLocked start.'); let predicates = new dataSharePredicates.DataSharePredicates(); predicates.equalTo(CalendarAlertsColumns.STATE, CalendarAlertStateType.STATE_SCHEDULED) try { await rdbStore.delete(C...
https://gitee.com/openharmony/applications_calendar_data.git
4662fea4440e9450f2ba5c9219ae698ce7af99c7
gitee
iop123123/arkts-static-skills
docs/ArkTS-Language-Guide/08-Stdlib/stdlib-source/std/core/ArrayBuffer.ets
arkts
getByteLength
Returns the length of the ArrayBuffer in bytes. @returns { int } The byte length. @syscap SystemCapability.Utils.Lang @FaAndStageModel
public getByteLength(): int { return this._byteLength }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left getByteLength 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 int AST#...
public getByteLength(): int { return this._byteLength }
https://gitcode.com/iop123123/arkts-static-skills
5ed2e69137b6d9f05576ec55bf7a55384b1b7a86
gitcode
iop123123/arkts-static-skills
docs/ArkTS-Language-Guide/08-Stdlib/stdlib-source/std/core/json.ets
arkts
createByteFromJSONValue
Creates a Byte instance based on JSONValue @param { Byte } this JSONValue - a JSON representation @param { JSONValue } json @returns { Byte } - byte value decoded from JSON @throws { JSONTypeError } if json does not encode a valid byte
function createByteFromJSONValue(json: JSONValue): Byte { if (json instanceof JSONNumber) { let num = (json as JSONNumber).value if (Double.isInteger(num) && Byte.MIN_VALUE <= num && num <= Byte.MAX_VALUE) { return num.toByte() } } throw new JSONTypeError('Cannot create B...
AST#program#Left AST#function_declaration#Left AST#function#Left function AST#function#Right AST#identifier#Left createByteFromJSONValue 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 createByteFromJSONValue(json: JSONValue): Byte { if (json instanceof JSONNumber) { let num = (json as JSONNumber).value if (Double.isInteger(num) && Byte.MIN_VALUE <= num && num <= Byte.MAX_VALUE) { return num.toByte() } } throw new JSONTypeError('Cannot create B...
https://gitcode.com/iop123123/arkts-static-skills
0a0a0367c0798c4c7c14efa1e08d7b828b14715e
gitcode
richshaw2015/nds
ohos/entry/src/main/ets/components/game/PauseMenu.ets
arkts
getNarrowMenuItems
窄屏模式下的菜单项(存档管理替代原来的保存/加载两项)
function getNarrowMenuItems(): MenuItemConfig[] { return [ { option: PauseMenuOption.RESUME, label: I18n.t('resume'), icon: CupertinoIcons.play }, { option: PauseMenuOption.SAVE_STATE, label: I18n.t('save_manager'), icon: CupertinoIcons.square_and_arrow_down }, { option: PauseMenuOption.CHEATS, label: I18...
AST#program#Left AST#function_declaration#Left AST#function#Left function AST#function#Right AST#identifier#Left getNarrowMenuItems AST#identifier#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#array_ty...
function getNarrowMenuItems(): MenuItemConfig[] { return [ { option: PauseMenuOption.RESUME, label: I18n.t('resume'), icon: CupertinoIcons.play }, { option: PauseMenuOption.SAVE_STATE, label: I18n.t('save_manager'), icon: CupertinoIcons.square_and_arrow_down }, { option: PauseMenuOption.CHEATS, label: I18...
https://github.com/richshaw2015/nds
174361d08b5306c0989aa3923592e8567b018b48
github
DaLongZhuaZi/manxia
entry/src/main/ets/Framework/Loaders/MangaDetailLoader.ets
arkts
parseChineseNumber
解析中文数字
private parseChineseNumber(chineseStr: string, numMap: Record<string, number>): number | null { if (!chineseStr) return null; let result = 0; let temp = 0; for (let i = 0; i < chineseStr.length; i++) { const char = chineseStr[i]; const num = numMap[char]; if (num === undefined) { ...
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left parseChineseNumber AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left chineseStr AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string A...
private parseChineseNumber(chineseStr: string, numMap: Record<string, number>): number | null { if (!chineseStr) return null; let result = 0; let temp = 0; for (let i = 0; i < chineseStr.length; i++) { const char = chineseStr[i]; const num = numMap[char]; if (num === undefined) { ...
https://github.com/DaLongZhuaZi/manxia
88f8fe75667fb9c565917549a37c4062f9a71a29
github
openharmony-tpc/ohos_coap
libcoap/src/main/ets/components/mainpage/coapResource.ets
arkts
registerGetHandler
get请求
registerGetHandler(resourceId: string, cb: Function): void { return this.coapResource.registerGetHandler(resourceId, cb); }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left registerGetHandler AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left resourceId AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string AST#string#Right AST#ERROR#Right AST#,#Left ...
registerGetHandler(resourceId: string, cb: Function): void { return this.coapResource.registerGetHandler(resourceId, cb); }
https://gitee.com/openharmony-tpc/ohos_coap.git
beeb595e59837a690d261d724d0aa7a276242bf4
gitee
itrainhub/wu-ui
WuUI/wu_ui/src/main/ets/utils/GlobalData.ets
arkts
init
初始化组件库 @param windowStage
public static init(windowStage: window.WindowStage) { windowStage.getMainWindow((err: BusinessError, data) => { if (err.code) { console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`) return } // 上下文 WuGlobalData.context = data.g...
AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left public AST#identifier#Right AST#ERROR#Left AST#identifier#Left static AST#identifier#Right AST#identifier#Left init AST#identifier#Right AST#ERROR#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#member_expression#Left AST#...
public static init(windowStage: window.WindowStage) { windowStage.getMainWindow((err: BusinessError, data) => { if (err.code) { console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`) return } // 上下文 WuGlobalData.context = data.g...
https://github.com/itrainhub/wu-ui
b85af8d5ab83fa7f1d6e9e6d0ecee6a4fa9d0437
github
lidaixian999/Smart_Car
entry/src/main/ets/model/Ai_online.ets
arkts
sendCustomRequest
示例1:发送自定义内容请求
public static sendCustomRequest(send_data:string): void { const customContent = "你好,请介绍一下人工智能的发展历程"; sendAIRequest(customContent, (response: ChatResponse) => { console.log("收到AI回复: " + response.content); }); }
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 sendCustomRequest AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left send_data AST#identifier#Right AST#ERROR#Left AST#:#...
public static sendCustomRequest(send_data:string): void { const customContent = "你好,请介绍一下人工智能的发展历程"; sendAIRequest(customContent, (response: ChatResponse) => { console.log("收到AI回复: " + response.content); }); }
https://github.com/lidaixian999/Smart_Car
5380427f244048a51a3b29f5f4f053a9f6bbc1fd
github
aimilin6688/KeePassHO
entry/src/main/ets/services/SettingsService.ets
arkts
registerObserver
注册观察者
public registerObserver(observer: (key: string) => void): void { this.observers.push(observer); }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#identifier#Left registerObserver AST#identifier#Right AST#(#Left ( AST#(#Right AST#call_expression#Left AST#identifier#Left observer AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#ERROR#Right AST#arguments#Left AST#(#Left ( AS...
public registerObserver(observer: (key: string) => void): void { this.observers.push(observer); }
https://github.com/aimilin6688/KeePassHO/blob/6ac299504782abfed903b23a13c736b0841388d9/entry/src/main/ets/services/SettingsService.ets#L322-L324
2070b44c7c3efc5806dcf83712136ddfb13d831b
github
Nekofox-POT/LinMusic
entry/src/main/ets/建筑垃圾堆/class_audio_player_old.ets
arkts
load_dsd
dsd重加载 //
load_dsd() { // 加载dsd表 try {fs.statSync(audio_player_path + '/dsd_cache')} catch {fs.mkdirSync(audio_player_path + '/dsd_cache')} for (const i of fs.listFileSync(audio_player_path + '/dsd_cache', { recursion: true })) { // 传入 this.dsd_list.set(nativeModule.extractFilename(audio_player_path + '...
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left load_dsd 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 // 加载dsd表 AST#c...
load_dsd() { // 加载dsd表 try {fs.statSync(audio_player_path + '/dsd_cache')} catch {fs.mkdirSync(audio_player_path + '/dsd_cache')} for (const i of fs.listFileSync(audio_player_path + '/dsd_cache', { recursion: true })) { // 传入 this.dsd_list.set(nativeModule.extractFilename(audio_player_path + '...
https://github.com/Nekofox-POT/LinMusic
b7a217199cc156301bd458b2f56f6e7b7017b1d8
github
openharmony-tpc/ohos_mpchart
library/src/main/ets/components/listener/BarLineChartTouchListener.ets
arkts
constructor
Constructor with initialization parameters. @param chart instance of the chart @param touchMatrix the touch-matrix of the chart @param dragTriggerDistance the minimum movement distance that will be interpreted as a "drag" gesture in vp (3vp equals to about 9 pixels on a 5.5" FHD screen)
constructor(chart: BarLineChartBase<BarLineScatterCandleBubbleData<IBarLineScatterCandleBubbleDataSet<EntryOhos>>>, touchMatrix: Matrix, dragTriggerDistance: number) { super(chart); this.mMatrix = touchMatrix; this.mDragTriggerDist = Utils.handleDataValues(dragTriggerDistance); this.mMinScalePoi...
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 chart AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#instantiation_expression#Left AST#identifier...
constructor(chart: BarLineChartBase<BarLineScatterCandleBubbleData<IBarLineScatterCandleBubbleDataSet<EntryOhos>>>, touchMatrix: Matrix, dragTriggerDistance: number) { super(chart); this.mMatrix = touchMatrix; this.mDragTriggerDist = Utils.handleDataValues(dragTriggerDistance); this.mMinScalePoi...
https://gitee.com/openharmony-tpc/ohos_mpchart.git
6558a6fe719b3d0f552be6d340e4f853e6e7a549
gitee
openharmony/vendor_unionman
unionpi_tiger/sample_hzu/WEILIAO/entry/src/main/ets/view/Home.ets
arkts
msgList
全局自定义构建函数
@Builder function msgList(item: SwipeInterface) { Row() { Badge({ count: item.noRead, position: BadgePosition.RightTop, style: {} }) { Image(item.icon) .width($r('app.float.homeIcon_width')) .height(($r('app.float.homeIcon_height'))) .borderRadius($r('app.float....
AST#program#Left AST#function_declaration#Left AST#decorator#Left AST#@#Left @ AST#@#Right AST#identifier#Left Builder AST#identifier#Right AST#decorator#Right AST#function#Left function AST#function#Right AST#identifier#Left msgList AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_...
@Builder function msgList(item: SwipeInterface) { Row() { Badge({ count: item.noRead, position: BadgePosition.RightTop, style: {} }) { Image(item.icon) .width($r('app.float.homeIcon_width')) .height(($r('app.float.homeIcon_height'))) .borderRadius($r('app.float....
https://gitee.com/openharmony/vendor_unionman.git
dcbeedaac5d66c2855f95313fc6771abcdc4f7aa
gitee
HarmonyOS_Samples/guide-snippets
ArkData/DataObject/CrossDeviceMigration/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
arkts
onContinue
1. 迁移发起端在onContinue接口中创建分布式数据对象并保存数据到接收端
async onContinue(wantParam: Record<string, Object | undefined>): Promise<AbilityConstant.OnContinueResult> { // 1.1 获取需要设置的分布式对象的资产关键uri try { let sessionId: string = distributedDataObject.genSessionId(); wantParam.distributedSessionId = sessionId; let distrUriArray: string[] = []; le...
AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left onContinue AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left wantParam AST#identifier#Right AST#type_annotation#Left AST#:#Left :...
async onContinue(wantParam: Record<string, Object | undefined>): Promise<AbilityConstant.OnContinueResult> { // 1.1 获取需要设置的分布式对象的资产关键uri try { let sessionId: string = distributedDataObject.genSessionId(); wantParam.distributedSessionId = sessionId; let distrUriArray: string[] = []; le...
https://gitcode.com/HarmonyOS_Samples/guide-snippets
bc927a1c7f6d12c0dc245838f57e8b9e85304fdc
gitcode
openharmony-tpc/mp4parser
library/src/main/ets/mp4parser/MP4Parser.ets
arkts
videoClip
Video clipping @param startTime @param endTime @param sourcePath @param outPath @param callback
static videoClip(startTime: string, endTime: string, sourcePath: string, outPath: string, callBack: ICallBack): void { mp4parser_napi.exeFFmpegCmd("ffmpeg -y -i " + sourcePath + " -ss " + startTime + " -c copy -to " + endTime + " " + outPath) .then((res: number) => { callBack.callBackResult(res) ...
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left videoClip AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left startTime AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string AST#string#Rig...
static videoClip(startTime: string, endTime: string, sourcePath: string, outPath: string, callBack: ICallBack): void { mp4parser_napi.exeFFmpegCmd("ffmpeg -y -i " + sourcePath + " -ss " + startTime + " -c copy -to " + endTime + " " + outPath) .then((res: number) => { callBack.callBackResult(res) ...
https://gitee.com/openharmony-tpc/mp4parser.git
c82674b0dfd3aa3855b61f7fe0eb1fa164442ab7
gitee
openharmony/arkui_ace_engine
advanced_ui_component/treeviewv2/source/treeviewv2.ets
arkts
onceNodeClick
Node click event registration and processing (once). @syscap SystemCapability.ArkUI.ArkUI.Full @since 26
public onceNodeClick(callback: OnChangedCallback): void { this.nodeClickOnceEvents.push(callback); }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left onceNodeClick AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left callback AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Lef...
public onceNodeClick(callback: OnChangedCallback): void { this.nodeClickOnceEvents.push(callback); }
https://gitcode.com/openharmony/arkui_ace_engine
4c4d117864932a9297f96555d1348b42bf993c03
gitcode
ZestBox-18/kitebook-frontend
commons/base/src/main/ets/utils/DebounceManager.ets
arkts
getActiveCount
获取当前活跃的防抖定时器数量 @returns 活跃定时器数量
public getActiveCount(): number { return DebounceManager.debounceTimers.size; }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left getActiveCount 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#...
public getActiveCount(): number { return DebounceManager.debounceTimers.size; }
https://github.com/ZestBox-18/kitebook-frontend
b1c0ae4573fea658bc9c4986a16674bb4319bb46
github
apap6628114/nga_oh
entry/src/main/ets/common/managers/ThreadPaginationManager.ets
arkts
replaceWith
用新的一页帖子整体替换当前内容(跳页/首次加载场景)。 @param newPosts - 该页帖子 @param page - 页码 @param totalPages - 总页数
replaceWith(newPosts: PostInfo[], page: number, totalPages: number): void { this.loadedLouSet.clear() for (let i = 0; i < newPosts.length; i++) { this.loadedLouSet.add(newPosts[i].lou) } this.posts = newPosts this.pageOfIndex = newPosts.map(() => page) this.loadedPageStart = page thi...
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left replaceWith AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left newPosts AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#subscript_expression#Left AST#identifier#Left PostInfo A...
replaceWith(newPosts: PostInfo[], page: number, totalPages: number): void { this.loadedLouSet.clear() for (let i = 0; i < newPosts.length; i++) { this.loadedLouSet.add(newPosts[i].lou) } this.posts = newPosts this.pageOfIndex = newPosts.map(() => page) this.loadedPageStart = page thi...
https://github.com/apap6628114/nga_oh/blob/5db5f8174b9a994685dc00fce666367b68c13f78/entry/src/main/ets/common/managers/ThreadPaginationManager.ets#L55-L64
9d19c260ae2ba4db44866b89738ef9c6a7a11281
github
openharmony/applications_permission_manager
permissionmanager/src/main/ets/GlobalExtAbility/GlobalExtAbility.ets
arkts
onDestroy
Lifecycle function, called back before a service extension is destroyed.
onDestroy(): void { Log.info('ServiceExtensionAbility onDestroy.'); globalWindow?.destroyWindow(); }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left onDestroy 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#Le...
onDestroy(): void { Log.info('ServiceExtensionAbility onDestroy.'); globalWindow?.destroyWindow(); }
https://gitee.com/openharmony/applications_permission_manager.git
a55558972c4776ccd592b711370eff6db63e4fa8
gitee
fa223797/Harmonyos-notebook
entry/src/main/ets/view/TaskStatisties.ets
arkts
computedStatusCount
当做自己的计算属性,但是page02一定记得要父组件传参,否则没东西
computedStatusCount(status:string){ const count = this.tasks.reduce((sum:number,item:TaskModel)=>{ if(item.taskStatus === status){ sum+=1 } return sum },0) return count }
AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left computedStatusCount AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left status AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string AST#string#Right AST#ERROR#Right...
computedStatusCount(status:string){ const count = this.tasks.reduce((sum:number,item:TaskModel)=>{ if(item.taskStatus === status){ sum+=1 } return sum },0) return count }
https://github.com/fa223797/Harmonyos-notebook
36365639d1ddf84590c6fc82d9fa20075a964966
github
miaochiahao/ark-ghidra
data/test_hap/arkts-decompile-test_original_index.ets
arkts
testIfElse
=== Control Flow Patterns ===
function testIfElse(x: number): string { if (x > 0) { return 'positive'; } else if (x < 0) { return 'negative'; } else { return 'zero'; } }
AST#program#Left AST#function_declaration#Left AST#function#Left function AST#function#Right AST#identifier#Left testIfElse AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left x AST#identifier#Right AST#type_annotation#Left AST#:#Left : AST#:#Right AS...
function testIfElse(x: number): string { if (x > 0) { return 'positive'; } else if (x < 0) { return 'negative'; } else { return 'zero'; } }
https://github.com/miaochiahao/ark-ghidra
73c6a61ace3446cd2f6102cfdafd90de10cbf552
github
AGenUI/AGenUI
platforms/harmony/agenui/src/main/ets/agenui/custom/A2UIComponent.ets
arkts
constructor
@param surfaceId Surface ID @param nodeId Node ID @param componentType Component type name @param viewStatePtr C++ ViewState pointer @param builder Builder wrapped by wrapBuilder() that defines the visual template
constructor(surfaceId: string, nodeId: string, componentType: string, viewStatePtr: bigint, builder: WrappedBuilder<[CustomView]>) { super(componentType, surfaceId, nodeId, viewStatePtr); this._builder = builder; this.customSurfaceId = surfaceId; this.customNodeId = nodeId; this.cust...
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#identifier#Left surfaceId AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string AST#string#Right AST#ERROR#Right AST#...
constructor(surfaceId: string, nodeId: string, componentType: string, viewStatePtr: bigint, builder: WrappedBuilder<[CustomView]>) { super(componentType, surfaceId, nodeId, viewStatePtr); this._builder = builder; this.customSurfaceId = surfaceId; this.customNodeId = nodeId; this.cust...
https://github.com/AGenUI/AGenUI
bb86673fc789b0141c6559c77380807bce88985d
github
openharmony-sig/arkcompiler_runtime_core
plugins/ets/tests/ets-templates/03.types/07.value_types/01.integer_types_and_operations/unary_plus/unary_plus_ushort.ets
arkts
main
--- desc: check unary plus operation for unsigned short integer operand ---
function main(): void { const v: ushort = {{v.value}} assert +(v) == {{v.result}}
AST#program#Left AST#function_declaration#Left AST#function#Left function AST#function#Right AST#identifier#Left main AST#identifier#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#predefined_type#Left A...
function main(): void { const v: ushort = {{v.value}} assert +(v) == {{v.result}}
https://gitee.com/openharmony-sig/arkcompiler_runtime_core.git
2d7c5a17757d5da1bc1bf0f07800292da7bf0f9a
gitee
NissonCX/CQU-HarmonyOS-APP-Dev-Final
entry/src/main/ets/entryability/EntryAbility.ets
arkts
onCreate
Ability创建时的回调 初始化数据管理器和应用配置
async onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): Promise<void> { try { // 设置颜色模式为系统默认 this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); } catch (err) { hilog.error(DOMAIN, 'testTag', 'Failed to set colorMode. Cause: %{...
AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left onCreate AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left want AST#identifier#Right AST#type_annotation#Left AST#:#Left : AST#:#...
async onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): Promise<void> { try { // 设置颜色模式为系统默认 this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); } catch (err) { hilog.error(DOMAIN, 'testTag', 'Failed to set colorMode. Cause: %{...
https://github.com/NissonCX/CQU-HarmonyOS-APP-Dev-Final
fb8f9804c00021e711863378c7ea403e5f5a506d
github
YANGZX22/Voot
entry/src/main/ets/storage/ApiConfigStorage.ets
arkts
loadSnapshotSync
同步读取配置快照的 JSON 字符串(用于流转时的 onContinue) 注意:此方法使用同步 API,仅在必要时使用
static loadSnapshotSync(ctx: common.Context): string { try { const prefs = preferences.getPreferencesSync(ctx, { name: ApiConfigStorage.PREF_FILE }); const serialized = prefs.getSync(ApiConfigStorage.SNAPSHOT_KEY, '') as string; return serialized || '{}'; } catch (error) { console.erro...
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left loadSnapshotSync 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#member_expressio...
static loadSnapshotSync(ctx: common.Context): string { try { const prefs = preferences.getPreferencesSync(ctx, { name: ApiConfigStorage.PREF_FILE }); const serialized = prefs.getSync(ApiConfigStorage.SNAPSHOT_KEY, '') as string; return serialized || '{}'; } catch (error) { console.erro...
https://github.com/YANGZX22/Voot
befaf35d6ad50ecd1bd957d33f7f25a10428b607
github
ZestBox-18/kitebook-frontend
commons/base/src/main/ets/utils/BillSyncController.ets
arkts
unregister
注销已注册的账单变化监听器。
unregister(listenerId: number): void { this.listeners.delete(listenerId) }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left unregister AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left listenerId AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#number#Left number AST#number#Right AST#ERROR#Right AST#)#Left ) AST#)#...
unregister(listenerId: number): void { this.listeners.delete(listenerId) }
https://github.com/ZestBox-18/kitebook-frontend
c9d763a9c6b27b2335845edccc3e858af4779f74
github
Joker-x-dev/CoolMallArkTS
core/state/src/main/ets/BreakpointState.ets
arkts
resolveBreakpoint
根据窗口宽度计算断点 @param {number} windowWidthVp - 窗口宽度(vp) @returns {BreakpointType} 断点名称
resolveBreakpoint(windowWidthVp: number): BreakpointType { for (const rule of BREAKPOINT_RULES) { if (windowWidthVp < rule.maxWidthVp) { return rule.name; } } return BreakpointType.LG; }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left resolveBreakpoint AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left windowWidthVp AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#number#Left number AST#number#Right AST#ERROR#Right AST#)#Lef...
resolveBreakpoint(windowWidthVp: number): BreakpointType { for (const rule of BREAKPOINT_RULES) { if (windowWidthVp < rule.maxWidthVp) { return rule.name; } } return BreakpointType.LG; }
https://github.com/Joker-x-dev/CoolMallArkTS
5303e5977b3101e06a1336775186d1723b63bf76
github
DaLongZhuaZi/manxia
entry/src/main/ets/Framework/WebView/WebViewAuthManager.ets
arkts
parseDocumentCookieString
解析 document.cookie 字符串为 CookieEntry 数组
private parseDocumentCookieString(cookieStr: string): CookieEntry[] { const result: CookieEntry[] = []; if (!cookieStr || cookieStr.length === 0) { return result; } let normalizedCookieString: string = cookieStr.replace(/\\"/g, ''); normalizedCookieString = normalizedCookieString.replace(/^"...
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left parseDocumentCookieString AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left cookieStr AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left st...
private parseDocumentCookieString(cookieStr: string): CookieEntry[] { const result: CookieEntry[] = []; if (!cookieStr || cookieStr.length === 0) { return result; } let normalizedCookieString: string = cookieStr.replace(/\\"/g, ''); normalizedCookieString = normalizedCookieString.replace(/^"...
https://github.com/DaLongZhuaZi/manxia
2b03c5b049b2d297a8fabe82866c5a314e87b355
github
iop123123/arkts-static-skills
docs/ArkTS-Language-Guide/08-Stdlib/stdlib-source/std/core/TypedUArrays.ets
arkts
toSorted
Creates a sorted copy @returns { Uint32Array } - a sorted copy @syscap SystemCapability.Utils.Lang @FaAndStageModel
public toSorted(): Uint32Array { return new Uint32Array(this).sort() }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left toSorted 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 Uint32Array A...
public toSorted(): Uint32Array { return new Uint32Array(this).sort() }
https://gitcode.com/iop123123/arkts-static-skills
63c9c2e8ddeb9c88f1ac25307efb5a54ca6f3b14
gitcode
RoooyHe/toona-ohos
toona/src/main/ets/services/MediaManager.ets
arkts
uploadImage
✅ 修复 1:复用 uploadMedia 方法,避免直接操作 this.httpClient 导致空指针
async uploadImage(data: ArrayBuffer, fileName: string): Promise<string> { const response = await this.uploadMedia(data, 'image/jpeg', fileName); return response.content_uri; }
AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left uploadImage AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left data AST#identifier#Right AST#type_annotation#Left AST#:#Left : AST...
async uploadImage(data: ArrayBuffer, fileName: string): Promise<string> { const response = await this.uploadMedia(data, 'image/jpeg', fileName); return response.content_uri; }
https://github.com/RoooyHe/toona-ohos
fa27df81bb0364c24156199cd063b92e372ff26a
github
LJ666-ui/harmony-health-care
entry/src/main/ets/common/utils/AccessibilityConfig.ets
arkts
toggleElderMode
切换老年模式
public toggleElderMode(): void { this.config.isElderMode = !this.config.isElderMode; AppStorage.setOrCreate<boolean>('isElderMode', this.config.isElderMode); // 老年模式自动启用大字体 if (this.config.isElderMode) { this.setFontScale(1.25); } else { this.setFontScale(1.0); } cons...
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left toggleElderMode 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#ERROR#Right AST#expres...
public toggleElderMode(): void { this.config.isElderMode = !this.config.isElderMode; AppStorage.setOrCreate<boolean>('isElderMode', this.config.isElderMode); // 老年模式自动启用大字体 if (this.config.isElderMode) { this.setFontScale(1.25); } else { this.setFontScale(1.0); } cons...
https://github.com/LJ666-ui/harmony-health-care
309219c51c942750ad1fffba5e9432b4621a7ca5
github
iop123123/arkts-static-skills
docs/ArkTS-Language-Guide/08-Stdlib/stdlib-source/std/core/TypedArrays.ets
arkts
toReversed
Creates a reversed copy @returns { Float64Array } - a reversed copy @syscap SystemCapability.Utils.Lang @FaAndStageModel
public toReversed(): Float64Array { let newArray = new Float64Array(this.lengthInt); if (this.lengthInt > 0) { Float64Array.reverseCopyBuffer(newArray.buffer, this.buffer, this.byteOffset, this.lengthInt); } return newArray }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left toReversed 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 Float64Arra...
public toReversed(): Float64Array { let newArray = new Float64Array(this.lengthInt); if (this.lengthInt > 0) { Float64Array.reverseCopyBuffer(newArray.buffer, this.buffer, this.byteOffset, this.lengthInt); } return newArray }
https://gitcode.com/iop123123/arkts-static-skills
a1ebdaaafc07d1e72290afba5efe2294eba5e8a1
gitcode
iop123123/arkts-static-skills
cli/arkts-static-cli/runtime/ark/es2panda/linux/etc/sdk/api/@ohos.url.ets
arkts
port
Sets the port portion of the URL. @param { string } port - The port portion of the URL.
set port(port: string) { if (this.cHost == '' || this.cProtocol == 'file:' || port == '') { return; } this.urlInner.setPort(port); this.cPort = this.urlInner.getPort(); this.cHost = this.urlInner.getHost(); this.setHref(); ...
AST#program#Left AST#ERROR#Left AST#set#Left set AST#set#Right AST#call_expression#Left AST#identifier#Left port AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left port AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left string AST#identifie...
set port(port: string) { if (this.cHost == '' || this.cProtocol == 'file:' || port == '') { return; } this.urlInner.setPort(port); this.cPort = this.urlInner.getPort(); this.cHost = this.urlInner.getHost(); this.setHref(); ...
https://gitcode.com/iop123123/arkts-static-skills
4dbb6b2b027ab3760863ce083faea78a316f1bed
gitcode
zcg741/chengyu-game
entry/src/main/ets/viewmodel/GameViewModel.ets
arkts
handleCorrectAnswer
处理正确答案
private async handleCorrectAnswer(): Promise<void> { this.session.score += GAME_CONFIG.SCORE_PER_CORRECT; this.session.correctCount++; this.session.consecutiveCorrect++; // 记录答题结果(用于动态难度调整) this.recentResults.push(true); if (this.recentResults.length > this.RECENT_RESULTS_MAX) { this.re...
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 handleCorrectAnswer AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Rig...
private async handleCorrectAnswer(): Promise<void> { this.session.score += GAME_CONFIG.SCORE_PER_CORRECT; this.session.correctCount++; this.session.consecutiveCorrect++; // 记录答题结果(用于动态难度调整) this.recentResults.push(true); if (this.recentResults.length > this.RECENT_RESULTS_MAX) { this.re...
https://github.com/zcg741/chengyu-game
59572f0df5d0dc7ac238afd44559bd59b4aacbf1
github
fbinba3955/Flymby
common/src/main/ets/utils/StringUtil.ets
arkts
removeHtmlTags
移除HTML标签 @param htmlString HTML字符串 @returns 移除HTML标签后的纯文本
static removeHtmlTags(htmlString: string): string { if (!htmlString) return ''; return htmlString.replace(/<[^>]*>/g, ''); }
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left removeHtmlTags AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left htmlString AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string AST#stri...
static removeHtmlTags(htmlString: string): string { if (!htmlString) return ''; return htmlString.replace(/<[^>]*>/g, ''); }
https://github.com/fbinba3955/Flymby
7ebbfb2f69369483f5e9de6ac513c583ca7e5754
github
richshaw2015/nds
ohos/entry/src/main/ets/types/MelonDSNative.ets
arkts
loadRewindState
加载倒带状态 对齐 Android MelonEmulator.loadRewindState()
static loadRewindState(index: number): boolean { return MelonDSNative.native.loadRewindState(index); }
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left loadRewindState 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...
static loadRewindState(index: number): boolean { return MelonDSNative.native.loadRewindState(index); }
https://github.com/richshaw2015/nds
e564d1d573cef3a282fc6e4fd86482186efe1056
github
LJ666-ui/harmony-health-care
entry/src/main/ets/aiagent/RAGRetriever.ets
arkts
simulateEmbedding
模拟向量化(用于演示) @param text 文本内容 @returns 向量表示
private simulateEmbedding(text: number[]): number[] { // 简单的模拟向量化 // 实际项目中应使用专业的Embedding模型 const dimension = 384; const vector: number[] = []; // 基于文本内容生成伪向量 const seed = this.hashCode(text as unknown as string); for (let i = 0; i < dimension; i++) { const value = Math.sin(seed * (...
AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left simulateEmbedding 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#subscript_e...
private simulateEmbedding(text: number[]): number[] { // 简单的模拟向量化 // 实际项目中应使用专业的Embedding模型 const dimension = 384; const vector: number[] = []; // 基于文本内容生成伪向量 const seed = this.hashCode(text as unknown as string); for (let i = 0; i < dimension; i++) { const value = Math.sin(seed * (...
https://github.com/LJ666-ui/harmony-health-care
39b4a274da78952f7c64e391c256269d48a863e9
github
openharmony/developtools_profiler
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/data/ChartData.ets
arkts
setValueTextSize
Sets the size (in dp) of the value-text for all DataSets this data object contains. @param size
public setValueTextSize(size: number): void { for (let data of this.mDataSets.dataSouce) { data.setValueTextSize(size); } }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left setValueTextSize AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left size AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left...
public setValueTextSize(size: number): void { for (let data of this.mDataSets.dataSouce) { data.setValueTextSize(size); } }
https://gitee.com/openharmony/developtools_profiler.git
d9a513e55aa2e301aa9e766d5a6bce0286885fa6
gitee
harmonyos/codelabs
HarmonyOS_NEXT/TargetManagement/entry/src/main/ets/view/AddTargetDialog.ets
arkts
dialogButtonStyle
Custom button style.
@Extend(Button) function dialogButtonStyle() { .fontSize($r('app.float.button_font')) .height($r('app.float.dialog_btn_height')) .width($r('app.float.dialog_btn_width')) .backgroundColor(Color.White) .fontColor($r('app.color.main_blue')) }
AST#program#Left AST#function_declaration#Left AST#decorator#Left AST#@#Left @ AST#@#Right AST#call_expression#Left AST#identifier#Left Extend AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left Button AST#identifier#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression...
@Extend(Button) function dialogButtonStyle() { .fontSize($r('app.float.button_font')) .height($r('app.float.dialog_btn_height')) .width($r('app.float.dialog_btn_width')) .backgroundColor(Color.White) .fontColor($r('app.color.main_blue')) }
https://gitee.com/harmonyos/codelabs.git
1d63131b4bed1333b7ac98768d7d1c07db77d752
gitee
OSpark-Team/Free-PCM
library/src/main/ets/utils/AudioRendererPlayer.ets
arkts
play
开始播放音频 @param decoder - PCM 流解码器实例 @param info - PCM 流信息(包含采样率、声道数等) @returns Promise<void> 播放开始后 resolve @remarks - 此方法会先停止当前播放(如果正在播放) - 创建 AudioRenderer 并设置音频参数 - 注册 writeData 回调,从解码器拉取 PCM 数据 - 自动启动 AudioRenderer 开始播放 @throws - AudioRenderer 创建失败 - AudioRenderer 启动失败
public async play(decoder: PcmStreamDecoder, info: PcmStreamInfo): Promise<void> { await this.stop(); this.decoder = decoder; this.streamInfo = info; const audioStreamInfo: audio.AudioStreamInfo = { samplingRate: this.mapSamplingRate(info.sampleRate), channels: this.mapChannels(info.chan...
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 play AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left decoder AST#identifier#Right AST#:#Left : AST#:#Rig...
public async play(decoder: PcmStreamDecoder, info: PcmStreamInfo): Promise<void> { await this.stop(); this.decoder = decoder; this.streamInfo = info; const audioStreamInfo: audio.AudioStreamInfo = { samplingRate: this.mapSamplingRate(info.sampleRate), channels: this.mapChannels(info.chan...
https://github.com/OSpark-Team/Free-PCM/blob/3440e7220d07d28815d172b4b3237145434075ee/library/src/main/ets/utils/AudioRendererPlayer.ets#L182-L248
d3073e769132f6b08c21e43e487607c48ca6f465
github
AlkaidLab/moonlight-harmony
entry/src/main/ets/service/customkey/CustomKeyStore.ets
arkts
migrateAbsoluteToPercent
数据迁移:旧的绝对坐标 (x,y vp) → 百分比坐标 (xPercent,yPercent) 检测逻辑:如果 key 有 x/y 字段但没有 xPercent/yPercent(或 xPercent 为 0 且 x > 1), 则认为是旧数据,需要迁移。 @returns true 如果发生了迁移
private static migrateAbsoluteToPercent(): boolean { if (!CustomKeyStore.profiles) return false; // 获取当前屏幕尺寸作为参考(假设旧数据是在当前设备上保存的) const displayInfo = display.getDefaultDisplaySync(); const screenWVp = px2vp(displayInfo.width); const screenHVp = px2vp(displayInfo.height); if (screenWVp <= 0 ||...
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 migrateAbsoluteToPercent AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expressi...
private static migrateAbsoluteToPercent(): boolean { if (!CustomKeyStore.profiles) return false; // 获取当前屏幕尺寸作为参考(假设旧数据是在当前设备上保存的) const displayInfo = display.getDefaultDisplaySync(); const screenWVp = px2vp(displayInfo.width); const screenHVp = px2vp(displayInfo.height); if (screenWVp <= 0 ||...
https://github.com/AlkaidLab/moonlight-harmony
c9fe54651d66a8d8a5d8176cd65c20ece68aa91b
github
lidaixian999/Smart_Car
entry/src/main/ets/model/SsapManager.ets
arkts
getScanStatus
获取扫描状态
public getScanStatus(): boolean { return this.isScanning; }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left getScanStatus 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 getScanStatus(): boolean { return this.isScanning; }
https://github.com/lidaixian999/Smart_Car
6b68700915fc7ed533c3bcec7c54b7d834203521
github
CLMC2025/Vignette
entry/src/main/ets/database/DBManager.ets
arkts
migrateVignetteCacheToItems
==================== VIGNETTE CACHE OPERATIONS ====================
private async migrateVignetteCacheToItems(): Promise<void> { return this.vignetteCacheRepo.migrateVignetteCacheToItems(); }
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 migrateVignetteCacheToItems AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expres...
private async migrateVignetteCacheToItems(): Promise<void> { return this.vignetteCacheRepo.migrateVignetteCacheToItems(); }
https://github.com/CLMC2025/Vignette
f117c4f80cc45a15f17c6de9e38b931a5267b056
github
DaLongZhuaZi/manxia
entry/src/main/ets/Framework/Services/DataService.ets
arkts
performanceTestOperation
性能测试操作
public async performanceTestOperation(index: number): Promise<void> { try { // 模拟一些数据操作 const testData: TestData = { index, timestamp: Date.now(), data: `test_data_${index}` }; // 模拟异步操作 await new Promise<void>(resolve => setTimeout(resolve, Math.random...
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 performanceTestOperation AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left index AST#identifier#Right AST#...
public async performanceTestOperation(index: number): Promise<void> { try { // 模拟一些数据操作 const testData: TestData = { index, timestamp: Date.now(), data: `test_data_${index}` }; // 模拟异步操作 await new Promise<void>(resolve => setTimeout(resolve, Math.random...
https://github.com/DaLongZhuaZi/manxia
749c2c27748f199a733725a1cf7e4a379e808d53
github
xiebyapps/ClipLink
entry/src/main/ets/utils/ClipboardUtil.ets
arkts
hasText
Check if clipboard has text data
static async hasText(): Promise<boolean> { try { const hasPermission = await ClipboardUtil.ensureReadPermission(); if (!hasPermission) { return false; } const systemPasteboard = pasteboard.getSystemPasteboard(); if (!(await systemPasteboard.hasData())) { return false;...
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 hasText AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Left :...
static async hasText(): Promise<boolean> { try { const hasPermission = await ClipboardUtil.ensureReadPermission(); if (!hasPermission) { return false; } const systemPasteboard = pasteboard.getSystemPasteboard(); if (!(await systemPasteboard.hasData())) { return false;...
https://github.com/xiebyapps/ClipLink
9bee85c82bb4f9cd7644a8ddf870f2e6503c2dcb
github
openharmony/codelabs
ETSUI/PassNote/entry/src/main/ets/common/ScheduleData.ets
arkts
getColorForText
根据字符串计算哈希值并返回对应颜色 @param text 输入文本 @returns 十六进制颜色字符串
static getColorForText(text: string): string { if (!text || text.length === 0) { return '#E0E0E0'; // 默认灰色 } let hash = 0; for (let i = 0; i < text.length; i++) { hash = text.charCodeAt(i) + ((hash << 5) - hash); } const index = Math.abs(hash) % CourseColorUtil.PRESET_COLORS.length...
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left getColorForText 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 getColorForText(text: string): string { if (!text || text.length === 0) { return '#E0E0E0'; // 默认灰色 } let hash = 0; for (let i = 0; i < text.length; i++) { hash = text.charCodeAt(i) + ((hash << 5) - hash); } const index = Math.abs(hash) % CourseColorUtil.PRESET_COLORS.length...
https://gitcode.com/openharmony/codelabs
88edd863140f0c75efe3020b5dc0e411dd376f8d
gitcode
somnio-software/my-bot-pal
entry/src/main/ets/utils/PermissionUtils.ets
arkts
openPermissionsSetting
Opens the system permission settings for a specific permission. @param permission - The permission for which to open the settings @param context - The application context @returns A promise that resolves to true if the permission was granted, false otherwise
public async openPermissionsSetting(permission: Permissions, context: Context): Promise<boolean> { try { const atManager = abilityAccessCtrl.createAtManager(); const data = await atManager.requestPermissionOnSetting(context, [permission]); return data[0] === abilityAccessCtrl.GrantStatus....
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 openPermissionsSetting AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left permission AST#identifier#Right A...
public async openPermissionsSetting(permission: Permissions, context: Context): Promise<boolean> { try { const atManager = abilityAccessCtrl.createAtManager(); const data = await atManager.requestPermissionOnSetting(context, [permission]); return data[0] === abilityAccessCtrl.GrantStatus....
https://github.com/somnio-software/my-bot-pal
c78e243e41800c828e27f6175ef304908eea9142
github
apap6628114/nga_oh
entry/src/main/ets/common/datasource/BaseLazyDataSource.ets
arkts
appendAll
在末尾追加元素,逐项触发增量新增通知。 @param list - 待追加元素列表
appendAll(list: T[]): void { const start: number = this.dataList.length for (let i = 0; i < list.length; i++) { this.dataList.push(list[i]) this.notifyAdd(start + i) } }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left appendAll AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left list AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#identifier#Left T AST#identifier#Right AST#[#Left [ AST#[#Right AST#]#Left ] A...
appendAll(list: T[]): void { const start: number = this.dataList.length for (let i = 0; i < list.length; i++) { this.dataList.push(list[i]) this.notifyAdd(start + i) } }
https://github.com/apap6628114/nga_oh/blob/5db5f8174b9a994685dc00fce666367b68c13f78/entry/src/main/ets/common/datasource/BaseLazyDataSource.ets#L71-L77
1470e51656ba12a70a92ca7d3397c5a492e0eb03
github
dingzhilin1990/zhilinclaw
src/security/CredentialVault.ets
arkts
getStats
获取凭证统计信息
public getStats(): Record<string, any> { const credentials = Array.from(this.credentials.values()); return { total: credentials.length, byType: Object.values(CredentialType).reduce((acc, type) => { acc[type] = credentials.filter(c => c.type === type).length; return acc; ...
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left getStats 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#binary_expression#Left AST#id...
public getStats(): Record<string, any> { const credentials = Array.from(this.credentials.values()); return { total: credentials.length, byType: Object.values(CredentialType).reduce((acc, type) => { acc[type] = credentials.filter(c => c.type === type).length; return acc; ...
https://github.com/dingzhilin1990/zhilinclaw
bad83647b074b0072bb847c4daec9a043b71578d
github
arkui-x/samples
CodeLab/Cases/feature/customkeyboardtoh5/src/main/ets/view/CustomKeyboardToH5.ets
arkts
build
浏览器对象
build() { Column() { TabletTitle({ browser: $browser }) Progress({ value: this.browser.progress, total: PROGRESS_TOTAL }) .color($r('app.color.custom_keyboard_to_h5_progress_color')) .visibility(this.browser.hideProgress ? Visibility.None : Visibility.Visible) Divider() ....
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() { TabletTitle({ browser: $browser }) Progress({ value: this.browser.progress, total: PROGRESS_TOTAL }) .color($r('app.color.custom_keyboard_to_h5_progress_color')) .visibility(this.browser.hideProgress ? Visibility.None : Visibility.Visible) Divider() ....
https://gitcode.com/arkui-x/samples
ad61a3d28d82919f14ab111cd3e5459bc61c13cf
gitcode
DaLongZhuaZi/manxia
entry/src/main/ets/Framework/Theme/ThemeColors.ets
arkts
register
注册主题色状态 @param state ThemeColorState实例 @param callback 状态更新回调,用于更新@State变量
static register(state: ThemeColorState, callback: ThemeColorUpdateCallback): void { const id = state.getId(); // 如果已注册,先取消 if (ThemeColorManager.registrations.has(id)) { ThemeColorManager.unregister(state); } // 创建主题变化回调 const themeCallback: ThemeChangeCallback = (theme: ThemeT...
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left register AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left state AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left ThemeC...
static register(state: ThemeColorState, callback: ThemeColorUpdateCallback): void { const id = state.getId(); // 如果已注册,先取消 if (ThemeColorManager.registrations.has(id)) { ThemeColorManager.unregister(state); } // 创建主题变化回调 const themeCallback: ThemeChangeCallback = (theme: ThemeT...
https://github.com/DaLongZhuaZi/manxia
6a84c5351fb4e874d93bf93944bdb8979e433b38
github
HarmonyOS_Samples/MusicHome
common/musicbasic/src/main/ets/api/SongDtoMapper.ets
arkts
toSongItem
Copies all song fields from DTO to a new {@link SongItem}. @param dto Source API DTO. @returns New song item for lists and player state.
public static toSongItem(dto: SongApiDto): SongItem { let item = new SongItem(); item.id = dto.id; item.title = dto.title; item.singer = dto.singer; item.mark = dto.mark; item.label = dto.label; item.src = dto.src; item.index = dto.index; item.lyric = dto.lyric; return item; ...
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 toSongItem AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left dto AST#identifier#Right AST#:#Left : AST#:#...
public static toSongItem(dto: SongApiDto): SongItem { let item = new SongItem(); item.id = dto.id; item.title = dto.title; item.singer = dto.singer; item.mark = dto.mark; item.label = dto.label; item.src = dto.src; item.index = dto.index; item.lyric = dto.lyric; return item; ...
https://gitcode.com/HarmonyOS_Samples/MusicHome
ccba57aafb8b89a33c3ef15c1c911a6ed3e68bf3
gitcode
Joker-x-dev/CoolMallArkTS
core/util/src/main/ets/toast/ToastUtils.ets
arkts
showSpinnerLoading
显示 Spinner 加载提示 @param {string | ResourceStr} message - 提示内容 @returns {void} 无返回值
static showSpinnerLoading(message: string | ResourceStr): void { IBestToast.show({ type: "loading", loadingType: "spinner", message: message }); }
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left showSpinnerLoading AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left message AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#binary_exp...
static showSpinnerLoading(message: string | ResourceStr): void { IBestToast.show({ type: "loading", loadingType: "spinner", message: message }); }
https://github.com/Joker-x-dev/CoolMallArkTS
106bc8c34469f3f23d03d5755498dcee8fd82b04
github
Explore-In-HMOS-Wearable/unit-calculator
entry/src/main/ets/services/PreferencesService.ets
arkts
saveLastUsedForCategory
─── Per-category last-used ────────────────────────────────────────────────
static saveLastUsedForCategory(category: string, from: AnyUnit, to: AnyUnit): void { const raw = AppStorage.get<string>(PrefKeys.CATEGORY_LAST_USED_MAP) ?? '[]'; let arr: CatLastUsed[] = []; try { const parsed = JSON.parse(raw) as CatLastUsed[]; arr = Array.isArray(parsed) ? parsed : []; }...
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left saveLastUsedForCategory AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left category AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string A...
static saveLastUsedForCategory(category: string, from: AnyUnit, to: AnyUnit): void { const raw = AppStorage.get<string>(PrefKeys.CATEGORY_LAST_USED_MAP) ?? '[]'; let arr: CatLastUsed[] = []; try { const parsed = JSON.parse(raw) as CatLastUsed[]; arr = Array.isArray(parsed) ? parsed : []; }...
https://github.com/Explore-In-HMOS-Wearable/unit-calculator
09bb031153983a791f7f26c7dc8599e28fe70fbe
github
killetom/ktretrofit
ktretrofit/src/main/ets/retrofit/Retrofit.ets
arkts
setReadTimeout
Set the read timeout for HTTP requests. @param timeout Timeout in milliseconds. @returns This builder instance for method chaining.
setReadTimeout(timeout: number): RetrofitBuilder { // Create a new HttpClientBuilder with the existing client's configuration const newClientBuilder = new HttpClientBuilder(); // Add all existing interceptors from the current client if (typeof (this.client as any).interceptors === 'ob...
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left setReadTimeout AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left timeout AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#number#Left number AST#number#Right AST#ERROR#Right AST#)#Left ) AST#)...
setReadTimeout(timeout: number): RetrofitBuilder { // Create a new HttpClientBuilder with the existing client's configuration const newClientBuilder = new HttpClientBuilder(); // Add all existing interceptors from the current client if (typeof (this.client as any).interceptors === 'ob...
https://github.com/killetom/ktretrofit
73c31fb2784165b0f498c451063a2957c5d2c59e
github
LongLiveY96/chatcube
entry/src/main/ets/pages/ChatPage.ets
arkts
handleAskUserAnswer
AskUserCard 提交回调: 把答案 JSON 喂给 ToolExecutionService.handleAskUser 的 await
handleAskUserAnswer(toolCallId: string, answerJson: string): void { const resolved = ServiceRegistry.toolExecution().resolvePendingAnswer(toolCallId, answerJson) if (!resolved) { console.warn('ChatPage', `handleAskUserAnswer: no pending resolver for ${toolCallId}`) return } }
AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left handleAskUserAnswer AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left toolCallId AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string AST#string#Right AST#ERROR#Right AST#,#Left...
handleAskUserAnswer(toolCallId: string, answerJson: string): void { const resolved = ServiceRegistry.toolExecution().resolvePendingAnswer(toolCallId, answerJson) if (!resolved) { console.warn('ChatPage', `handleAskUserAnswer: no pending resolver for ${toolCallId}`) return } }
https://github.com/LongLiveY96/chatcube
e09fb91fe24aa35df8c71da7d2c15eebdae22036
github
offlinecat-dev/OCNetORM
src/main/ets/repository/TransactionOptions.ets
arkts
serializable
创建串行化隔离级别的事务选项 @returns 串行化事务选项
static serializable(): TransactionOptions { throw new Error('当前不支持 SERIALIZABLE 隔离级别,请使用 READ_COMMITTED 或 READ_UNCOMMITTED') }
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left serializable 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 Transacti...
static serializable(): TransactionOptions { throw new Error('当前不支持 SERIALIZABLE 隔离级别,请使用 READ_COMMITTED 或 READ_UNCOMMITTED') }
https://github.com/offlinecat-dev/OCNetORM
b122bbb6eda1fb61a2d17a3cb12a326dc36675f2
github
honjow/Next2V
shared/src/main/ets/backup/BackupSecretDenylist.ets
arkts
isExcluded
True when the given preferences key must be excluded from the plaintext whole-store dump.
static isExcluded(key: string): boolean { const lower = key.toLowerCase() for (const fragment of BackupSecretDenylist.SENSITIVE_SUBSTRINGS) { if (lower.includes(fragment)) { return true } } return BackupSecretDenylist.TRANSIENT_KEYS.indexOf(key) >= 0 }
AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left isExcluded AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left key AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left string...
static isExcluded(key: string): boolean { const lower = key.toLowerCase() for (const fragment of BackupSecretDenylist.SENSITIVE_SUBSTRINGS) { if (lower.includes(fragment)) { return true } } return BackupSecretDenylist.TRANSIENT_KEYS.indexOf(key) >= 0 }
https://github.com/honjow/Next2V
c00a953a9fd0b6cd6156e104eb9ca756765d1a83
github
DaLongZhuaZi/manxia
entry/src/main/ets/Framework/Editor/FileEditorService.ets
arkts
getPageState
获取页面实例快照
public getPageState(instanceId: string): FileEditorPageState | null { const state = this.pageStates.get(instanceId); return state ? this.clonePageState(state) : null; }
AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left getPageState AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left instanceId AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string AST#string...
public getPageState(instanceId: string): FileEditorPageState | null { const state = this.pageStates.get(instanceId); return state ? this.clonePageState(state) : null; }
https://github.com/DaLongZhuaZi/manxia
49b01240205029d6452d34cd81a5c3b3a06a21f9
github