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 |
|---|---|---|---|---|---|---|---|---|---|---|
who7708/harmonyos-codelabs | MovieCard/entry/src/main/ets/common/utils/CommonUtils.ets | arkts | insertForm | Insert form data.
@param {FormItem} form Form entity
@param {relationalStore.RdbStore} rdbStore RDB database
@return {Promise<number>} return the row ID if the operation is successful. return -1 otherwise. | insertForm(form: FormItem, rdbStore: relationalStore.RdbStore) {
if ((this.isEmpty(rdbStore)) || (this.isEmpty(form))) {
Logger.error(CommonConstants.TAG_COMMON_UTILS, 'insertForm rdbStore or form is null');
return;
}
rdbStore.insert(CommonConstants.TABLE_NAME, form.toValuesBucket()).catch((er... | AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left insertForm AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left form AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left FormItem AST#identifier#Right ... | insertForm(form: FormItem, rdbStore: relationalStore.RdbStore) {
if ((this.isEmpty(rdbStore)) || (this.isEmpty(form))) {
Logger.error(CommonConstants.TAG_COMMON_UTILS, 'insertForm rdbStore or form is null');
return;
}
rdbStore.insert(CommonConstants.TABLE_NAME, form.toValuesBucket()).catch((er... | https://github.com/who7708/harmonyos-codelabs | ac5cd91d57cdf40e20a78195593e01bf615f240d | github |
PollenWang6/HiXD | entry/src/main/ets/services/ExamService.ets | arkts | mergeExamResults | 合并已安排和未安排考试 | static mergeExamResults(arranged: string, notArranged: string): string {
try {
const arrObj: Record<string, Object> = JSON.parse(arranged) as Record<string, Object>;
const naObj: Record<string, Object> = JSON.parse(notArranged) as Record<string, Object>;
// 从 notArranged 中提取课程名,转成考试行格式(无日期/时间)
... | AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left mergeExamResults AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left arranged AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string AST#stri... | static mergeExamResults(arranged: string, notArranged: string): string {
try {
const arrObj: Record<string, Object> = JSON.parse(arranged) as Record<string, Object>;
const naObj: Record<string, Object> = JSON.parse(notArranged) as Record<string, Object>;
// 从 notArranged 中提取课程名,转成考试行格式(无日期/时间)
... | https://github.com/PollenWang6/HiXD | 103173bd8c21750efcbf87f8e573983c22e312ea | github |
honjow/Next2V | shared/src/main/ets/network/ApiService.ets | arkts | getRepliesWithWebFallback | Get topic replies; when public API returns fewer than total, fall back to public web page HTML. | async getRepliesWithWebFallback(
topicId: number,
expectedReplies: number = 0,
): Promise<V2exReply[]> {
const apiReplies = await this.getReplies(topicId)
if (apiReplies.length === 0 || (expectedReplies > 0 && apiReplies.length < expectedReplies)) {
try {
const webReplies = await this.... | AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left getRepliesWithWebFallback AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left topicId AST#identifier#Right AST#type_annotation#Left... | async getRepliesWithWebFallback(
topicId: number,
expectedReplies: number = 0,
): Promise<V2exReply[]> {
const apiReplies = await this.getReplies(topicId)
if (apiReplies.length === 0 || (expectedReplies > 0 && apiReplies.length < expectedReplies)) {
try {
const webReplies = await this.... | https://github.com/honjow/Next2V | 6e0f8fd6ba4aa865ea7917e575fcc301a6068fd7 | github |
DaLongZhuaZi/manxia | entry/src/main/ets/Framework/Novel/LegadoRhinoEngine.ets | arkts | setRhinoWebviewController | 设置Rhino沙箱专用的WebView控制器
Rhino沙箱需要独立的WebView实例来运行沙箱脚本 | setRhinoWebviewController(controller: webview.WebviewController): void {
logger.info(TAG, '设置Rhino沙箱WebView控制器...');
// 如果引擎还未初始化,先创建执行器
if (!this.rhinoExecutor) {
this.rhinoExecutor = getRhinoWasmExecutor();
logger.info(TAG, '创建了新的RhinoWasmExecutor');
}
// 传递给RhinoWasmExecut... | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left setRhinoWebviewController AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#member_expression#Left AST#identifier#Left controller AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#identifier#Left webview AST#i... | setRhinoWebviewController(controller: webview.WebviewController): void {
logger.info(TAG, '设置Rhino沙箱WebView控制器...');
// 如果引擎还未初始化,先创建执行器
if (!this.rhinoExecutor) {
this.rhinoExecutor = getRhinoWasmExecutor();
logger.info(TAG, '创建了新的RhinoWasmExecutor');
}
// 传递给RhinoWasmExecut... | https://github.com/DaLongZhuaZi/manxia | ad7987bfbf6fc6cb2cd3c70a20e0e695c44738a7 | github |
CLMC2025/Vignette | entry/src/main/ets/ui/Animations.ets | arkts | SuccessAnimation | 成功动画组件 | @Builder
function SuccessAnimation(
key: string,
progress: number
): void {
Column() {
Row() {
Image($r('sys.media.ohos_ic_public_ok'))
.width(24)
.height(24)
.fillColor(DesignTokens.Colors.SUCCESS)
.scale({
x: progress,
y: progress
})
... | 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 SuccessAnimation AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#... | @Builder
function SuccessAnimation(
key: string,
progress: number
): void {
Column() {
Row() {
Image($r('sys.media.ohos_ic_public_ok'))
.width(24)
.height(24)
.fillColor(DesignTokens.Colors.SUCCESS)
.scale({
x: progress,
y: progress
})
... | https://github.com/CLMC2025/Vignette | e799b625061792532cea6a935dd2d0e412a41bd1 | github |
openharmony/applications_call | entry/src/main/ets/model/CallManager.ets | arkts | initCallData | init CallData | private initCallData() {
if (globalThis.abilityWant && globalThis.abilityWant.parameters && ('callState' in globalThis.abilityWant.parameters)) {
if (!this.isServiceConnected) {
globalThis.calluiAbilityContext?.terminateSelf().then((data) => {
LogUtils.i(TAG, 'calluiAbility terminateSelf b... | AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left initCallData 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... | private initCallData() {
if (globalThis.abilityWant && globalThis.abilityWant.parameters && ('callState' in globalThis.abilityWant.parameters)) {
if (!this.isServiceConnected) {
globalThis.calluiAbilityContext?.terminateSelf().then((data) => {
LogUtils.i(TAG, 'calluiAbility terminateSelf b... | https://gitee.com/openharmony/applications_call.git | 1c11f205de951fddab79bb1983abe8758fa13b0f | gitee |
mqxu/HarmonyOS_In_Action | examples/01_foundation/F002_state_management/entry/src/main/ets/utils/StateManager.ets | arkts | toggleBoolean | 切换布尔值状态
@param current 当前布尔值
@returns 切换后的布尔值 | static toggleBoolean(current: boolean): boolean {
return !current;
} | AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left toggleBoolean AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left current AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left... | static toggleBoolean(current: boolean): boolean {
return !current;
} | https://github.com/mqxu/HarmonyOS_In_Action | 7ab060ebe1960cd7b3ed86c594a885f25ff07610 | github |
miaochiahao/ark-ghidra | data/test_hap/arkts-decompile-test22_original_index.ets | arkts | testSwitchLike | --- Switch-like if-else chain --- | function testSwitchLike(): string {
let grade: string = 'B';
let desc: string = '';
if (grade === 'A') {
desc = 'Excellent';
} else if (grade === 'B') {
desc = 'Good';
} else if (grade === 'C') {
desc = 'Average';
} else {
desc = 'Below Average';
}
return desc;
} | AST#program#Left AST#function_declaration#Left AST#function#Left function AST#function#Right AST#identifier#Left testSwitchLike 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_t... | function testSwitchLike(): string {
let grade: string = 'B';
let desc: string = '';
if (grade === 'A') {
desc = 'Excellent';
} else if (grade === 'B') {
desc = 'Good';
} else if (grade === 'C') {
desc = 'Average';
} else {
desc = 'Below Average';
}
return desc;
} | https://github.com/miaochiahao/ark-ghidra | 5c8290e77060152ae8809b7d93deffc3b32c592e | github |
DaLongZhuaZi/manxia | entry/src/main/ets/Framework/Managers/ReadingAnalyticsManager.ets | arkts | saveGoalsSettings | 保存阅读目标设置 | private async saveGoalsSettings(): Promise<void> {
if (!this.preferencesStore) return;
try {
await this.preferencesStore.put(this.KEY_MANGA_GOAL, this.goalsSettings.mangaGoalMinutes);
await this.preferencesStore.put(this.KEY_EBOOK_GOAL, this.goalsSettings.ebookGoalMinutes);
await this.prefe... | 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 saveGoalsSettings AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right... | private async saveGoalsSettings(): Promise<void> {
if (!this.preferencesStore) return;
try {
await this.preferencesStore.put(this.KEY_MANGA_GOAL, this.goalsSettings.mangaGoalMinutes);
await this.preferencesStore.put(this.KEY_EBOOK_GOAL, this.goalsSettings.ebookGoalMinutes);
await this.prefe... | https://github.com/DaLongZhuaZi/manxia | 49782b86ba2e6792cd8b903de1dafd07ecf6a7bd | github |
DaLongZhuaZi/manxia | entry/src/main/ets/Framework/Managers/EnhancedBackupManager.ets | arkts | restoreMangaLibrary | 恢复漫画库 | private async restoreMangaLibrary(items: MangaBackupItem[]): Promise<void> {
logger.info(TAG, `正在恢复漫画库: ${items.length} 项`);
const downloadDirPath = AppStorage.get<string>('downloadSyncDirPath');
const failures: string[] = [];
for (const item of items) {
try {
const now = Date.... | 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 restoreMangaLibrary AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left items AST#identifier#Right AST#:#... | private async restoreMangaLibrary(items: MangaBackupItem[]): Promise<void> {
logger.info(TAG, `正在恢复漫画库: ${items.length} 项`);
const downloadDirPath = AppStorage.get<string>('downloadSyncDirPath');
const failures: string[] = [];
for (const item of items) {
try {
const now = Date.... | https://github.com/DaLongZhuaZi/manxia | b6afbfbb450d73d0f820ade1c42fb4a1b8e3211e | github |
AlkaidLab/moonlight-harmony | entry/src/main/ets/service/usbdriver/SwitchProController.ets | arkts | rumbleTriggers | 扳机震动(Switch Pro 不支持) | rumbleTriggers(_leftTrigger: number, _rightTrigger: number): void {
// Switch Pro 不支持扳机震动
} | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left rumbleTriggers AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left _leftTrigger AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#number#Left number AST#number#Right AST#ERROR#Right AST#,#Left , ... | rumbleTriggers(_leftTrigger: number, _rightTrigger: number): void {
// Switch Pro 不支持扳机震动
} | https://github.com/AlkaidLab/moonlight-harmony | d6a928d6809e1ea3cdd4f7b6cf27162b76667f52 | github |
ZestBox-18/kitebook-frontend | commons/kite_utils/src/main/ets/utils/clog/Clog.ets | arkts | enableSave | 开启所有级别落盘
调用后:info/warn/error 均会写入对应文件及汇总文件(在目录已配置的情况下) | public static enableSave(): void {
Clog.DISABLE_NON_ERROR_SAVE = false;
} | 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 enableSave AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Le... | public static enableSave(): void {
Clog.DISABLE_NON_ERROR_SAVE = false;
} | https://github.com/ZestBox-18/kitebook-frontend | 2d5337388238c2bfdff1a5115fd72aac5fa0d8d6 | github |
miaochiahao/ark-ghidra | data/test_hap/arkts-decompile-test12_original_index.ets | arkts | testComplexTemplate | --- Nested template literal with computed values --- | function testComplexTemplate(): string {
let x: number = 42;
let y: number = 3;
let result: string = `x=${x},y=${y},sum=${String(x + y)}`;
return result;
} | AST#program#Left AST#function_declaration#Left AST#function#Left function AST#function#Right AST#identifier#Left testComplexTemplate 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#predefi... | function testComplexTemplate(): string {
let x: number = 42;
let y: number = 3;
let result: string = `x=${x},y=${y},sum=${String(x + y)}`;
return result;
} | https://github.com/miaochiahao/ark-ghidra | 81b11e6787ee48287885f7319e928574bda0a938 | github |
Amaz1ny/HarmonyDO-public | entry/src/main/ets/common/constants/ApiConstants.ets | arkts | categoryTopics | 分类下话题 | static categoryTopics(slug: string, id: number): string {
return `/c/${slug}/${id}/l/latest.json`;
} | AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left categoryTopics AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left slug AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left s... | static categoryTopics(slug: string, id: number): string {
return `/c/${slug}/${id}/l/latest.json`;
} | https://github.com/Amaz1ny/HarmonyDO-public | 2188c3ef4bc2bdfb80b1133d57e31939efafcb97 | github |
LJ666-ui/harmony-health-care | entry/src/main/ets/aiagent/OphthalmologyAgent.ets | arkts | handleSpecialCase | 处理特定类型的眼科问题
可以根据问题类型提供更专业的回答 | protected async handleSpecialCase(query: string): Promise<string | null> {
// 检测是否为视力检查相关
if (query.includes('视力检查') || query.includes('验光')) {
return this.getVisionExamAdvice();
}
// 检测是否为用眼疲劳相关
if (query.includes('疲劳') || query.includes('累')) {
return this.getEyeStrainAdvice();
... | AST#program#Left AST#ERROR#Left AST#protected#Left protected AST#protected#Right AST#identifier#Left async AST#identifier#Right AST#call_expression#Left AST#identifier#Left handleSpecialCase AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left query AST#identifier#Right AS... | protected async handleSpecialCase(query: string): Promise<string | null> {
// 检测是否为视力检查相关
if (query.includes('视力检查') || query.includes('验光')) {
return this.getVisionExamAdvice();
}
// 检测是否为用眼疲劳相关
if (query.includes('疲劳') || query.includes('累')) {
return this.getEyeStrainAdvice();
... | https://github.com/LJ666-ui/harmony-health-care | ee92e2fb7d7d7852c67ddaf96084a921523c7cba | github |
openharmony/usb_usb_manager | test/native/unittest/usb.manager-test-hap-master/usb/src/main/ets/pages/split_test.ets | arkts | aboutToAppear | Track which interface is expanded | aboutToAppear() {
this.refreshDevices();
} | AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left aboutToAppear 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... | aboutToAppear() {
this.refreshDevices();
} | https://gitee.com/openharmony/usb_usb_manager.git | 0d6bfda51ff598caab6455d71f80c7108c0c553a | gitee |
openharmony/applications_contacts | entry/src/main/ets/presenter/dialer/DialerPresenter.ets | arkts | checkNeedNumberSpace | Check whether formatting spaces are required when entering a number. | checkNeedNumberSpace(numText:string) {
let isSpace = /[+;,#*]/g;
let isRule = /^+./;
if (isSpace.test(numText)) {
// If the number string contains special characters, no space is added.
if (isRule.test(numText)) {
return true;
} else {
return false;
}
}
return true;
} | AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left checkNeedNumberSpace AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left numText AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string AST#string#Right AST#ERROR#Rig... | checkNeedNumberSpace(numText:string) {
let isSpace = /[+;,#*]/g;
let isRule = /^+./;
if (isSpace.test(numText)) {
// If the number string contains special characters, no space is added.
if (isRule.test(numText)) {
return true;
} else {
return false;
}
}
return true;
} | https://gitee.com/openharmony/applications_contacts.git | 2c599bf4e8f51b7650687ad4b37280b6c708024e | gitee |
Mydstiny/RemoteDeskHarmonyOS | entry/src/main/ets/services/RemoteKeyDispatcher.ets | arkts | sendShortcutSequence | 发送快捷键序列 (全部 down → 逆序 up) | sendShortcutSequence(loader: ExtensionLoader, sessionId: number,
keyCodes: number[], label: string,
getLatch: LatchGetter | null = null,
isRemoteDown: RemoteDownGetter | null = null,
setRemoteDown: RemoteDownSetter | null = null): void {
try {
const pressedCodes: number[] = [];
for (le... | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left sendShortcutSequence AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left loader AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left ExtensionLoader AST#identifier#Ri... | sendShortcutSequence(loader: ExtensionLoader, sessionId: number,
keyCodes: number[], label: string,
getLatch: LatchGetter | null = null,
isRemoteDown: RemoteDownGetter | null = null,
setRemoteDown: RemoteDownSetter | null = null): void {
try {
const pressedCodes: number[] = [];
for (le... | https://github.com/Mydstiny/RemoteDeskHarmonyOS | a5636a2872d7bf88bb14916dc6068a602ee9a3fc | github |
DaLongZhuaZi/manxia | entry/src/main/ets/Framework/Utils/TypeGuards.ets | arkts | isNonNegativeNumber | 检查值是否为非负数
@param value - 要检查的值
@returns 是否为非负数 | static isNonNegativeNumber(value: Object): boolean {
if (!TypeGuards.isNumber(value)) {
return false;
}
const numValue = value as number;
return numValue >= 0;
} | AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left isNonNegativeNumber 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#... | static isNonNegativeNumber(value: Object): boolean {
if (!TypeGuards.isNumber(value)) {
return false;
}
const numValue = value as number;
return numValue >= 0;
} | https://github.com/DaLongZhuaZi/manxia | 0c4144f93ee2dc8334f98f4b405606b8bc003cea | github |
HarmonyOS_Samples/sample_in_harmonyos | features/devpractices/src/main/ets/model/ImageModel.ets | arkts | windowSize | Get window size. | windowSize(deviceWidth?: number, deviceHeight?: number): void {
this.componentWidth = deviceWidth as number;
this.componentHeight = deviceHeight as number;
} | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left windowSize AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left deviceWidth AST#identifier#Right AST#ERROR#Left AST#?#Left ? AST#?#Right AST#:#Left : AST#:#Right AST#number#Left number AST#number#Right AST#ERROR... | windowSize(deviceWidth?: number, deviceHeight?: number): void {
this.componentWidth = deviceWidth as number;
this.componentHeight = deviceHeight as number;
} | https://gitcode.com/HarmonyOS_Samples/sample_in_harmonyos | 7b0f2ac96ff12394c257da2a434d057d1bfa11de | gitcode |
Octo-o-o-o/harmonyos-ai-workspace | tools/hooks/test-fixtures/BadSecurityKit.ets | arkts | loadUsers | DB-001: ResultSet 没 close | async loadUsers(store: relationalStore.RdbStore): Promise<void> {
const rs = await store.getResultSet('SELECT * FROM users');
while (rs.goToNextRow()) {
// ... 处理每一行
}
// 漏了 rs.close()
} | AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left loadUsers AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left store AST#identifier#Right AST#type_annotation#Left AST#:#Left : AST#... | async loadUsers(store: relationalStore.RdbStore): Promise<void> {
const rs = await store.getResultSet('SELECT * FROM users');
while (rs.goToNextRow()) {
// ... 处理每一行
}
// 漏了 rs.close()
} | https://github.com/Octo-o-o-o/harmonyos-ai-workspace | 728c3df6507ff33bbaa58938ffbe27a1721d92ec | github |
Tencent-RTC/TUIKit_Harmony | atomic_x/src/main/ets/basecomponent/language/LanguageState.ets | arkts | unsubscribe | Unsubscribe from layout direction changes | unsubscribe(callback: (direction: LayoutDirection) => void): void {
this.subscribers = this.subscribers.filter(cb => cb !== callback);
} | AST#program#Left AST#ERROR#Left AST#identifier#Left unsubscribe AST#identifier#Right AST#(#Left ( AST#(#Right AST#call_expression#Left AST#identifier#Left callback AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#ERROR#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left ... | unsubscribe(callback: (direction: LayoutDirection) => void): void {
this.subscribers = this.subscribers.filter(cb => cb !== callback);
} | https://github.com/Tencent-RTC/TUIKit_Harmony | 3976e47ae35d7347aa4cfb7cb3f7c909611c9399 | github |
CongDuang/PlayHarmony | html_entities_replace/src/main/ets/HtmEntityReplace.ets | arkts | replace | 替换方法
@param str 原字符串
@returns 处理过的结果字符串 | static replace(str?: string): string | undefined {
if (!str) {
return;
}
return str.replace(/&(\w+);/g, (match: string, entity: string) => {
const res = decodeMap[entity] as string | undefined;
return res || match;
})
} | AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left replace AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left str AST#identifier#Right AST#?#Left ? AST#?#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#... | static replace(str?: string): string | undefined {
if (!str) {
return;
}
return str.replace(/&(\w+);/g, (match: string, entity: string) => {
const res = decodeMap[entity] as string | undefined;
return res || match;
})
} | https://github.com/CongDuang/PlayHarmony/blob/7ccbad93bb99503665f6d6fbe3452a6286327dfa/html_entities_replace/src/main/ets/HtmEntityReplace.ets#L12-L20 | 79940ccda5b9a3036c34fad58802b2d237eaccb9 | github |
openharmony-sig/arkcompiler_runtime_core | plugins/ets/stdlib/std/core/String.ets | arkts | replace | Returns a new string with one, some, or all matches of a pattern replaced by a replacement.
The pattern can be a string or a RegExp, and the replacement can be a string or a function called for each match.
If pattern is a string, only the first occurrence will be replaced. The original string is left unchanged. | public replace(pattern: RegExp, replacement: String) : String {
throw new Error("Not implemented");
} | AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left replace AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left pattern AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#identifier#Left RegExp AST#identifier... | public replace(pattern: RegExp, replacement: String) : String {
throw new Error("Not implemented");
} | https://gitee.com/openharmony-sig/arkcompiler_runtime_core.git | 5f03a0b92ce79d9075d5ab54760e5c50dcb1a490 | gitee |
DaLongZhuaZi/manxia | entry/src/main/ets/Framework/Animation/AnimationSettingsManager.ets | arkts | setBookOpenDuration | 设置书籍打开动画时长 | public async setBookOpenDuration(duration: number): Promise<void> {
// 限制范围: 100ms - 1000ms
const clampedDuration = Math.max(100, Math.min(1000, duration));
if (this.currentSettings.bookOpenDuration === clampedDuration) {
return;
}
this.currentSettings.bookOpenDuration = clampedDuration;
... | 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 setBookOpenDuration AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left duration AST#identifier#Right AST#ERROR#Left AST#:#... | public async setBookOpenDuration(duration: number): Promise<void> {
// 限制范围: 100ms - 1000ms
const clampedDuration = Math.max(100, Math.min(1000, duration));
if (this.currentSettings.bookOpenDuration === clampedDuration) {
return;
}
this.currentSettings.bookOpenDuration = clampedDuration;
... | https://github.com/DaLongZhuaZi/manxia | 91cf694f772a699ec7357f041b03f907fb937e34 | github |
openharmony-sig/aki | example/ohos/11_napi_value/entry/src/main/ets/pages/Index.ets | arkts | build | 获取js的资源对象 | build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.onClick(() => {
let rawfilelist = libraw_file.getFileList(this.resmgr, ""); //传入资源对象,以及访问的rawfile文件夹名称
console.log("[AKI] rawfilelist" + rawfilelist);
... | 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#call_expression#Left AST#member_expression#Left AST... | build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.onClick(() => {
let rawfilelist = libraw_file.getFileList(this.resmgr, ""); //传入资源对象,以及访问的rawfile文件夹名称
console.log("[AKI] rawfilelist" + rawfilelist);
... | https://gitee.com/openharmony-sig/aki.git | 69ddec6b6ee2cb284a881e851b8ebca5996e8f5f | gitee |
iop123123/arkts-static-skills | cli/arkts-static-cli/runtime/ark/es2panda/linux/etc/sdk/api/@arkts.collections.ets | arkts | getIndexOf | Locates the first occurrence of a certain bit value within a range of bits in a bit vector.
@param { int } element - Element to be Located (0 means 0, else means 1).
@param { int } fromIndex - The starting position of the index, containing the value at that index position.
@param { int } toIndex - The end of the index,... | public getIndexOf(element: int, fromIndex: int, toIndex: int): int {
this.checkRange(fromIndex, toIndex);
let fromElem = this.computeElementIdAndBitId(fromIndex);
let toElem = this.computeElementIdAndBitId(toIndex);
if (fromElem.elementId === toElem.elementId) ... | AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left getIndexOf AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left element AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#identifier#Left int AST#identifier... | public getIndexOf(element: int, fromIndex: int, toIndex: int): int {
this.checkRange(fromIndex, toIndex);
let fromElem = this.computeElementIdAndBitId(fromIndex);
let toElem = this.computeElementIdAndBitId(toIndex);
if (fromElem.elementId === toElem.elementId) ... | https://gitcode.com/iop123123/arkts-static-skills | 04bbfe47ebbdeec6b37b64afc694623526da17df | gitcode |
iop123123/arkts-static-skills | cli/arkts-static-cli/runtime/ark/es2panda/linux/etc/sdk/api/@ohos.util.HashMap.ets | arkts | length | Returns number of Entries with unique keys in the HashMap
@returns number of Entries with unique keys in the HashMap | get length(): int {
return this.buckets.size.toInt();
} | AST#program#Left AST#ERROR#Left AST#get#Left get AST#get#Right AST#call_expression#Left AST#identifier#Left length 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#identifier#Right... | get length(): int {
return this.buckets.size.toInt();
} | https://gitcode.com/iop123123/arkts-static-skills | ea337ab13ad8e0a225e84b367d8ec42b5ef16be3 | gitcode |
wuba/omni-ui | omni_component/src/main/ets/components/guide/core/Controller.ets | arkts | _getObservedPageIndex | 私有方法,不建议用户使用:用于Controller控制器通知组件页面index切换
@returns 页面index | public _getObservedPageIndex(): ObservedPageIndex | null {
return this.observedPageIndex;
} | AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left _getObservedPageIndex 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_expressio... | public _getObservedPageIndex(): ObservedPageIndex | null {
return this.observedPageIndex;
} | https://github.com/wuba/omni-ui | d8b794f77e66492ae249c9e5138cc628e5402916 | github |
AetheriumSimulator/qemu-hmos | entry/src/main/ets/utils/RDPAuthManager.ets | arkts | loadCredentials | === 私有方法 ===
从持久化存储加载凭据 | private async loadCredentials(): Promise<void> {
if (!this.preferences) {
return;
}
try {
const all = await this.preferences.getAll();
for (const key in all) {
if (key.startsWith('credential_')) {
try {
const credentialJson = all[key] as string;
... | 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 loadCredentials AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right A... | private async loadCredentials(): Promise<void> {
if (!this.preferences) {
return;
}
try {
const all = await this.preferences.getAll();
for (const key in all) {
if (key.startsWith('credential_')) {
try {
const credentialJson = all[key] as string;
... | https://github.com/AetheriumSimulator/qemu-hmos | fa3bf5ebe09bca564b732a3abb2bf20eb8f2875f | github |
bhengubv/aether-protocol | arkts/src/main/ets/incentive/TipPacketPayload.ets | arkts | readNumber | Reads a numeric field, returning 0 when absent or not a number. | function readNumber(obj: Record<string, ESObject>, key: string): number {
const v: ESObject = obj[key];
return typeof v === 'number' ? v as number : 0;
} | AST#program#Left AST#function_declaration#Left AST#function#Left function AST#function#Right AST#identifier#Left readNumber AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left obj AST#identifier#Right AST#type_annotation#Left AST#:#Left : AST#:#Right ... | function readNumber(obj: Record<string, ESObject>, key: string): number {
const v: ESObject = obj[key];
return typeof v === 'number' ? v as number : 0;
} | https://github.com/bhengubv/aether-protocol | 95da3ed590f73ac5779fffc0cd5e20ae6dd30140 | github |
LJ666-ui/harmony-health-care | entry/src/main/ets/medicalimaging/ImagingTypeClassifier.ets | arkts | classify | 分类影像类型
@param pixelMap 图像
@returns 分类结果 | async classify(pixelMap: image.PixelMap): Promise<ClassificationResult> {
try {
// 提取图像特征
const features = await MedicalImageUtils.extractFeatures(pixelMap);
// 基于特征判断影像类型
const result = this.classifyByFeatures(features);
return result;
} catch (error) {
conso... | AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left classify AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left pixelMap AST#identifier#Right AST#type_annotation#Left AST#:#Left : AS... | async classify(pixelMap: image.PixelMap): Promise<ClassificationResult> {
try {
// 提取图像特征
const features = await MedicalImageUtils.extractFeatures(pixelMap);
// 基于特征判断影像类型
const result = this.classifyByFeatures(features);
return result;
} catch (error) {
conso... | https://github.com/LJ666-ui/harmony-health-care | dc4e1555e47df9e57f0c8395ad38a360496d162d | github |
offlinecat-dev/OCNetORM | src/main/ets/logging/Logger.ets | arkts | logBatchInsert | 记录批量插入日志
仅在 DEBUG 级别记录,包含数据量和耗时
@param tableName 表名
@param totalCount 总数据量
@param insertedCount 成功插入数量
@param duration 执行耗时(毫秒)
@param useTransaction 是否使用事务 | logBatchInsert(tableName: string, totalCount: number, insertedCount: number, duration: number, useTransaction: boolean): void {
// 批量插入日志仅在 DEBUG 级别记录
if (!this.shouldLog(LogLevel.DEBUG)) {
return
}
const transactionInfo = useTransaction ? '事务模式' : '非事务模式'
const content = `表: ${tableName}, 插... | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left logBatchInsert AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left tableName AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string AST#string#Right AST#ERROR#Right AST#,#Left , AST... | logBatchInsert(tableName: string, totalCount: number, insertedCount: number, duration: number, useTransaction: boolean): void {
// 批量插入日志仅在 DEBUG 级别记录
if (!this.shouldLog(LogLevel.DEBUG)) {
return
}
const transactionInfo = useTransaction ? '事务模式' : '非事务模式'
const content = `表: ${tableName}, 插... | https://github.com/offlinecat-dev/OCNetORM | 38fbdc348f721e99243312d2e1293715533ebcbe | github |
iop123123/arkts-static-skills | docs/ArkTS-Language-Guide/08-Stdlib/stdlib-source/std/core/Type.ets | arkts | make | Makes instance of this array with provided length
Each element are instantiated using default value
If element type is class value then empty constructor are called
@param {long} length of array
@throws {Error} error if element type doesn't have default value
@returns {Object} new instance of array
@syscap SystemCapabi... | public make(length: long): Object {
return TypeAPI.makeArrayInstance(this.elemTD, this.getContextLinker(), length)
} | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left public AST#identifier#Right AST#ERROR#Left AST#identifier#Left make AST#identifier#Right AST#ERROR#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left length AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#id... | public make(length: long): Object {
return TypeAPI.makeArrayInstance(this.elemTD, this.getContextLinker(), length)
} | https://gitcode.com/iop123123/arkts-static-skills | 73b24777433af88d11b4d3f919cee8befb113b03 | gitcode |
arkui-x/samples | CodeLab/Cases/feature/componentinstancesharedinpages/src/main/ets/pages/TakeTaxiDetailPage.ets | arkts | changePreferType | 更改PreferType | changePreferType(status: number): void {
if (status === display.FoldStatus.FOLD_STATUS_FOLDED) {
this.isCenter = false;
} else {
this.isCenter = true;
}
} | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left changePreferType AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left status AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left number AST#identifier#Right AST#)#Lef... | changePreferType(status: number): void {
if (status === display.FoldStatus.FOLD_STATUS_FOLDED) {
this.isCenter = false;
} else {
this.isCenter = true;
}
} | https://gitcode.com/arkui-x/samples | d606804736768bc46670b917ec3f776f8f5af314 | gitcode |
DaLongZhuaZi/manxia | entry/src/main/ets/Framework/Novel/NovelLoginManager.ets | arkts | getCookies | 获取书源的Cookie | getCookies(sourceId: string): Record<string, string> {
return this.cookies.get(sourceId) || {};
} | AST#program#Left AST#expression_statement#Left AST#sequence_expression#Left AST#binary_expression#Left AST#call_expression#Left AST#identifier#Left getCookies AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left sourceId AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#st... | getCookies(sourceId: string): Record<string, string> {
return this.cookies.get(sourceId) || {};
} | https://github.com/DaLongZhuaZi/manxia | acf2d744621649ba87dbc80297d458cfa6f80565 | github |
openharmony-sig/ohos_danmaku_flame_master | library/src/main/ets/components/common/master/flame/danmaku/ui/widget/DanmakuView.ets | arkts | hideAndPauseDrawTask | hide the danmakuview and pause the drawtask
@return the paused position
@see #showAndResumeDrawTask | hideAndPauseDrawTask(): number{
return this.delegate.hideAndPauseDrawTask()
} | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left hideAndPauseDrawTask AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Left : AST#:#Right AST#number#Left number AST#number#Right AST#ERROR#Right AST#s... | hideAndPauseDrawTask(): number{
return this.delegate.hideAndPauseDrawTask()
} | https://gitee.com/openharmony-sig/ohos_danmaku_flame_master.git | e2a85e3ce27d3960d5053d090be9d303e32ec095 | gitee |
openharmony-sig/arkcompiler_runtime_core | plugins/ets/stdlib/escompat/TypedUArrays.ets | arkts | internal | Creates a Uint32Array with the same underlying ArrayBuffer
@param begin start index, inclusive
@param end last index, exclusive
@returns new Uint32Array with the same underlying ArrayBuffer
public | /* public */ internal subarray(begin: int, end: int): Uint32Array {
return new Uint32Array(this.buffer, begin * Uint32Array.BYTES_PER_ELEMENT, end - begin)
} | AST#program#Left AST#comment#Left /* public */ AST#comment#Right AST#ERROR#Left AST#identifier#Left internal AST#identifier#Right AST#call_expression#Left AST#identifier#Left subarray AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left begin AST#identifier#Right AST#ERROR#Left AST#:#Lef... | /* public */ internal subarray(begin: int, end: int): Uint32Array {
return new Uint32Array(this.buffer, begin * Uint32Array.BYTES_PER_ELEMENT, end - begin)
} | https://gitee.com/openharmony-sig/arkcompiler_runtime_core.git | 9adb74b224b022472e3334c7e75638cc1c04e5f5 | gitee |
dingzhilin1990/zhilinclaw | examples/WeatherPlugin.ets | arkts | getSkill | 获取插件的技能 | getSkill(): WeatherQuerySkill | undefined {
return this.skill;
} | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left getSkill 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#identifier#Left WeatherQuerySkill AST#iden... | getSkill(): WeatherQuerySkill | undefined {
return this.skill;
} | https://github.com/dingzhilin1990/zhilinclaw | c3fdf35ea7002415be5d2d72321358d2624f392e | github |
DaLongZhuaZi/manxia | entry/src/main/ets/Framework/Cache/CoverCacheManager.ets | arkts | cleanSourceCovers | 清理指定图源的所有封面 | async cleanSourceCovers(sourceId: number): Promise<void> {
try {
if (!await this.ensurePathInitialized()) {
logger.error(TAG, '封面路径未初始化,无法清理封面');
return;
}
// 先确保 pkg 已缓存
const pkg = await this.ensureSourcePkg(sourceId);
// 删除新格式目录(基于 pkg)
if (pkg)... | AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left cleanSourceCovers 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 AST#:#... | async cleanSourceCovers(sourceId: number): Promise<void> {
try {
if (!await this.ensurePathInitialized()) {
logger.error(TAG, '封面路径未初始化,无法清理封面');
return;
}
// 先确保 pkg 已缓存
const pkg = await this.ensureSourcePkg(sourceId);
// 删除新格式目录(基于 pkg)
if (pkg)... | https://github.com/DaLongZhuaZi/manxia | 8d233446c24c99c40eb175a3f9105932dc80b9da | github |
openharmony-tpc/mp4parser | library/src/main/ets/mp4parser/MP4Parser.ets | arkts | audioMerge | Audio synthesis
@param sourcePath
@param outPath
@param callBack | static audioMerge(filePath_one: string, filePath_two: string, outPath: string, callBack: ICallBack) {
let fileCachePathCallBack: IFileCachePathCallBack = {
callBackResult(path: string) {
mp4parser_napi.exeFFmpegCmd("ffmpeg -y -f concat -safe 0 -i " + path + " -c copy " + outPath)
.then((r... | AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left audioMerge AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left filePath_one AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string AST#string... | static audioMerge(filePath_one: string, filePath_two: string, outPath: string, callBack: ICallBack) {
let fileCachePathCallBack: IFileCachePathCallBack = {
callBackResult(path: string) {
mp4parser_napi.exeFFmpegCmd("ffmpeg -y -f concat -safe 0 -i " + path + " -c copy " + outPath)
.then((r... | https://gitee.com/openharmony-tpc/mp4parser.git | f2d9f09a94b63f41ce741b8b5f58d6b8196aa695 | gitee |
CPF-ApplicationTPC/openharmony_tpc_samples | SwipeMenuListView/library/src/main/ets/components/SwipeMenuList.ets | arkts | setCloseCurve | 设置菜单关闭时的自定义动画曲线
@param curve 自定义曲线 | setCloseCurve(curve: curves.ICurve): void {
this.closeAnimationConfig.setCustomCurve(curve);
} | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left setCloseCurve AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left curve AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#member_expression#Left AST#identifier#Left curves AST#ide... | setCloseCurve(curve: curves.ICurve): void {
this.closeAnimationConfig.setCustomCurve(curve);
} | https://gitcode.com/CPF-ApplicationTPC/openharmony_tpc_samples | e602cc889d6ce2a7a4a6128066fe819dd68fe32f | gitcode |
openharmony-sig/arkcompiler_runtime_core | plugins/ets/stdlib/escompat/TypedArrays.ets | arkts | from | Creates an Float32Array from array-like argument
@param o array-like object to initialize Float32Array
@param mapFn function to apply for each
@returns new Float32Array | public from(o: Object, mapFn: (e: Object) => float): Float32Array {
let newF: (e: Object, index: int) => float =
(e: Object, index: int): float => { return mapFn(e) }
return this.from(o, newF)
} | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left public AST#identifier#Right AST#ERROR#Left AST#identifier#Left from AST#identifier#Right AST#ERROR#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left o AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#R... | public from(o: Object, mapFn: (e: Object) => float): Float32Array {
let newF: (e: Object, index: int) => float =
(e: Object, index: int): float => { return mapFn(e) }
return this.from(o, newF)
} | https://gitee.com/openharmony-sig/arkcompiler_runtime_core.git | b675baf90f90f41e7c41188a5488afcf2bfe5422 | gitee |
richshaw2015/nds | ohos/entry/src/test/LayoutBackupProperty.test.ets | arkts | filterLayoutsByTarget | Core filtering logic extracted from LayoutBackupManager.backupFilteredLayout.
The real implementation does: allLayouts.filter(layout => layout.target === target)
We replicate that exact logic here for testability without fileIo. | function filterLayoutsByTarget(allLayouts: LayoutEntry[], target: string): LayoutEntry[] {
return allLayouts.filter(layout => layout.target === target);
} | AST#program#Left AST#function_declaration#Left AST#function#Left function AST#function#Right AST#identifier#Left filterLayoutsByTarget AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left allLayouts AST#identifier#Right AST#type_annotation#Left AST#:#L... | function filterLayoutsByTarget(allLayouts: LayoutEntry[], target: string): LayoutEntry[] {
return allLayouts.filter(layout => layout.target === target);
} | https://github.com/richshaw2015/nds | da9b297fefb1215940f7fba3c130e5f63a72c781 | github |
Nekofox-POT/LinMusic | entry/src/main/ets/建筑垃圾堆/class_audio_ffmpeg_player.ets | arkts | set_play_list | 设置播放列表(初始化) // | async set_play_list(list: string[], index: number) {
// 设置
this.play_list = list
this.play_list_index = index
// 广播列表
emitter.emit({ eventId: 718 }, { data: { list: this.play_list, index: this.play_list_index } })
// 初始化(播放)
await this.set_audio_play()
} | AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left set_play_list AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left list AST#identifier#Right AST#type_annotation#Left AST#:#Left : A... | async set_play_list(list: string[], index: number) {
// 设置
this.play_list = list
this.play_list_index = index
// 广播列表
emitter.emit({ eventId: 718 }, { data: { list: this.play_list, index: this.play_list_index } })
// 初始化(播放)
await this.set_audio_play()
} | https://github.com/Nekofox-POT/LinMusic | c16441ac6ab5f83d7074fc211b0a7b6fdc673e80 | github |
RoooyHe/toona-ohos | toona/src/main/ets/network/clients/DeviceHttpClient.ets | arkts | queryKeys | ==========================================
2. 端到端加密 & 密钥备份模块 (✅ 恢复被误删的方法)
========================================== | async queryKeys(request: Record<string, Object>): Promise<Record<string, Object>> {
return await this.post<Record<string, Object>>('/keys/query', request as Record<string, string | object>);
} | AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left queryKeys AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left request AST#identifier#Right AST#type_annotation#Left AST#:#Left : AS... | async queryKeys(request: Record<string, Object>): Promise<Record<string, Object>> {
return await this.post<Record<string, Object>>('/keys/query', request as Record<string, string | object>);
} | https://github.com/RoooyHe/toona-ohos | d10962deaffd848cb3ded913f277f3a32d3b1144 | github |
LongLiveY96/chatcube | entry/src/main/ets/utils/LunarCalendarUtils.ets | arkts | getLeapMonthDays | 获取某年闰月的天数(0表示无闰月) | function getLeapMonthDays(year: number): number {
if (getLeapMonth(year) === 0) {
return 0
}
const index = year - 1900
if (index < 0 || index >= LUNAR_INFO.length) {
return 0
}
return (LUNAR_INFO[index] & 0x10000) !== 0 ? 30 : 29
} | AST#program#Left AST#function_declaration#Left AST#function#Left function AST#function#Right AST#identifier#Left getLeapMonthDays AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left year AST#identifier#Right AST#type_annotation#Left AST#:#Left : AST#:... | function getLeapMonthDays(year: number): number {
if (getLeapMonth(year) === 0) {
return 0
}
const index = year - 1900
if (index < 0 || index >= LUNAR_INFO.length) {
return 0
}
return (LUNAR_INFO[index] & 0x10000) !== 0 ? 30 : 29
} | https://github.com/LongLiveY96/chatcube | 4c2e906756e2b5263c416bb1bbe9d6a595b2c2da | github |
openharmony/applications_permission_manager | permissionmanager/src/main/ets/GlobalExtAbility/GlobalDialogModel.ets | arkts | cameraStatus | 判断相机全局状态
@param context ServiceExtensionContext
return boolean | private cameraStatus(context: Context): boolean {
try {
let cameraManager = camera.getCameraManager(context);
let isMuteSupported = cameraManager.isCameraMuteSupported();
if (!isMuteSupported) {
Log.info('The current device does not support disabling the camera.');
return false;
... | AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left cameraStatus AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left context AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Le... | private cameraStatus(context: Context): boolean {
try {
let cameraManager = camera.getCameraManager(context);
let isMuteSupported = cameraManager.isCameraMuteSupported();
if (!isMuteSupported) {
Log.info('The current device does not support disabling the camera.');
return false;
... | https://gitee.com/openharmony/applications_permission_manager.git | 001e6359b731c0db56fda2bcdbd04c7f6f5e1c1b | gitee |
iop123123/arkts-static-skills | docs/ArkTS-Language-Guide/08-Stdlib/stdlib-source/std/core/TypedArrays.ets | arkts | of | Returns a new array from a set of elements.
@param { FixedArray<bigint> } items - a set of elements to include in the new array object.
@returns { BigInt64Array } - a new BigInt64Array
@static
@syscap SystemCapability.Utils.Lang
@FaAndStageModel | public static of(...items: FixedArray<bigint>): BigInt64Array {
let res = new BigInt64Array(items.length.toInt())
res.ofBigInt(items)
return res
} | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left public AST#identifier#Right AST#ERROR#Left AST#identifier#Left static AST#identifier#Right AST#of#Left of AST#of#Right AST#ERROR#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#spread_element#Left AST#...#Left ... AST#...#Right AST#ERROR... | public static of(...items: FixedArray<bigint>): BigInt64Array {
let res = new BigInt64Array(items.length.toInt())
res.ofBigInt(items)
return res
} | https://gitcode.com/iop123123/arkts-static-skills | bafa31d68803ed012ab043cefbd77638241a63ea | gitcode |
arkui-x/samples | CodeLab/Cases/feature/h5cache/src/main/ets/common/OfflineResourceManager.ets | arkts | fetchFromCache | 从内存缓存、磁盘缓存和离线包中取回数据,按照内存缓存、磁盘缓存、离线包顺序依次查找
如果是文本类型资源,需要将数据转化为字符串后返回
@param url 资源请求url
@param data 请求的数据类型,js、png、css、json等 | fetchFromCache(url: string, type: string): null | ResponseDataType {
// 防止url过长或者包含非法字符导致意外错误,需要使用算法进行转化,这里使用md5算法
let key = transferUrlToKey(url);
// 按照内存缓存、磁盘缓存、离线包顺序依次查找资源
let res = this.memoryCacheManager.fetchFromMemory(key);
if (!res) {
res = this.diskCacheManager.fetchFromDisk(key);
... | AST#program#Left AST#expression_statement#Left AST#binary_expression#Left AST#call_expression#Left AST#identifier#Left fetchFromCache 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#ERROR#Right AST#identifier#Left ... | fetchFromCache(url: string, type: string): null | ResponseDataType {
// 防止url过长或者包含非法字符导致意外错误,需要使用算法进行转化,这里使用md5算法
let key = transferUrlToKey(url);
// 按照内存缓存、磁盘缓存、离线包顺序依次查找资源
let res = this.memoryCacheManager.fetchFromMemory(key);
if (!res) {
res = this.diskCacheManager.fetchFromDisk(key);
... | https://gitcode.com/arkui-x/samples | f399d0a1a3b70c1e128623b7f9b121902a04817f | gitcode |
openharmony-sig/flutter_packages | packages/webview_flutter/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/ViewFlutterApiImpl.ets | arkts | setApi | Sets the Flutter API used to send messages to Dart.
<p>This is only visible for testing. | setApi(api: ViewFlutterApi) {
this.api = api;
} | AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left setApi AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left api AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left ViewFlutterApi AST#identifier#Right... | setApi(api: ViewFlutterApi) {
this.api = api;
} | https://gitee.com/openharmony-sig/flutter_packages.git | 76ffdbfe003243af132c12102ba0fe18ed20a46a | gitee |
tdcare/tdwebrtc | example/MediaStreamAdvancedExample.ets | arkts | initialize | 初始化并检测设备能力 | public async initialize(): Promise<boolean> {
try {
// 1. 检测编解码器能力
this.codecCapabilities = detectVideoCodecCapabilities();
console.log('[MediaStreamExample] 编解码器能力:');
console.log(` 硬件编码: ${this.codecCapabilities.hwEncode.join(', ')}`);
console.log(` 硬件解码: ${this.codecCapabilities... | 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 initialize AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Lef... | public async initialize(): Promise<boolean> {
try {
// 1. 检测编解码器能力
this.codecCapabilities = detectVideoCodecCapabilities();
console.log('[MediaStreamExample] 编解码器能力:');
console.log(` 硬件编码: ${this.codecCapabilities.hwEncode.join(', ')}`);
console.log(` 硬件解码: ${this.codecCapabilities... | https://github.com/tdcare/tdwebrtc | 3e0a511963870797759e15e122bb68c48867cb7e | github |
TDCQCX/ShiHuaMusic-Harmony | entry/src/main/ets/utils/HttpUtil.ets | arkts | buildFullUrl | 构建完整URL
@param url 相对URL
@param params 查询参数 | private static buildFullUrl(url: string, params?: Record<string, string | number>): string {
let fullUrl: string = `${HttpUtil.baseUrl}${url}`;
if (params) {
const queryString = Object.keys(params)
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(params[key] as string)}`)
... | 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 buildFullUrl AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left url AST#identifier#Right AST#:#Left : A... | private static buildFullUrl(url: string, params?: Record<string, string | number>): string {
let fullUrl: string = `${HttpUtil.baseUrl}${url}`;
if (params) {
const queryString = Object.keys(params)
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(params[key] as string)}`)
... | https://github.com/TDCQCX/ShiHuaMusic-Harmony | 33f5fade7d0132bfc544831ea53cb079bd9ef72e | github |
iop123123/arkts-static-skills | docs/ArkTS-Language-Guide/08-Stdlib/stdlib-source/std/core/TypedUArrays.ets | arkts | constructor | Creates an Uint8ClampedArray from FixedArray<number>
@param { FixedArray<number> } numbers - data initializer
@syscap SystemCapability.Utils.Lang
@FaAndStageModel | public constructor(numbers: FixedArray<number>) {
this(numbers.length)
for (let i: int = 0; i < this.lengthInt; ++i) {
this.setUnsafeClamp(i, Uint8ClampedArray.toUint8Clamped(numbers[i]))
}
} | AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left constructor AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left numbers AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#instantiation_exp... | public constructor(numbers: FixedArray<number>) {
this(numbers.length)
for (let i: int = 0; i < this.lengthInt; ++i) {
this.setUnsafeClamp(i, Uint8ClampedArray.toUint8Clamped(numbers[i]))
}
} | https://gitcode.com/iop123123/arkts-static-skills | 8c31e9b3c686ca8ebe32c32e393429d25b01a83a | gitcode |
openharmony-tpc/ohos_mpchart | library/src/main/ets/components/listener/EventControl.ets | arkts | eventIsEnable | 事件是否启用 | public eventIsEnable(evType: EventType) {
return this.eventMap.get(evType);
} | AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left eventIsEnable AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left evType AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left ... | public eventIsEnable(evType: EventType) {
return this.eventMap.get(evType);
} | https://gitee.com/openharmony-tpc/ohos_mpchart.git | 65942f3197f5844675b38d0c1b2d51b883b7e2d6 | gitee |
richshaw2015/nds | ohos/entry/src/main/ets/utils/NdsRomCache.ets | arkts | freeCacheSpace | 释放指定大小的缓存空间
使用 LRU 策略,优先删除最久未使用的文件
@param sizeToFree 需要释放的空间大小 | private freeCacheSpace(sizeToFree: SizeUnit): void {
const cacheDir = this.getCacheDir();
if (!cacheDir) {
return;
}
// 获取所有缓存文件,按最后修改时间排序(最旧的在前)
const files = this.listFiles(cacheDir);
files.sort((a, b) => a.lastModified - b.lastModified);
let freedBytes = SizeUnit.bytes(0);
... | AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left freeCacheSpace AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left sizeToFree AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#identifier#Left SizeUnit... | private freeCacheSpace(sizeToFree: SizeUnit): void {
const cacheDir = this.getCacheDir();
if (!cacheDir) {
return;
}
// 获取所有缓存文件,按最后修改时间排序(最旧的在前)
const files = this.listFiles(cacheDir);
files.sort((a, b) => a.lastModified - b.lastModified);
let freedBytes = SizeUnit.bytes(0);
... | https://github.com/richshaw2015/nds | c49df6676fc9e7fb85558f9bcd3e6b1db201068b | github |
LJ666-ui/harmony-health-care | entry/src/main/ets/ar/PathPlanner.ets | arkts | startNavigation | ==================== 历史记录管理 ====================
开始导航(添加到历史记录)
@path 导航路径
@destinationName 目的地名称 | public startNavigation(path: NavigationPath, destinationName: string): string {
const historyItem: NavigationHistory = {
id: `HIST_${Date.now()}`,
destinationId: `DEST_${Date.now()}`,
destinationName,
startTime: Date.now(),
endTime: 0,
duration: 0,
distance: path.totalDis... | AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left startNavigation AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left path AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left ... | public startNavigation(path: NavigationPath, destinationName: string): string {
const historyItem: NavigationHistory = {
id: `HIST_${Date.now()}`,
destinationId: `DEST_${Date.now()}`,
destinationName,
startTime: Date.now(),
endTime: 0,
duration: 0,
distance: path.totalDis... | https://github.com/LJ666-ui/harmony-health-care | bb75f1379c26b26903ae469298ffb92515b45271 | github |
openharmony/codelabs | ETSUI/LifeTrack/entry/src/main/ets/pages/StepManager.ets | arkts | getRecentStepRecords | 获取最近的步数记录 | async getRecentStepRecords(limit: number = 7): Promise<StepResult> {
try {
const records = await this.stepDao.getRecentStepRecords(limit);
return { success: true, data: records };
} catch (error) {
console.error('Get recent step records failed:', error);
return {
success: fal... | AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left getRecentStepRecords AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Left limit AST#identifier#Right AST#type_annotation#Left AST#:#... | async getRecentStepRecords(limit: number = 7): Promise<StepResult> {
try {
const records = await this.stepDao.getRecentStepRecords(limit);
return { success: true, data: records };
} catch (error) {
console.error('Get recent step records failed:', error);
return {
success: fal... | https://gitcode.com/openharmony/codelabs | 7a97500884a9ff55c45340b3e7922e84e81338f3 | gitcode |
offlinecat-dev/OCNetORM | src/main/ets/repository/TransactionOptions.ets | arkts | withTimeout | 创建带超时的事务选项
@param timeout 超时时间(毫秒)
@returns 带超时的事务选项 | static withTimeout(timeout: number): TransactionOptions {
const options = new TransactionOptions()
options.timeout = timeout
return options
} | AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left withTimeout 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#Rig... | static withTimeout(timeout: number): TransactionOptions {
const options = new TransactionOptions()
options.timeout = timeout
return options
} | https://github.com/offlinecat-dev/OCNetORM | 9dd3ab95e8b8873ae8d1555d2949d8d72a8015f2 | github |
wuba/omni-ui | omni_component/src/main/ets/components/popup/BasePopup.ets | arkts | popupMaxHeight | 弹窗最大高度
@returns | popupMaxHeight(): Length | undefined {
return undefined
} | AST#program#Left AST#expression_statement#Left AST#binary_expression#Left AST#call_expression#Left AST#identifier#Left popupMaxHeight AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#identi... | popupMaxHeight(): Length | undefined {
return undefined
} | https://github.com/wuba/omni-ui | 24895250421671d01d2e04dd8687df873bcfc9bd | github |
openharmony-sig/online_event | solution_student_challenge/基于OpenHarmony的OpenGit_潘骏翔/OpenGit/entry/src/main/ets/MainAbility/pages/common/component/LableItem.ets | arkts | build | 该标签的内容 | build() {
Text(this.label)
.fontSize(12)
.backgroundColor($r("app.color.tsp_fill_weak"))
.margin({ left: 4, right: 4 })
.padding({ left: 4, right: 4, top: 2, bottom: 2 })
.borderRadius(6)
} | 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() {
Text(this.label)
.fontSize(12)
.backgroundColor($r("app.color.tsp_fill_weak"))
.margin({ left: 4, right: 4 })
.padding({ left: 4, right: 4, top: 2, bottom: 2 })
.borderRadius(6)
} | https://gitee.com/openharmony-sig/online_event.git | fdae69c57a2a29e3cce60bd1e9282d279d8275e6 | gitee |
openharmony/applications_settings | product/phone/src/main/ets/pages/dateAndTime.ets | arkts | onAccept | Successfully built Dialog | onAccept() {
LogUtil.info(MODULE_TAG + 'onAccept');
} | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left onAccept 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 AS... | onAccept() {
LogUtil.info(MODULE_TAG + 'onAccept');
} | https://gitee.com/openharmony/applications_settings.git | 73e2b43fd174f6222b59082711425101e197d89e | gitee |
openharmony-sig/shimmer-ohos | library/src/main/ets/components/MainPage/Shimmer.ets | arkts | setDropoff | Sets how quickly the shimmer's gradient drops-off. A larger value causes a sharper drop-off. | setDropoff(dropoff: number): Shimmer {
if (dropoff < 0) {
throw new Error("Given invalid dropoff value: " + dropoff);
}
this.dropoff = dropoff;
return this
} | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left setDropoff AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left dropoff AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#number#Left number AST#number#Right AST#ERROR#Right AST#)#Left ) AST#)#Rig... | setDropoff(dropoff: number): Shimmer {
if (dropoff < 0) {
throw new Error("Given invalid dropoff value: " + dropoff);
}
this.dropoff = dropoff;
return this
} | https://gitee.com/openharmony-sig/shimmer-ohos.git | b7e5a9408343c30c64a7700ef324214a3346fef4 | gitee |
the-wwyang/kids-learning-app | src/main/ets/storage/UserSettingsStorageService.ets | arkts | saveSettings | 保存用户设置
@param settings 用户设置对象 | static async saveSettings(settings: UserSettings): Promise<void> {
try {
await dataStorage.saveObject(
UserSettingsStorageService.STORE_NAME,
UserSettingsStorageService.KEY_SETTINGS,
settings
);
// 记录修改时间
await dataStorage.saveString(
UserSettingsStorageSer... | 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 saveSettings AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left settings AST#identifier#Right AST#:#Left : ... | static async saveSettings(settings: UserSettings): Promise<void> {
try {
await dataStorage.saveObject(
UserSettingsStorageService.STORE_NAME,
UserSettingsStorageService.KEY_SETTINGS,
settings
);
// 记录修改时间
await dataStorage.saveString(
UserSettingsStorageSer... | https://github.com/the-wwyang/kids-learning-app | ae01b595b3339043d9926161090da7a9d07903f2 | github |
openharmony/arkcompiler_taihe_ffi_gen | test/ani_overload/user/main.ets | arkts | test_enum | 测试传入 enum 类型 | function test_enum() {
let color = test_overload.Color.red;
let instance: test_overload.OverloadInterface =
test_overload.get_interface();
let res = instance.overloadFunc(color);
arktest.assertEQ(res, (1).toInt());
} | AST#program#Left AST#function_declaration#Left AST#function#Left function AST#function#Right AST#identifier#Left test_enum AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#formal_parameters#Right AST#statement_block#Left AST#{#Left { AST#{#Right AST#lexical_declarati... | function test_enum() {
let color = test_overload.Color.red;
let instance: test_overload.OverloadInterface =
test_overload.get_interface();
let res = instance.overloadFunc(color);
arktest.assertEQ(res, (1).toInt());
} | https://gitcode.com/openharmony/arkcompiler_taihe_ffi_gen | cce2b5f7e971ed2502dec30b13590fb4610eb14c | gitcode |
openharmony-sig/applications_clock | common/src/main/ets/manager/TimerManager.ets | arkts | stopAlarm | 停止闹钟计时 | async stopAlarm(): Promise<void> {
const timerId = await this.getTimerId();
if (!timerId || timerId === NO_TIMER) {
return;
}
try {
const preferences = await this.getPreferences();
await preferences.delete(ALARM_CLOCK_TRIGGER_TIME);
await preferences.delete(ALARM_CLOCK_TRIGGER_... | AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left stopAlarm AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#formal_parameters#Right AST#type_annotation#Left AST#:#Left : AST#:#Right AST#generic_ty... | async stopAlarm(): Promise<void> {
const timerId = await this.getTimerId();
if (!timerId || timerId === NO_TIMER) {
return;
}
try {
const preferences = await this.getPreferences();
await preferences.delete(ALARM_CLOCK_TRIGGER_TIME);
await preferences.delete(ALARM_CLOCK_TRIGGER_... | https://gitee.com/openharmony-sig/applications_clock.git | 3b194f18288e4fb55a16745fd2ee64d1f05248b4 | gitee |
arkui-x/samples | CodeLab/Cases/feature/addressrecognize/src/main/ets/view/AddressRecognize.ets | arkts | resetIsDefault | 重置默认地址 | resetIsDefault() {
const addressList: Address[] = [];
this.myAddressList.forEach((address: Address) => {
if (address.defaultFlag) {
address.defaultFlag = false;
}
addressList.push(address);
});
this.myAddressList = addressList;
} | AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left resetIsDefault 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#Lef... | resetIsDefault() {
const addressList: Address[] = [];
this.myAddressList.forEach((address: Address) => {
if (address.defaultFlag) {
address.defaultFlag = false;
}
addressList.push(address);
});
this.myAddressList = addressList;
} | https://gitcode.com/arkui-x/samples | ff81677f1d9e971b17953cfa2bf02952cb13fce1 | gitcode |
LongLiveY96/chatcube | entry/src/main/ets/services/IconDownloadCache.ets | arkts | rebuildIndex | 启动时扫描缓存目录重建内存索引 | private rebuildIndex(): void {
try {
const entries = fileIo.listFileSync(this.cacheDir)
for (let i = 0; i < entries.length; i++) {
const fileName = entries[i]
if (fileName.endsWith('.png')) {
const filePath = `${this.cacheDir}/${fileName}`
// 文件名格式: {hash}.png,对应的 u... | AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left rebuildIndex 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#voi... | private rebuildIndex(): void {
try {
const entries = fileIo.listFileSync(this.cacheDir)
for (let i = 0; i < entries.length; i++) {
const fileName = entries[i]
if (fileName.endsWith('.png')) {
const filePath = `${this.cacheDir}/${fileName}`
// 文件名格式: {hash}.png,对应的 u... | https://github.com/LongLiveY96/chatcube | 54c8f82dc9cc4010e65b93cc0a202fb981cd8f1c | github |
dingzhilin1990/zhilinclaw | src/core/ZhiLinClawCore.ets | arkts | getEventBus | 获取事件总线实例 | public getEventBus(): EventBus {
return this.eventBus;
} | AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left getEventBus 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 EventBus A... | public getEventBus(): EventBus {
return this.eventBus;
} | https://github.com/dingzhilin1990/zhilinclaw | 2b01cffea94d19835e364c9df0d5a9f2f194cc19 | github |
offlinecat-dev/OCNetORM | src/main/ets/repository/BatchInsertOptions.ets | arkts | constructor | 构造函数
@param useTransaction 是否使用事务,默认为 true
@param executeHooks 是否执行钩子,默认为 true
@param executeValidation 是否执行数据验证,默认为 true | constructor(
useTransaction: boolean = true,
executeHooks: boolean = true,
executeValidation: boolean = true
) {
this.useTransaction = useTransaction
this.executeHooks = executeHooks
this.executeValidation = executeValidation
} | 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 useTransaction AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#assignment_expression#Left AST#iden... | constructor(
useTransaction: boolean = true,
executeHooks: boolean = true,
executeValidation: boolean = true
) {
this.useTransaction = useTransaction
this.executeHooks = executeHooks
this.executeValidation = executeValidation
} | https://github.com/offlinecat-dev/OCNetORM | 07ade228058c2bdc2bb6172901934ba277b7e361 | github |
openharmony/applications_call | entry/src/main/ets/common/utils/utils.ets | arkts | formatTime | format time
@param { number } count | public formatTime(count) {
const second = Math.floor((count % MIN_VAL) / SEC_VAL);
const minute = Math.floor((count / MIN_VAL) % SIXTY_SECONDS);
const hour = Math.floor(count / (SIXTY_SECONDS * MIN_VAL));
const secondStr = second <= NINE_MAX ? '0' + second : second;
const minuteStr = minute <= NIN... | AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left formatTime AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left count AST#identifier#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#ERROR... | public formatTime(count) {
const second = Math.floor((count % MIN_VAL) / SEC_VAL);
const minute = Math.floor((count / MIN_VAL) % SIXTY_SECONDS);
const hour = Math.floor(count / (SIXTY_SECONDS * MIN_VAL));
const secondStr = second <= NINE_MAX ? '0' + second : second;
const minuteStr = minute <= NIN... | https://gitee.com/openharmony/applications_call.git | 29f75a940428c652472f8ce17e56d963f79e477a | gitee |
openharmony/distributedhardware_distributed_hardware_fwk | application/entry/src/main/ets/utils/DeviceUtil.ets | arkts | getFoldProductType | 获取代表产品形态的配置项值
@returns FoldPhoneTypeValue | private static getFoldProductType(): number {
logger.info(`${TAG} getFoldProductType in.`);
if (DeviceUtil.foldProductTypeValue !== FoldPhoneTypeValue.INVALID_VALUE) {
return DeviceUtil.foldProductTypeValue;
}
try {
let productValue: string = systemParameterEnhance.getSync('const.window.fo... | 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 getFoldProductType AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Rig... | private static getFoldProductType(): number {
logger.info(`${TAG} getFoldProductType in.`);
if (DeviceUtil.foldProductTypeValue !== FoldPhoneTypeValue.INVALID_VALUE) {
return DeviceUtil.foldProductTypeValue;
}
try {
let productValue: string = systemParameterEnhance.getSync('const.window.fo... | https://gitee.com/openharmony/distributedhardware_distributed_hardware_fwk.git | 6cd69c39a72a11b2f846920f02895ebb1a831c76 | gitee |
CLMC2025/Vignette | entry/src/main/ets/context/ContextValidator.ets | arkts | validateLength | 验证长度有效性 | private validateLength(context: string, minWords: number, maxWords: number, result: ValidationResult): void {
const wordCount = this.countWords(context);
if (minWords > 0 && wordCount < minWords) {
result.addIssue(new ValidationIssue(
ValidationIssueType.LENGTH_INVALID,
IssueSeverity.ERR... | AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left validateLength AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left context AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string AST#stri... | private validateLength(context: string, minWords: number, maxWords: number, result: ValidationResult): void {
const wordCount = this.countWords(context);
if (minWords > 0 && wordCount < minWords) {
result.addIssue(new ValidationIssue(
ValidationIssueType.LENGTH_INVALID,
IssueSeverity.ERR... | https://github.com/CLMC2025/Vignette | b481bd3c29bf65f01f35952c11c848784ec05e8c | github |
openharmony-sig/commons-cli | library/src/main/ets/components/cli/Options.ets | arkts | getOptionGroup | Gets the OptionGroup the {@code opt} belongs to.
@param opt the option whose OptionGroup is being queried.
@return the OptionGroup if {@code opt} is part of an OptionGroup, otherwise return null | public getOptionGroup(opt: CliOption): OptionGroup{
return this.optionGroups.get(opt.getKey()) == null ? new OptionGroup() : this.optionGroups.get(opt.getKey()) as OptionGroup;
} | AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left getOptionGroup AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left opt AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left Cl... | public getOptionGroup(opt: CliOption): OptionGroup{
return this.optionGroups.get(opt.getKey()) == null ? new OptionGroup() : this.optionGroups.get(opt.getKey()) as OptionGroup;
} | https://gitee.com/openharmony-sig/commons-cli.git | 702401030ed07ded426ef639fde687b55ccd9573 | gitee |
aimilin6688/KeePassHO | entry/src/main/ets/common/utils/CommonUtils.ets | arkts | base64Encode | base64编码
@param str
@returns | public static base64Encode(str: string): string {
const base64 = new util.Base64Helper();
const encoder = new util.TextEncoder()
return base64.encodeToStringSync(encoder.encodeInto(str));
} | 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 base64Encode AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left str AST#identifier#Right AST#:#Left : AST#... | public static base64Encode(str: string): string {
const base64 = new util.Base64Helper();
const encoder = new util.TextEncoder()
return base64.encodeToStringSync(encoder.encodeInto(str));
} | https://github.com/aimilin6688/KeePassHO/blob/6ac299504782abfed903b23a13c736b0841388d9/entry/src/main/ets/common/utils/CommonUtils.ets#L39-L43 | f98d804ec6aeb8b38f0a7c0e674e5513961cb8db | github |
honjow/Next2V | shared/src/main/ets/settings/IgnoredNodesSettings.ets | arkts | current | The live ignored-node list, read from the V2 mirror apply() keeps in lockstep with the persisted key. | static current(): string[] {
return connectIgnoredNodes().names
} | AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left current 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 string AST#ide... | static current(): string[] {
return connectIgnoredNodes().names
} | https://github.com/honjow/Next2V | 1f59819bf1374d960f6115e2a65a675d546f812d | github |
Countly/countly-sdk-hos | library/src/main/ets/internal/ModuleBase.ets | arkts | onDeviceIdChangedNotMerged | Called on device ID change without merge, module state should be reset. | public onDeviceIdChangedNotMerged(oldId: string, newId: string): Promise<void> {
return Promise.resolve();
} | AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left onDeviceIdChangedNotMerged AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left oldId AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#iden... | public onDeviceIdChangedNotMerged(oldId: string, newId: string): Promise<void> {
return Promise.resolve();
} | https://github.com/Countly/countly-sdk-hos | e03df249946014e88fe0410de1b0e32f1f06de2e | github |
CPF-ApplicationTPC/openharmony_tpc_samples | OhosVideoCache/library/src/main/ets/HttpUrlSource.ets | arkts | destroy | 销毁连接并释放资源
外部可以调用此方法来主动关闭 HTTP 请求连接 | public destroy(): void {
const that = this;
new Promise<void>((resolve, reject) => {
const eventEmitId = `${that.serverHashId}_${VideoCacheConstant.HTTPURLSOURCE_DESTROY}`;
let eventData: emitter.EventData = {
data: {
"url": that.url
}
};
emitter.emit(eventEmi... | AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left destroy 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 ... | public destroy(): void {
const that = this;
new Promise<void>((resolve, reject) => {
const eventEmitId = `${that.serverHashId}_${VideoCacheConstant.HTTPURLSOURCE_DESTROY}`;
let eventData: emitter.EventData = {
data: {
"url": that.url
}
};
emitter.emit(eventEmi... | https://gitcode.com/CPF-ApplicationTPC/openharmony_tpc_samples | 6bf89f657e7ff56794a6d3398e60bd05748e1cb4 | gitcode |
HarmonyOS_Samples/BestPracticeSnippets | UseSendable/entry/src/main/ets/pages/ConcurrentTaskManagement5.ets | arkts | concurrentTask | [EndExclude quick_start] | @Concurrent
function concurrentTask(num: number): number {
hilog.info(0x0000, 'TAG', '%{public}s', 'Add the task that needs to be executed with delay');
return num;
} | AST#program#Left AST#function_declaration#Left AST#decorator#Left AST#@#Left @ AST#@#Right AST#identifier#Left Concurrent AST#identifier#Right AST#decorator#Right AST#function#Left function AST#function#Right AST#identifier#Left concurrentTask AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST... | @Concurrent
function concurrentTask(num: number): number {
hilog.info(0x0000, 'TAG', '%{public}s', 'Add the task that needs to be executed with delay');
return num;
} | https://gitcode.com/HarmonyOS_Samples/BestPracticeSnippets | 43a88355647ef343dd972d4a66a1a447df3f1f38 | gitcode |
arkui-x/samples | CodeLab/Cases/feature/customscan/src/main/ets/viewmodel/CustomScanViewModel.ets | arkts | detectFromPhotoPicker | 打开系统相册,选择照片进行二维码识别
@returns {string} | async detectFromPhotoPicker(): Promise<string> {
const photoSelectOptions = new photoAccessHelper.PhotoSelectOptions();
photoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE;
photoSelectOptions.maxSelectNumber = 1;
const photoViewPicker = new photoAccessHelper.PhotoViewPicker()... | AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left detectFromPhotoPicker AST#identifier#Right AST#ERROR#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#formal_parameters#Right AST#type_annotation#Left AST#:#Left : AST#:#Right AS... | async detectFromPhotoPicker(): Promise<string> {
const photoSelectOptions = new photoAccessHelper.PhotoSelectOptions();
photoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE;
photoSelectOptions.maxSelectNumber = 1;
const photoViewPicker = new photoAccessHelper.PhotoViewPicker()... | https://gitcode.com/arkui-x/samples | db944ddafbfc58804d8fa8f56037ee77da044907 | gitcode |
offlinecat-dev/OCNetORM | src/main/ets/database/DatabaseManager.ets | arkts | getInstance | 获取单例实例
@returns DatabaseManager 实例 | static getInstance(): DatabaseManager {
return DatabaseManager.instance
} | AST#program#Left AST#ERROR#Left AST#static#Left static AST#static#Right AST#call_expression#Left AST#identifier#Left getInstance 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 DatabaseMa... | static getInstance(): DatabaseManager {
return DatabaseManager.instance
} | https://github.com/offlinecat-dev/OCNetORM | 4e329da0ca9f213af95994ea901240572231f5a8 | github |
YANGZX22/Voot | entry/src/main/ets/storage/OnboardingStorage.ets | arkts | markCompleted | 标记整个引导流程完成(协议确认 + 配置引导)
@param ctx UI Ability Context | static async markCompleted(ctx: common.UIAbilityContext): Promise<void> {
const prefs = await OnboardingStorage.getPrefs(ctx);
await prefs.put(OnboardingStorage.KEY_COMPLETED, true);
await prefs.put(OnboardingStorage.KEY_SETUP_COMPLETED, true);
await prefs.flush();
} | 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 markCompleted AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left ctx AST#identifier#Right AST#:#Left : AST#... | static async markCompleted(ctx: common.UIAbilityContext): Promise<void> {
const prefs = await OnboardingStorage.getPrefs(ctx);
await prefs.put(OnboardingStorage.KEY_COMPLETED, true);
await prefs.put(OnboardingStorage.KEY_SETUP_COMPLETED, true);
await prefs.flush();
} | https://github.com/YANGZX22/Voot | 244da2d5483a7a2f044eef2daf6e460dbfaaae6e | github |
xiaofenger_705/protobuf-arkts-generator | runtime/arkpb/JsonEncodingVisitor.ets | arkts | visitMapInt32String | 访问 map<int32, string> 字段
JSON: object with string keys | visitMapInt32String(value: Map<number, string>, fieldNumber: number): void {
const fieldName = this.getFieldName(fieldNumber)
const obj: Record<string, Object> = {}
value.forEach((v, k) => {
obj[k.toString()] = v as Object
})
this.json[fieldName] = obj as Object
} | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left visitMapInt32String AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#instantiation_expression#Left AST#identifier#Left value AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#identifier#Left Map AST#identifie... | visitMapInt32String(value: Map<number, string>, fieldNumber: number): void {
const fieldName = this.getFieldName(fieldNumber)
const obj: Record<string, Object> = {}
value.forEach((v, k) => {
obj[k.toString()] = v as Object
})
this.json[fieldName] = obj as Object
} | https://gitcode.com/xiaofenger_705/protobuf-arkts-generator | b8ebd3e3c11ef35d551c949daac35ac002b89a79 | gitcode |
HarmonyOS_Samples/MusicHome | common/musicbasic/src/main/ets/model/SongDataSource.ets | arkts | pushData | Appends a song and notifies listeners of an add at the new tail index.
@param data Song to append. | public pushData(data: SongItem): void {
this.dataArray.push(data);
this.notifyDataAdd(this.dataArray.length - 1);
} | AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left pushData 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#Left SongIte... | public pushData(data: SongItem): void {
this.dataArray.push(data);
this.notifyDataAdd(this.dataArray.length - 1);
} | https://gitcode.com/HarmonyOS_Samples/MusicHome | e255549714a265f25f3eece74629dd554f65a537 | gitcode |
honjow/Next2V | shared/src/main/ets/network/HttpClient.ets | arkts | getTextResponseWithHeaders | GET request for plain text and response headers (for Cookie private-page detection / 2FA redirect) | async getTextResponseWithHeaders(endpoint: string, headers: Record<string, string>): Promise<TextResponseWithHeaders> {
return this.requestTextResponse(endpoint, http.RequestMethod.GET, MAX_RETRIES, headers)
} | AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#member_expression#Left AST#identifier#Left async AST#identifier#Right AST#ERROR#Left AST#identifier#Left getTextResponseWithHeaders AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identif... | async getTextResponseWithHeaders(endpoint: string, headers: Record<string, string>): Promise<TextResponseWithHeaders> {
return this.requestTextResponse(endpoint, http.RequestMethod.GET, MAX_RETRIES, headers)
} | https://github.com/honjow/Next2V | dc72fb143aa9092f0be9fa6c14bd3a5127f41bf4 | github |
TDCQCX/ShiHuaMusic-Harmony | entry/src/main/ets/utils/GlobalDataManager.ets | arkts | setLoginStatus | 设置登录状态
@param isLoggedIn 是否登录
@param userInfo 用户信息
@param token 认证令牌 | async setLoginStatus(isLoggedIn: boolean, userInfo?: UserInfo, token?: string): Promise<void> {
this.isLoggedIn = isLoggedIn;
if (userInfo && token) {
this.userInfo = userInfo;
this.token = token;
await StorageUtil.saveUserInfo(userInfo);
await StorageUtil.saveToken(token);
... | AST#program#Left AST#expression_statement#Left AST#assignment_expression#Left AST#member_expression#Left AST#identifier#Left async AST#identifier#Right AST#ERROR#Left AST#identifier#Left setLoginStatus AST#identifier#Right AST#formal_parameters#Left AST#(#Left ( AST#(#Right AST#required_parameter#Left AST#identifier#Le... | async setLoginStatus(isLoggedIn: boolean, userInfo?: UserInfo, token?: string): Promise<void> {
this.isLoggedIn = isLoggedIn;
if (userInfo && token) {
this.userInfo = userInfo;
this.token = token;
await StorageUtil.saveUserInfo(userInfo);
await StorageUtil.saveToken(token);
... | https://github.com/TDCQCX/ShiHuaMusic-Harmony | a3030e5afec2f16e0a06d94c493693c3fce9d66f | github |
SMAT-Lab/PhantomRendering | Harmoney_Next-Tiktok/entry/src/main/ets/utils/TikTokChatStore.ets | arkts | getOneTiktokVideoAllComment | 获取一条视频的所有评论数据
@param {String} videoId 视频的id | getOneTiktokVideoAllComment(videoId: string) {
const store = this.getVideoStore(videoId)
const existingComments = JSON.parse(store.getSync(videoId, '[]') as string) as commentDataModel[]
// 如果没有评论数据,初始化一些模拟评论数据
if (existingComments.length === 0) {
const mockComments = getRandomMockComments(... | AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left getOneTiktokVideoAllComment AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left videoId AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left string AST#string#Right AST#ER... | getOneTiktokVideoAllComment(videoId: string) {
const store = this.getVideoStore(videoId)
const existingComments = JSON.parse(store.getSync(videoId, '[]') as string) as commentDataModel[]
// 如果没有评论数据,初始化一些模拟评论数据
if (existingComments.length === 0) {
const mockComments = getRandomMockComments(... | https://github.com/SMAT-Lab/PhantomRendering | 4daf546e3011387db4005cd440846dc4f3749710 | github |
SMAT-Lab/PhantomRendering | Harmoney_Next-Tiktok/entry/src/main/ets/models/watchHistory.ets | arkts | getProgressText | 获取观看进度文本 | getProgressText(): string {
if (this.watchProgress >= 90) {
return '已看完'
} else if (this.watchProgress >= 50) {
return `看了 ${this.watchProgress}%`
} else {
return `刚开始看`
}
} | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left getProgressText AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#)#Left ) AST#)#Right AST#arguments#Right AST#call_expression#Right AST#:#Left : AST#:#Right AST#string#Left string AST#string#Right AST#ERROR#Right AST#statem... | getProgressText(): string {
if (this.watchProgress >= 90) {
return '已看完'
} else if (this.watchProgress >= 50) {
return `看了 ${this.watchProgress}%`
} else {
return `刚开始看`
}
} | https://github.com/SMAT-Lab/PhantomRendering | 336f4a93a6147771adc827585fa7d978e312520a | github |
openharmony/codelabs | ETSUI/Foodbook/entry/src/main/ets/pages/set up.ets | arkts | showLogoutConfirm | 退出登录确认对话框 | showLogoutConfirm() {
AlertDialog.show({
title: '退出登录',
message: '确定要退出当前账号吗?',
primaryButton: {
value: '取消',
action: () => console.log('点击了取消'),
backgroundColor: '#666666',
fontColor: '#FFFFFF'
},
secondaryButton: {
value: '确定退出',
acti... | AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left showLogoutConfirm 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#... | showLogoutConfirm() {
AlertDialog.show({
title: '退出登录',
message: '确定要退出当前账号吗?',
primaryButton: {
value: '取消',
action: () => console.log('点击了取消'),
backgroundColor: '#666666',
fontColor: '#FFFFFF'
},
secondaryButton: {
value: '确定退出',
acti... | https://gitcode.com/openharmony/codelabs | 0d2f4d42674b2bf7b983b631538036eb759cce62 | gitcode |
DaLongZhuaZi/manxia | entry/src/main/ets/Framework/Data/DataManager.ets | arkts | getChapterByExternalId | 【WebView专用】根据外部章节ID获取章节信息(包括内部ID)
用于WebView图源,通过外部ID查找数据库中的章节记录
@param comicId 漫画的内部ID
@param externalChapterId 章节的外部ID(从图源API获取的原始ID)
@returns 章节信息,如果未找到则返回null | public async getChapterByExternalId(comicId: string, externalChapterId: string): Promise<ChapterInfo | null> {
try {
logger.info(TAG, `🔍 [数据库QUERY] [WebView专用] 表名=chapter, 查询条件: comicId=${comicId}, externalId=${externalChapterId}`);
if (!externalChapterId || externalChapterId.trim().length ===... | 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 getChapterByExternalId AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left comicId AST#identifier#Right AST#ERROR#Left AST#... | public async getChapterByExternalId(comicId: string, externalChapterId: string): Promise<ChapterInfo | null> {
try {
logger.info(TAG, `🔍 [数据库QUERY] [WebView专用] 表名=chapter, 查询条件: comicId=${comicId}, externalId=${externalChapterId}`);
if (!externalChapterId || externalChapterId.trim().length ===... | https://github.com/DaLongZhuaZi/manxia | 08265abfb64bdcca943d4b7f36864b24e9042c6a | github |
codelably/HCompass | core/navigation/src/main/ets/NavigationService.ets | arkts | navigateToForResult | 跳转并以 Promise 形式获取返回结果
@param name 路由名称
@param params 跳转参数
@param options 导航选项
@returns 返回结果 | async navigateToForResult<T>(name: string, params?: object, options?: NavigateOptions): Promise<T | undefined> {
return new Promise<T | undefined>((resolve) => {
this.navigateToWithResult(name, params, (info: PopInfo) => {
resolve(info?.result as T);
}, options);
});
} | AST#program#Left AST#ERROR#Left AST#async#Left async AST#async#Right AST#ERROR#Left AST#identifier#Left navigateToForResult AST#identifier#Right AST#ERROR#Right AST#type_parameters#Left AST#<#Left < AST#<#Right AST#type_parameter#Left AST#type_identifier#Left T AST#type_identifier#Right AST#type_parameter#Right AST#>#L... | async navigateToForResult<T>(name: string, params?: object, options?: NavigateOptions): Promise<T | undefined> {
return new Promise<T | undefined>((resolve) => {
this.navigateToWithResult(name, params, (info: PopInfo) => {
resolve(info?.result as T);
}, options);
});
} | https://github.com/codelably/HCompass | 87f6edb75df50d8f976cd88db553ed646606d8b1 | github |
openharmony-tpc/ohos_coap | libcoap/src/main/ets/components/mainpage/coapResource.ets | arkts | registerPostHandler | post请求 | registerPostHandler(resourceId: string, cb: Function): void {
return this.coapResource.registerPostHandler(resourceId, cb);
} | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left registerPostHandler 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... | registerPostHandler(resourceId: string, cb: Function): void {
return this.coapResource.registerPostHandler(resourceId, cb);
} | https://gitee.com/openharmony-tpc/ohos_coap.git | 4856b1638eeab701507f292e5dcb4bf067a91ea6 | gitee |
DaLongZhuaZi/manxia | entry/src/main/ets/Framework/WebView/MangaSourceActionEngine.ets | arkts | buildMultipleItemsScript | 构建多项提取脚本 | private buildMultipleItemsScript(baseSelector: string, fields: Array<[string, string]>): string {
let fieldExtractions = fields.map((field: [string, string]) => {
const fieldName = field[0];
const fieldSelector = field[1];
// 特殊处理 ::index
if (fieldSelector === '::index') {
r... | AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left buildMultipleItemsScript AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left baseSelector AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#string#Left ... | private buildMultipleItemsScript(baseSelector: string, fields: Array<[string, string]>): string {
let fieldExtractions = fields.map((field: [string, string]) => {
const fieldName = field[0];
const fieldSelector = field[1];
// 特殊处理 ::index
if (fieldSelector === '::index') {
r... | https://github.com/DaLongZhuaZi/manxia | a953830b3bcaba0019285f9cc634c76358875718 | github |
codelably/tuniao-ui | packages/main/src/main/ets/viewmodel/TnPickerViewModel.ets | arkts | toggleCascade | 切换联动选择器显示状态 | toggleCascade(): void {
this.cascadeOpen = !this.cascadeOpen;
} | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left toggleCascade 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_bloc... | toggleCascade(): void {
this.cascadeOpen = !this.cascadeOpen;
} | https://github.com/codelably/tuniao-ui | 1ce7d11815d3d2fbc68159c908cc9ca0f3e6d99b | github |
HarmonyOS_Samples/BestPracticeSnippets | VideoProcessBaseWeb/entry/src/main/ets/pages/Index.ets | arkts | build | [End on_back_press]
[EndExclude index]
[EndExclude is_full]
[EndExclude bind_pop]
[EndExclude is_show] | build() {
// [StartExclude index]
Column() {
// [Start raw_file]
// [Start full_exit]
Web({
src: $rawfile(/zh/.test(this.language) ? 'index_cn.html' : 'index_en.html'),
controller: this.webController
})
// [StartExclude full_exit]
// [StartExclude is_full]
... | 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#comment#Le... | build() {
// [StartExclude index]
Column() {
// [Start raw_file]
// [Start full_exit]
Web({
src: $rawfile(/zh/.test(this.language) ? 'index_cn.html' : 'index_en.html'),
controller: this.webController
})
// [StartExclude full_exit]
// [StartExclude is_full]
... | https://gitcode.com/HarmonyOS_Samples/BestPracticeSnippets | e3c062eb80443b5139063d39258f491d856e4407 | gitcode |
ZestBox-18/kitebook-frontend | commons/kite_utils/src/main/ets/utils/windowInfo/WindowUtil.ets | arkts | queryOrientationByResourceManager | 通过资源管理器查询方向信息 | queryOrientationByResourceManager(): void {
let info: resourceManager.Direction | undefined =
this.uiContext?.getHostContext()?.resourceManager.getConfigurationSync().direction;
hilog.info(0x0000, 'testLog', `The Orientation is ${info}`);
} | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left queryOrientationByResourceManager 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#Righ... | queryOrientationByResourceManager(): void {
let info: resourceManager.Direction | undefined =
this.uiContext?.getHostContext()?.resourceManager.getConfigurationSync().direction;
hilog.info(0x0000, 'testLog', `The Orientation is ${info}`);
} | https://github.com/ZestBox-18/kitebook-frontend | e7f4dcd96b47263b472182f75c52a38a5d28c63c | github |
CLMC2025/Vignette | entry/src/main/ets/context/ContextValidator.ets | arkts | generateImprovements | 生成改进建议 | generateImprovements(result: ValidationResult): string[] {
const improvements: string[] = [];
for (const issue of result.issues) {
if (issue.suggestion.length > 0) {
improvements.push(issue.suggestion);
}
}
return improvements;
} | AST#program#Left AST#expression_statement#Left AST#call_expression#Left AST#identifier#Left generateImprovements AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#ERROR#Left AST#identifier#Left result AST#identifier#Right AST#:#Left : AST#:#Right AST#ERROR#Right AST#identifier#Left ValidationResult A... | generateImprovements(result: ValidationResult): string[] {
const improvements: string[] = [];
for (const issue of result.issues) {
if (issue.suggestion.length > 0) {
improvements.push(issue.suggestion);
}
}
return improvements;
} | https://github.com/CLMC2025/Vignette | 417d6c6facd491ea9db80c804ddf8cabce7d0376 | github |
iop123123/arkts-static-skills | cli/arkts-static-cli/runtime/ark/es2panda/linux/etc/sdk/api/@ohos.util.ets | arkts | isArrayBufferView | Check whether the type is included in the isAnyArrayBuffer.
@param { Object } value - A included in the isAnyArrayBuffer value
@returns { boolean } Returns true if the value is an instance of one of the ArrayBuffer views,
such as typed array objects or DataView. | isArrayBufferView(value: Object): boolean {
return this.isDataView(value) || this.isTypedArray(value);
} | AST#program#Left AST#ERROR#Left AST#call_expression#Left AST#identifier#Left isArrayBufferView 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 Object AST#identifier#Right AST#)#Lef... | isArrayBufferView(value: Object): boolean {
return this.isDataView(value) || this.isTypedArray(value);
} | https://gitcode.com/iop123123/arkts-static-skills | bde75b30a482e38964e0f040f665548c121978f3 | gitcode |
AlkaidLab/moonlight-harmony | entry/src/main/ets/service/network/NetworkBoostService.ets | arkts | subscribeScene | ───── netSceneChange(弱信号预测/拥塞) ───── | private subscribeScene(): void {
if (!this.supported || this.sceneCallback) {
return;
}
const cb = (list: Array<netQuality.NetworkScene>): void => {
if (!list || list.length === 0) {
return;
}
let primary: netQuality.NetworkScene | undefined = list.find((s) =>
s.pat... | AST#program#Left AST#ERROR#Left AST#private#Left private AST#private#Right AST#call_expression#Left AST#identifier#Left subscribeScene 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#v... | private subscribeScene(): void {
if (!this.supported || this.sceneCallback) {
return;
}
const cb = (list: Array<netQuality.NetworkScene>): void => {
if (!list || list.length === 0) {
return;
}
let primary: netQuality.NetworkScene | undefined = list.find((s) =>
s.pat... | https://github.com/AlkaidLab/moonlight-harmony | eb288a4efad4489943879ea0d06a60f742d79242 | github |
openharmony-tpc/ohos_mpchart | library/src/main/ets/components/data/ScatterDataSet.ets | arkts | setScatterShapeHoleColor | Sets the color for the hole in the shape.
@param holeColor | public setScatterShapeHoleColor(holeColor: number): void {
this.mScatterShapeHoleColor = holeColor;
} | AST#program#Left AST#ERROR#Left AST#public#Left public AST#public#Right AST#call_expression#Left AST#identifier#Left setScatterShapeHoleColor AST#identifier#Right AST#arguments#Left AST#(#Left ( AST#(#Right AST#identifier#Left holeColor AST#identifier#Right AST#ERROR#Left AST#:#Left : AST#:#Right AST#number#Left number... | public setScatterShapeHoleColor(holeColor: number): void {
this.mScatterShapeHoleColor = holeColor;
} | https://gitee.com/openharmony-tpc/ohos_mpchart.git | 648a3dc71460fb42a9a7229682adb5679306c10f | gitee |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.