nwo
stringclasses 304
values | sha
stringclasses 304
values | path
stringlengths 9
214
| language
stringclasses 1
value | identifier
stringlengths 0
49
| docstring
stringlengths 1
34.2k
| function
stringlengths 8
59.4k
| ast_function
stringlengths 71
497k
| obf_function
stringlengths 8
39.4k
| url
stringlengths 102
324
| function_sha
stringlengths 40
40
| source
stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/analytics/AnalyticsService.ets
|
arkts
|
startNewSession
|
开始新会话
|
private startNewSession(): void {
this.currentSessionId = `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
this.sessionStartTime = Date.now();
const eventData: AppLaunchEventData = {
sessionId: this.currentSessionId,
timestamp: new Date().toISOString()
};
this.trackEvent('app_launch', eventData);
}
|
AST#method_declaration#Left private startNewSession AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentSessionId AST#member_expression#Right = AST#expression#Left AST#template_literal#Left ` session_ AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Date AST#expression#Right . now AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right _ AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . random AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 36 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . substr AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 2 AST#expression#Right , AST#expression#Left 9 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sessionStartTime AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Date AST#expression#Right . now AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left eventData : AST#type_annotation#Left AST#primary_type#Left AppLaunchEventData AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left sessionId AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentSessionId AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left timestamp AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . toISOString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . trackEvent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'app_launch' AST#expression#Right , AST#expression#Left eventData AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private startNewSession(): void {
this.currentSessionId = `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
this.sessionStartTime = Date.now();
const eventData: AppLaunchEventData = {
sessionId: this.currentSessionId,
timestamp: new Date().toISOString()
};
this.trackEvent('app_launch', eventData);
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/analytics/AnalyticsService.ets#L313-L322
|
d35f5f897544f3f67e50c35b1476faaf69dca3c9
|
github
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/Solutions/Tools/FlipClock/entry/src/main/ets/common/AlarmClock.ets
|
arkts
|
getDeviceType
|
获取设备类型
|
async getDeviceType(){
try {
let deviceType = deviceInfo.deviceType;
Logger.info(`deviceType` + JSON.stringify(deviceType));
if (deviceType === 'default') {
this.isDefault = true;
} else {
this.isDefault = false;
}
} catch (e) {
Logger.info(`getSync unexpected error: ${e}`);
}
}
|
AST#method_declaration#Left async getDeviceType AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left deviceType = AST#expression#Left AST#member_expression#Left AST#expression#Left deviceInfo AST#expression#Right . deviceType AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#template_literal#Left ` deviceType ` AST#template_literal#Right AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left deviceType AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left deviceType AST#expression#Right === AST#expression#Left 'default' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isDefault AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isDefault AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( e ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` getSync unexpected error: AST#template_substitution#Left $ { AST#expression#Left e AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async getDeviceType(){
try {
let deviceType = deviceInfo.deviceType;
Logger.info(`deviceType` + JSON.stringify(deviceType));
if (deviceType === 'default') {
this.isDefault = true;
} else {
this.isDefault = false;
}
} catch (e) {
Logger.info(`getSync unexpected error: ${e}`);
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Solutions/Tools/FlipClock/entry/src/main/ets/common/AlarmClock.ets#L62-L74
|
277703cb1bc8dfeee6c08b3db586c4f10097087c
|
gitee
|
salehelper/algorithm_arkts.git
|
61af15272038646775a4745fca98a48ba89e1f4e
|
entry/src/main/ets/strings/BoyerMoore.ets
|
arkts
|
findAllMatches
|
在文本中查找模式串的所有出现位置
@param text 文本字符串
@param pattern 模式串
@returns 所有匹配位置的数组
|
static findAllMatches(text: string, pattern: string): number[] {
if (!text || !pattern || pattern.length === 0) {
return [];
}
const result: number[] = [];
const badCharTable: Map<string, number> = BoyerMoore.buildBadCharTable(pattern);
const goodSuffixTable: number[] = BoyerMoore.buildGoodSuffixTable(pattern);
const m = pattern.length;
const n = text.length;
let i = 0;
while (i <= n - m) {
let j = m - 1;
while (j >= 0 && pattern[j] === text[i + j]) {
j--;
}
if (j < 0) {
// 找到匹配
result.push(i);
i += goodSuffixTable[0];
} else {
// 使用坏字符规则和好后缀规则中的较大值
const badCharShift = badCharTable.get(text[i + j]) ?? m;
const goodSuffixShift = goodSuffixTable[j];
i += Math.max(badCharShift, goodSuffixShift);
}
}
return result;
}
|
AST#method_declaration#Left static findAllMatches AST#parameter_list#Left ( AST#parameter#Left text : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left pattern : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left text AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left AST#unary_expression#Left ! AST#expression#Left pattern AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left pattern AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left result : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left badCharTable : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Map AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left BoyerMoore AST#expression#Right . buildBadCharTable AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left pattern AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left goodSuffixTable : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left BoyerMoore AST#expression#Right . buildGoodSuffixTable AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left pattern AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left m = AST#expression#Left AST#member_expression#Left AST#expression#Left pattern AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left n = AST#expression#Left AST#member_expression#Left AST#expression#Left text AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#while_statement#Left while ( AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right <= AST#expression#Left AST#binary_expression#Left AST#expression#Left n AST#expression#Right - AST#expression#Left m AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left j = AST#expression#Left AST#binary_expression#Left AST#expression#Left m AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#while_statement#Left while ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left j AST#expression#Right >= AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left pattern AST#expression#Right [ AST#expression#Left j AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right === AST#expression#Left AST#subscript_expression#Left AST#expression#Left text AST#expression#Right [ AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right + AST#expression#Left j AST#expression#Right AST#binary_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#update_expression#Left AST#expression#Left j AST#expression#Right -- AST#update_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#while_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left j AST#expression#Right < AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // 找到匹配 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left i AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left i += AST#expression#Left AST#subscript_expression#Left AST#expression#Left goodSuffixTable AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { // 使用坏字符规则和好后缀规则中的较大值 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left badCharShift = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left badCharTable AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left text AST#expression#Right [ AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right + AST#expression#Left j AST#expression#Right AST#binary_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ?? AST#expression#Left m AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left goodSuffixShift = AST#expression#Left AST#subscript_expression#Left AST#expression#Left goodSuffixTable AST#expression#Right [ AST#expression#Left j AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left i += AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . max AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left badCharShift AST#expression#Right , AST#expression#Left goodSuffixShift AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#while_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static findAllMatches(text: string, pattern: string): number[] {
if (!text || !pattern || pattern.length === 0) {
return [];
}
const result: number[] = [];
const badCharTable: Map<string, number> = BoyerMoore.buildBadCharTable(pattern);
const goodSuffixTable: number[] = BoyerMoore.buildGoodSuffixTable(pattern);
const m = pattern.length;
const n = text.length;
let i = 0;
while (i <= n - m) {
let j = m - 1;
while (j >= 0 && pattern[j] === text[i + j]) {
j--;
}
if (j < 0) {
result.push(i);
i += goodSuffixTable[0];
} else {
const badCharShift = badCharTable.get(text[i + j]) ?? m;
const goodSuffixShift = goodSuffixTable[j];
i += Math.max(badCharShift, goodSuffixShift);
}
}
return result;
}
|
https://github.com/salehelper/algorithm_arkts.git/blob/61af15272038646775a4745fca98a48ba89e1f4e/entry/src/main/ets/strings/BoyerMoore.ets#L12-L43
|
717cae91b448ad6b2f55ab2f8735a218e7f3ceae
|
github
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/BasicFeature/Media/VideoTrimmer/entry/src/main/ets/videotrimmer/RangeSeekBarView.ets
|
arkts
|
leftThumbUpdate
|
更新左边滑块位置
|
leftThumbUpdate(deltaX: number) {
let deltaPx = deltaX;
// 左边距
if (deltaPx <= 0 && ((this.leftThumbRect[0] + deltaPx) <= this.leftPadding)) {
deltaPx = this.leftPadding - this.leftThumbRect[0];
}
// 右边距
if (deltaPx >= 0 && ((this.leftThumbRect[2] + deltaPx) >= (this.rightThumbRect[0] - this.leftRightPaddingMin))) {
deltaPx = (this.rightThumbRect[0] - this.leftRightPaddingMin) - this.leftThumbRect[2];
}
// 左边界 新增与右thumb的最大边距
if (deltaPx <= 0 && ((this.leftThumbRect[2] + deltaPx) <= (this.rightThumbRect[0] - this.leftRightPaddingMax))) {
deltaPx = (this.rightThumbRect[0] - this.leftRightPaddingMax) - this.leftThumbRect[2];
}
let newArea = [
(this.leftThumbRect[0] + deltaPx),
this.leftThumbRect[1],
(this.leftThumbRect[2] + deltaPx),
this.leftThumbRect[3]];
this.leftThumbRect = newArea;
this.leftThumbPosition = { x: newArea[0], y: newArea[1] };
this.leftTextPosition = { x: newArea[0], y: newArea[1] };
this.middenPosition = { x: this.leftThumbRect[2], y: this.leftThumbRect[1] };
this.transparentWidth = this.rightThumbRect[0] - this.leftThumbRect[2];
// 更新选取视频时间
this.onRangeValueChanged();
}
|
AST#method_declaration#Left leftThumbUpdate AST#parameter_list#Left ( AST#parameter#Left deltaX : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left deltaPx = AST#expression#Left deltaX AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 左边距 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left deltaPx AST#expression#Right <= AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right + AST#expression#Left deltaPx AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right <= AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . leftPadding AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left deltaPx = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftPadding AST#member_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . leftThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 右边距 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left deltaPx AST#expression#Right >= AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 2 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right + AST#expression#Left deltaPx AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right >= AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rightThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . leftRightPaddingMin AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left deltaPx = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rightThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . leftRightPaddingMin AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . leftThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 2 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 左边界 新增与右thumb的最大边距 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left deltaPx AST#expression#Right <= AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 2 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right + AST#expression#Left deltaPx AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right <= AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rightThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . leftRightPaddingMax AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left deltaPx = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rightThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . leftRightPaddingMax AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . leftThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 2 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left newArea = AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right + AST#expression#Left deltaPx AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right , AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right , AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 2 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right + AST#expression#Left deltaPx AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right , AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 3 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftThumbRect AST#member_expression#Right = AST#expression#Left newArea AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftThumbPosition AST#member_expression#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#subscript_expression#Left AST#expression#Left newArea AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#subscript_expression#Left AST#expression#Left newArea AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftTextPosition AST#member_expression#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#subscript_expression#Left AST#expression#Left newArea AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#subscript_expression#Left AST#expression#Left newArea AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . middenPosition AST#member_expression#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 2 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . transparentWidth AST#member_expression#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rightThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . leftThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 2 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 更新选取视频时间 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onRangeValueChanged AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
leftThumbUpdate(deltaX: number) {
let deltaPx = deltaX;
if (deltaPx <= 0 && ((this.leftThumbRect[0] + deltaPx) <= this.leftPadding)) {
deltaPx = this.leftPadding - this.leftThumbRect[0];
}
if (deltaPx >= 0 && ((this.leftThumbRect[2] + deltaPx) >= (this.rightThumbRect[0] - this.leftRightPaddingMin))) {
deltaPx = (this.rightThumbRect[0] - this.leftRightPaddingMin) - this.leftThumbRect[2];
}
if (deltaPx <= 0 && ((this.leftThumbRect[2] + deltaPx) <= (this.rightThumbRect[0] - this.leftRightPaddingMax))) {
deltaPx = (this.rightThumbRect[0] - this.leftRightPaddingMax) - this.leftThumbRect[2];
}
let newArea = [
(this.leftThumbRect[0] + deltaPx),
this.leftThumbRect[1],
(this.leftThumbRect[2] + deltaPx),
this.leftThumbRect[3]];
this.leftThumbRect = newArea;
this.leftThumbPosition = { x: newArea[0], y: newArea[1] };
this.leftTextPosition = { x: newArea[0], y: newArea[1] };
this.middenPosition = { x: this.leftThumbRect[2], y: this.leftThumbRect[1] };
this.transparentWidth = this.rightThumbRect[0] - this.leftThumbRect[2];
this.onRangeValueChanged();
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/BasicFeature/Media/VideoTrimmer/entry/src/main/ets/videotrimmer/RangeSeekBarView.ets#L324-L353
|
d2f0fab62bee82f42f1de6d2b4a9f365b3cbf30d
|
gitee
|
DEMON-coding/HarmonyOs-Clock-Demo.git
|
f3c71a3d5ac478d463dfed068b89582104d2f9f6
|
entry/src/main/ets/common/utils/NotificationUtil.ets
|
arkts
|
请求打开通知权限
|
export function requestNotificationPermission(context: common.UIAbilityContext) {
notificationManager.requestEnableNotification(context).then(() => {
console.info('通知权限已开启');
}).catch((err: Error) => {
console.error('开启通知权限失败: ' + JSON.stringify(err));
});
}
|
AST#export_declaration#Left export AST#function_declaration#Left function requestNotificationPermission AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left notificationManager AST#expression#Right . requestEnableNotification AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '通知权限已开启' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '开启通知权限失败: ' AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export function requestNotificationPermission(context: common.UIAbilityContext) {
notificationManager.requestEnableNotification(context).then(() => {
console.info('通知权限已开启');
}).catch((err: Error) => {
console.error('开启通知权限失败: ' + JSON.stringify(err));
});
}
|
https://github.com/DEMON-coding/HarmonyOs-Clock-Demo.git/blob/f3c71a3d5ac478d463dfed068b89582104d2f9f6/entry/src/main/ets/common/utils/NotificationUtil.ets#L8-L14
|
bccb253bc3076b44d83e0d87db02bf6f6d709962
|
github
|
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/common/utils/Toast.ets
|
arkts
|
showCustomDialog
|
显示自定义底部弹窗
@param builder - 自定义弹窗内容构建器,需使用`@Builder`修饰的函数
@param autoCancel: true 允许用户点击空白处关闭Dialog
@remarks
- 弹窗默认从屏幕底部弹出
- 自动处理软键盘冲突(避让模式)
- 错误会通过console.error输出
@example
```typescript
@Builder function MyDialog() {
Column() { Text("自定义内容") }
}
showCustomDialog(()=>{this.MyDialog()});
```
|
static showCustomDialog(builder: CustomBuilder, autoCancel: boolean = true, isBgTransparent: boolean = false, onDisappear?: ()=>void ): void {
promptAction.openCustomDialog({
builder: builder, // 传入自定义UI构建器
isModal:true,
autoCancel: autoCancel,
showInSubWindow:false,
alignment: DialogAlignment.Center, // 弹窗对齐方式:底部
keyboardAvoidMode: KeyboardAvoidMode.DEFAULT, // 软键盘弹出时自动调整弹窗位置
keyboardAvoidDistance: LengthMetrics.vp(10), // 弹窗与键盘间距为0虚拟像素(默认紧贴键盘上方)
maskColor: $r('app.color.color_translucent'),// ✅ 半透明黑色遮罩 (50% 透明度)
backgroundColor: isBgTransparent ? Color.Transparent : Color.White,
backgroundBlurStyle: isBgTransparent ? BlurStyle.NONE : BlurStyle.Regular,
maskRect:{ x: 0, y: 0, width: '100%', height: '100%' },
onDidDisappear: onDisappear,
}).then((dialogId: number) => {
Toast.customDialogComponentId = dialogId
}).catch((error: BusinessError) => {
console.error(`openCustomDialog error code is ${error.code}, message is ${error.message}`)
})
}
|
AST#method_declaration#Left static showCustomDialog AST#parameter_list#Left ( AST#parameter#Left builder : AST#type_annotation#Left AST#primary_type#Left CustomBuilder AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left autoCancel : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#parameter#Right , AST#parameter#Left isBgTransparent : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#parameter#Right , AST#parameter#Left onDisappear ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . openCustomDialog AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left builder AST#property_name#Right : AST#expression#Left builder AST#expression#Right AST#property_assignment#Right , // 传入自定义UI构建器 AST#property_assignment#Left AST#property_name#Left isModal AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left autoCancel AST#property_name#Right : AST#expression#Left autoCancel AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left showInSubWindow AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left alignment AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left DialogAlignment AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 弹窗对齐方式:底部 AST#property_assignment#Left AST#property_name#Left keyboardAvoidMode AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left KeyboardAvoidMode AST#expression#Right . DEFAULT AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 软键盘弹出时自动调整弹窗位置 AST#property_assignment#Left AST#property_name#Left keyboardAvoidDistance AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LengthMetrics AST#expression#Right . vp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 10 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , // 弹窗与键盘间距为0虚拟像素(默认紧贴键盘上方) AST#property_assignment#Left AST#property_name#Left maskColor AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.color_translucent' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , // ✅ 半透明黑色遮罩 (50% 透明度) AST#property_assignment#Left AST#property_name#Left backgroundColor AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left isBgTransparent AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Transparent AST#member_expression#Right AST#expression#Right : AST#expression#Left Color AST#expression#Right AST#conditional_expression#Right AST#expression#Right . White AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left backgroundBlurStyle AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left isBgTransparent AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left BlurStyle AST#expression#Right . NONE AST#member_expression#Right AST#expression#Right : AST#expression#Left BlurStyle AST#expression#Right AST#conditional_expression#Right AST#expression#Right . Regular AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left maskRect AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left '100%' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left '100%' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left onDidDisappear AST#property_name#Right : AST#expression#Left onDisappear AST#expression#Right AST#property_assignment#Right , } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left dialogId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left Toast AST#expression#Right . customDialogComponentId AST#member_expression#Right = AST#expression#Left dialogId AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` openCustomDialog error code is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , message is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
static showCustomDialog(builder: CustomBuilder, autoCancel: boolean = true, isBgTransparent: boolean = false, onDisappear?: ()=>void ): void {
promptAction.openCustomDialog({
builder: builder,
isModal:true,
autoCancel: autoCancel,
showInSubWindow:false,
alignment: DialogAlignment.Center,
keyboardAvoidMode: KeyboardAvoidMode.DEFAULT,
keyboardAvoidDistance: LengthMetrics.vp(10),
maskColor: $r('app.color.color_translucent'),
backgroundColor: isBgTransparent ? Color.Transparent : Color.White,
backgroundBlurStyle: isBgTransparent ? BlurStyle.NONE : BlurStyle.Regular,
maskRect:{ x: 0, y: 0, width: '100%', height: '100%' },
onDidDisappear: onDisappear,
}).then((dialogId: number) => {
Toast.customDialogComponentId = dialogId
}).catch((error: BusinessError) => {
console.error(`openCustomDialog error code is ${error.code}, message is ${error.message}`)
})
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/utils/Toast.ets#L176-L199
|
d3523286fae8877cbe058d168f447a6d6c036a41
|
github
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/Performance/PerformanceLibrary/feature/DFXStateManagement/src/main/ets/view/DFXStateBeforeOptimization.ets
|
arkts
|
uiStyle的属性被多个组件使用
|
build() {
Column() {
// 使用状态变量的组件
SpecialImage({
specialImageUiStyle: this.uiStyle
})
Stack() {
Column() {
Image($r('app.media.icon'))
.opacity($r('app.float.icon_opacity'))
.scale({
x: this.uiStyle.scaleX,
y: this.uiStyle.scaleY
})
.width($r('app.integer.stack_icon_width'))
.height($r('app.integer.stack_icon_height'))
}
.width('100%')
.position({ y: $r('app.integer.stack_column_position_y') })
Stack() {
Text("Hello World")
.fontColor($r('app.color.text_color'))
.fontWeight(FontWeight.Medium)
.fontSize($r('app.integer.button_font_size'))
.margin({ top: $r('app.integer.text_margin_top') })
}
.position({
x: $r('app.integer.text_position_x'),
y: $r('app.integer.text_position_y')
})
.width('100%')
.height('100%')
}
.margin({ top: $r('app.integer.stack_margin_top') })
.borderRadius($r('app.integer.stack_border_radius'))
.backgroundColor($r('app.color.stack_color'))
.width($r('app.integer.stack_width'))
.height($r('app.integer.stack_height'))
.translate({
x: this.uiStyle.translateX,
y: this.uiStyle.translateY
})
// 通过按钮点击回调修改状态变量的值,引起相应的组件刷新
Column() {
Button('Move')
.width($r('app.integer.button_width'))
.fontSize($r('app.integer.button_font_size'))
.backgroundColor($r('app.color.button_color'))
.margin({ bottom: $r('app.integer.button_margin_bottom') })
.onClick(() => {
animateTo({
duration: animationDuration
}, () => {
this.uiStyle.translateY = (this.uiStyle.translateY + translateYChangeValue) % translateYChangeRange;
})
})
Button('Scale')
.backgroundColor($r('app.color.button_color'))
.fontSize($r('app.integer.button_font_size'))
.width($r('app.integer.button_width'))
.margin({ bottom: $r('app.integer.button_margin_bottom') })
.onClick(() => {
this.uiStyle.scaleX = (this.uiStyle.scaleX + scaleXChangeValue) % scaleXChangeRange;
})
}
.position({
y: $r('app.integer.button_column_position_y')
})
.height('100%')
.width('100%')
}
.width('100%')
.height('100%')
}
|
AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { // 使用状态变量的组件 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left SpecialImage ( AST#component_parameters#Left { AST#component_parameter#Left specialImageUiStyle : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . uiStyle AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Stack ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.icon' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . opacity ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.icon_opacity' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . scale ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . uiStyle AST#member_expression#Right AST#expression#Right . scaleX AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . uiStyle AST#member_expression#Right AST#expression#Right . scaleY AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.stack_icon_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.stack_icon_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . position ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.stack_column_position_y' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Stack ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left "Hello World" AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.button_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.text_margin_top' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . position ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.text_position_x' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.text_position_y' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.stack_margin_top' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.stack_border_radius' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.stack_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.stack_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.stack_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . translate ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . uiStyle AST#member_expression#Right AST#expression#Right . translateX AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . uiStyle AST#member_expression#Right AST#expression#Right . translateY AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 通过按钮点击回调修改状态变量的值,引起相应的组件刷新 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left 'Move' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.button_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.button_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.button_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.button_margin_bottom' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left animateTo AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left animationDuration AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . uiStyle AST#member_expression#Right AST#expression#Right . translateY AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . uiStyle AST#member_expression#Right AST#expression#Right . translateY AST#member_expression#Right AST#expression#Right + AST#expression#Left translateYChangeValue AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right % AST#expression#Left translateYChangeRange AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left 'Scale' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.button_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.button_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.button_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.button_margin_bottom' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . uiStyle AST#member_expression#Right AST#expression#Right . scaleX AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . uiStyle AST#member_expression#Right AST#expression#Right . scaleX AST#member_expression#Right AST#expression#Right + AST#expression#Left scaleXChangeValue AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right % AST#expression#Left scaleXChangeRange AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . position ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.button_column_position_y' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right
|
build() {
Column() {
SpecialImage({
specialImageUiStyle: this.uiStyle
})
Stack() {
Column() {
Image($r('app.media.icon'))
.opacity($r('app.float.icon_opacity'))
.scale({
x: this.uiStyle.scaleX,
y: this.uiStyle.scaleY
})
.width($r('app.integer.stack_icon_width'))
.height($r('app.integer.stack_icon_height'))
}
.width('100%')
.position({ y: $r('app.integer.stack_column_position_y') })
Stack() {
Text("Hello World")
.fontColor($r('app.color.text_color'))
.fontWeight(FontWeight.Medium)
.fontSize($r('app.integer.button_font_size'))
.margin({ top: $r('app.integer.text_margin_top') })
}
.position({
x: $r('app.integer.text_position_x'),
y: $r('app.integer.text_position_y')
})
.width('100%')
.height('100%')
}
.margin({ top: $r('app.integer.stack_margin_top') })
.borderRadius($r('app.integer.stack_border_radius'))
.backgroundColor($r('app.color.stack_color'))
.width($r('app.integer.stack_width'))
.height($r('app.integer.stack_height'))
.translate({
x: this.uiStyle.translateX,
y: this.uiStyle.translateY
})
Column() {
Button('Move')
.width($r('app.integer.button_width'))
.fontSize($r('app.integer.button_font_size'))
.backgroundColor($r('app.color.button_color'))
.margin({ bottom: $r('app.integer.button_margin_bottom') })
.onClick(() => {
animateTo({
duration: animationDuration
}, () => {
this.uiStyle.translateY = (this.uiStyle.translateY + translateYChangeValue) % translateYChangeRange;
})
})
Button('Scale')
.backgroundColor($r('app.color.button_color'))
.fontSize($r('app.integer.button_font_size'))
.width($r('app.integer.button_width'))
.margin({ bottom: $r('app.integer.button_margin_bottom') })
.onClick(() => {
this.uiStyle.scaleX = (this.uiStyle.scaleX + scaleXChangeValue) % scaleXChangeRange;
})
}
.position({
y: $r('app.integer.button_column_position_y')
})
.height('100%')
.width('100%')
}
.width('100%')
.height('100%')
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Performance/PerformanceLibrary/feature/DFXStateManagement/src/main/ets/view/DFXStateBeforeOptimization.ets#L72-L147
|
b4d17d840ce05f404ed4298a43cd27102e66f472
|
gitee
|
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Ability/StageAbility/entry/src/main/ets/model/ButtonClickMethod.ets
|
arkts
|
toEntryAbilitySecond
|
Navigate to the Second Page of EntryAbility.
|
toEntryAbilitySecond() {
router.pushUrl({
url: 'pages/Second',
params: {
src: textMessage,
count: CommonConstants.NUM_VALUES[0]
}
});
}
|
AST#method_declaration#Left toEntryAbilitySecond AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left router AST#expression#Right . pushUrl AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left 'pages/Second' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left params AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left src AST#property_name#Right : AST#expression#Left textMessage AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left count AST#property_name#Right : AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . NUM_VALUES AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
toEntryAbilitySecond() {
router.pushUrl({
url: 'pages/Second',
params: {
src: textMessage,
count: CommonConstants.NUM_VALUES[0]
}
});
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Ability/StageAbility/entry/src/main/ets/model/ButtonClickMethod.ets#L36-L44
|
d0c90cd919d12e82c4bc8d6fcad548b319b1e159
|
gitee
|
2763981847/Clock-Alarm.git
|
8949bedddb7d011021848196735f30ffe2bd1daf
|
entry/src/main/ets/model/ReminderService.ets
|
arkts
|
deleteReminder
|
删除提醒。
@param reminderId number 提醒的 ID
|
public deleteReminder(reminderId: number) {
reminderAgent.cancelReminder(reminderId);
}
|
AST#method_declaration#Left public deleteReminder AST#parameter_list#Left ( AST#parameter#Left reminderId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left reminderAgent AST#expression#Right . cancelReminder AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left reminderId AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
public deleteReminder(reminderId: number) {
reminderAgent.cancelReminder(reminderId);
}
|
https://github.com/2763981847/Clock-Alarm.git/blob/8949bedddb7d011021848196735f30ffe2bd1daf/entry/src/main/ets/model/ReminderService.ets#L43-L45
|
f8991d8e60a859df94a2116478eb06cac0cff86a
|
github
|
bigbear20240612/planner_build-.git
|
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
|
entry/src/main/ets/viewmodel/TaskViewModel.ets
|
arkts
|
getTaskStats
|
获取任务统计信息
|
getTaskStats(): TaskStats {
const total = this.tasks.length;
const completed = this.getCompletedTasks().length;
const pending = this.getPendingTasks().length;
const overdue = this.getOverdueTasks().length;
const todayTasks = this.getTodayTasks();
const todayCompleted = todayTasks.filter(task => task.completed).length;
// 计算时间维度统计
const timeStats = this.calculateTimeStats();
const completionAnalysis = this.calculateCompletionTimeAnalysis();
return {
total,
completed,
pending,
overdue,
todayTotal: todayTasks.length,
todayCompleted,
completionRate: total > 0 ? Math.round((completed / total) * 100) : 0,
todayCompletionRate: todayTasks.length > 0 ? Math.round((todayCompleted / todayTasks.length) * 100) : 0,
timeStats,
completionAnalysis
};
}
|
AST#method_declaration#Left getTaskStats AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left TaskStats AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left total = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . tasks AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left completed = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getCompletedTasks AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left pending = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getPendingTasks AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left overdue = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getOverdueTasks AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left todayTasks = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getTodayTasks AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left todayCompleted = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left todayTasks AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left task => AST#expression#Left AST#member_expression#Left AST#expression#Left task AST#expression#Right . completed AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 计算时间维度统计 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left timeStats = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . calculateTimeStats AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left completionAnalysis = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . calculateCompletionTimeAnalysis AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left total AST#property_assignment#Right , AST#property_assignment#Left completed AST#property_assignment#Right , AST#property_assignment#Left pending AST#property_assignment#Right , AST#property_assignment#Left overdue AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left todayTotal AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left todayTasks AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left todayCompleted AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left completionRate AST#property_name#Right : AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left total AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . round AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left completed AST#expression#Right / AST#expression#Left total AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left 100 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left 0 AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left todayCompletionRate AST#property_name#Right : AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left todayTasks AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . round AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left todayCompleted AST#expression#Right / AST#expression#Left todayTasks AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left 100 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left 0 AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left timeStats AST#property_assignment#Right , AST#property_assignment#Left completionAnalysis AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
getTaskStats(): TaskStats {
const total = this.tasks.length;
const completed = this.getCompletedTasks().length;
const pending = this.getPendingTasks().length;
const overdue = this.getOverdueTasks().length;
const todayTasks = this.getTodayTasks();
const todayCompleted = todayTasks.filter(task => task.completed).length;
const timeStats = this.calculateTimeStats();
const completionAnalysis = this.calculateCompletionTimeAnalysis();
return {
total,
completed,
pending,
overdue,
todayTotal: todayTasks.length,
todayCompleted,
completionRate: total > 0 ? Math.round((completed / total) * 100) : 0,
todayCompletionRate: todayTasks.length > 0 ? Math.round((todayCompleted / todayTasks.length) * 100) : 0,
timeStats,
completionAnalysis
};
}
|
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/viewmodel/TaskViewModel.ets#L491-L515
|
235ce0090cdbead008d3b17933dc2e534123d13e
|
github
|
Application-Security-Automation/Arktan.git
|
3ad9cb05235e38b00cd5828476aa59a345afa1c0
|
dataset/completeness/alias/alias_001_T.ets
|
arkts
|
Introduction 别名
|
export function alias_001_T(taint_src : string) {
let a = new A();
let b = a;
b.data = taint_src;
taint.Sink(a.data);
}
|
AST#export_declaration#Left export AST#function_declaration#Left function alias_001_T AST#parameter_list#Left ( AST#parameter#Left taint_src : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left a = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left A AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left b = AST#expression#Left a AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left b AST#expression#Right . data AST#member_expression#Right = AST#expression#Left taint_src AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left taint AST#expression#Right . Sink AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left a AST#expression#Right . data AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export function alias_001_T(taint_src : string) {
let a = new A();
let b = a;
b.data = taint_src;
taint.Sink(a.data);
}
|
https://github.com/Application-Security-Automation/Arktan.git/blob/3ad9cb05235e38b00cd5828476aa59a345afa1c0/dataset/completeness/alias/alias_001_T.ets#L6-L12
|
0157fe25d90abe9b3aa7c47fedb72d6157b2a06b
|
github
|
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/ar/ARCardService.ets
|
arkts
|
3D颜色接口
|
export interface Color3D {
r: number;
g: number;
b: number;
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface Color3D AST#object_type#Left { AST#type_member#Left r : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left g : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left b : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
|
export interface Color3D {
r: number;
g: number;
b: number;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/ar/ARCardService.ets#L88-L92
|
84a8b2388bb2e4defe2f63fc4d37ae80eac06148
|
github
|
|
harmonyos/samples
|
f5d967efaa7666550ee3252d118c3c73a77686f5
|
HarmonyOS_NEXT/Security/Huks/entry/src/main/ets/model/HuksModel.ets
|
arkts
|
getSm4EncryptProperties
|
Sm4加密密钥属性信息
|
function getSm4EncryptProperties(properties: HuksProperties[]): void {
let index = 0;
properties[index++] = {
tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
value: huks.HuksKeyAlg.HUKS_ALG_SM4
};
properties[index++] = {
tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128,
};
properties[index++] = {
tag: huks.HuksTag.HUKS_TAG_PURPOSE,
value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT
};
properties[index++] = {
tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
value: huks.HuksCipherMode.HUKS_MODE_CBC
};
properties[index++] = {
tag: huks.HuksTag.HUKS_TAG_PADDING,
value: huks.HuksKeyPadding.HUKS_PADDING_PKCS7
};
properties[index++] = {
tag: huks.HuksTag.HUKS_TAG_IV,
value: stringToUint8Array(IV)
};
return;
}
|
AST#function_declaration#Left function getSm4EncryptProperties AST#parameter_list#Left ( AST#parameter#Left properties : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left HuksProperties [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left index = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left properties AST#expression#Right [ AST#expression#Left AST#update_expression#Left AST#expression#Left index AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left tag AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left huks AST#expression#Right . HuksTag AST#member_expression#Right AST#expression#Right . HUKS_TAG_ALGORITHM AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left huks AST#expression#Right . HuksKeyAlg AST#member_expression#Right AST#expression#Right . HUKS_ALG_SM4 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left properties AST#expression#Right [ AST#expression#Left AST#update_expression#Left AST#expression#Left index AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left tag AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left huks AST#expression#Right . HuksTag AST#member_expression#Right AST#expression#Right . HUKS_TAG_KEY_SIZE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left huks AST#expression#Right . HuksKeySize AST#member_expression#Right AST#expression#Right . HUKS_SM4_KEY_SIZE_128 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , } AST#object_literal#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left properties AST#expression#Right [ AST#expression#Left AST#update_expression#Left AST#expression#Left index AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left tag AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left huks AST#expression#Right . HuksTag AST#member_expression#Right AST#expression#Right . HUKS_TAG_PURPOSE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left huks AST#expression#Right . HuksKeyPurpose AST#member_expression#Right AST#expression#Right . HUKS_KEY_PURPOSE_ENCRYPT AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left properties AST#expression#Right [ AST#expression#Left AST#update_expression#Left AST#expression#Left index AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left tag AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left huks AST#expression#Right . HuksTag AST#member_expression#Right AST#expression#Right . HUKS_TAG_BLOCK_MODE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left huks AST#expression#Right . HuksCipherMode AST#member_expression#Right AST#expression#Right . HUKS_MODE_CBC AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left properties AST#expression#Right [ AST#expression#Left AST#update_expression#Left AST#expression#Left index AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left tag AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left huks AST#expression#Right . HuksTag AST#member_expression#Right AST#expression#Right . HUKS_TAG_PADDING AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left huks AST#expression#Right . HuksKeyPadding AST#member_expression#Right AST#expression#Right . HUKS_PADDING_PKCS7 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left properties AST#expression#Right [ AST#expression#Left AST#update_expression#Left AST#expression#Left index AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left tag AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left huks AST#expression#Right . HuksTag AST#member_expression#Right AST#expression#Right . HUKS_TAG_IV AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left stringToUint8Array AST#expression#Right AST#argument_list#Left ( AST#expression#Left IV AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
|
function getSm4EncryptProperties(properties: HuksProperties[]): void {
let index = 0;
properties[index++] = {
tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
value: huks.HuksKeyAlg.HUKS_ALG_SM4
};
properties[index++] = {
tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128,
};
properties[index++] = {
tag: huks.HuksTag.HUKS_TAG_PURPOSE,
value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT
};
properties[index++] = {
tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
value: huks.HuksCipherMode.HUKS_MODE_CBC
};
properties[index++] = {
tag: huks.HuksTag.HUKS_TAG_PADDING,
value: huks.HuksKeyPadding.HUKS_PADDING_PKCS7
};
properties[index++] = {
tag: huks.HuksTag.HUKS_TAG_IV,
value: stringToUint8Array(IV)
};
return;
}
|
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/HarmonyOS_NEXT/Security/Huks/entry/src/main/ets/model/HuksModel.ets#L68-L95
|
34773698b8ace6d848b155553d59b78c0b6402b7
|
gitee
|
openharmony/interface_sdk-js
|
c349adc73e2ec1f61f6fca489b5af059e3ed6999
|
api/@ohos.file.fs.d.ets
|
arkts
|
Event Listening.
@interface WatchEvent
@syscap SystemCapability.FileManagement.File.FileIO
@since 20
|
export interface WatchEvent {
/**
* File name.
*
* @type { string }
* @readonly
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 20
*/
readonly fileName: string;
/**
* Event happened.
*
* @type { number }
* @readonly
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 20
*/
readonly event: number;
/**
* Associated rename event.
*
* @type { number }
* @readonly
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 20
*/
readonly cookie: number;
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface WatchEvent AST#object_type#Left { /**
* File name.
*
* @type { string }
* @readonly
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 20
*/ AST#type_member#Left readonly AST#ERROR#Left fileName AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /**
* Event happened.
*
* @type { number }
* @readonly
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 20
*/ AST#type_member#Left readonly AST#ERROR#Left event AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /**
* Associated rename event.
*
* @type { number }
* @readonly
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 20
*/ AST#type_member#Left readonly AST#ERROR#Left cookie AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
|
export interface WatchEvent {
readonly fileName: string;
readonly event: number;
readonly cookie: number;
}
|
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.file.fs.d.ets#L4176-L4206
|
aa725bd6f0a3727ea2bda23cd0caddfa6d39a01f
|
gitee
|
|
huangwei021230/HarmonyFlow.git
|
427f918873b0c9efdc975ff4889726b1bfccc546
|
entry/src/main/ets/ime/text/Key/KeyCode.ets
|
arkts
|
,
|
export const SPACE = 32;
|
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left SPACE = AST#expression#Left 32 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
|
export const SPACE = 32;
|
https://github.com/huangwei021230/HarmonyFlow.git/blob/427f918873b0c9efdc975ff4889726b1bfccc546/entry/src/main/ets/ime/text/Key/KeyCode.ets#L16-L16
|
5e3db6b4457faf502dde8b084609c70691367c3a
|
github
|
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
ef_ui/src/main/ets/ui/select/Cascade.ets
|
arkts
|
reset
|
重置数据
|
private reset() {
this.show = !this.show;
this.showCity = false;
this.showArea = false;
this.selectData = new cascadeCity();
this.currentList = new Array();
this.selectIndex = 0;
this.currentList = this.getProvinceData();
}
|
AST#method_declaration#Left private reset AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . show AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . show AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showCity AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showArea AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectData AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left cascadeCity AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentList AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectIndex AST#member_expression#Right = AST#expression#Left 0 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentList AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getProvinceData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
private reset() {
this.show = !this.show;
this.showCity = false;
this.showArea = false;
this.selectData = new cascadeCity();
this.currentList = new Array();
this.selectIndex = 0;
this.currentList = this.getProvinceData();
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_ui/src/main/ets/ui/select/Cascade.ets#L134-L142
|
4ee1defa8aafa319675642fd76ed7825c8b7db0f
|
gitee
|
LiuAnclouds/Harmony-ArkTS-App.git
|
2119ce333927599b81a31081bc913e1416837308
|
WeatherMind/entry/src/main/ets/pages/ChooseCity.ets
|
arkts
|
buildConfirmDialog
|
构建确认弹窗
|
@Builder
buildConfirmDialog() {
Column() {
Column() {
// 顶部装饰
Row() {
Text('✨')
.fontSize(24)
}
.width(60)
.height(60)
.backgroundColor('#E8F4FD')
.borderRadius(30)
.justifyContent(FlexAlign.Center)
.margin({ bottom: 20 })
Text('选择城市')
.fontSize(20)
.fontWeight(FontWeight.Bold)
.fontColor('#333333')
.margin({ bottom: 8 })
Text(`即将为您切换到`)
.fontSize(14)
.fontColor('#666666')
.margin({ bottom: 4 })
Text(`📍 ${this.selectedCity}`)
.fontSize(18)
.fontColor('#4A90E2')
.fontWeight(FontWeight.Bold)
.margin({ bottom: 32 })
Row() {
Button('取消')
.width(110)
.height(48)
.fontSize(16)
.fontColor('#666666')
.backgroundColor('#F8F9FA')
.borderRadius(24)
.border({ width: 1, color: '#E9ECEF' })
.onClick(() => {
this.showConfirmDialog = false;
// 取消后保持在搜索页面
})
Blank()
Button() {
Row() {
Text('🌤️')
.fontSize(16)
.margin({ right: 6 })
Text('确认选择')
.fontSize(16)
.fontWeight(FontWeight.Medium)
}
}
.width(130)
.height(48)
.fontColor('#FFFFFF')
.linearGradient({
direction: GradientDirection.Right,
colors: [['#4A90E2', 0.0], ['#7B68EE', 1.0]]
})
.borderRadius(24)
.shadow({
radius: 8,
color: '#304A90E2',
offsetX: 0,
offsetY: 4
})
.onClick(() => {
this.showConfirmDialog = false;
this.selectCity(this.selectedCity);
// 确认后会跳转到天气页面,不需要关闭搜索页面
})
}
.width('100%')
}
.width(320)
.padding(32)
.backgroundColor('#FFFFFF')
.borderRadius(24)
.shadow({
radius: 25,
color: '#30000000',
offsetX: 0,
offsetY: 12
})
}
.width('100%')
.height('100%')
.backgroundColor('rgba(0, 0, 0, 0.5)')
.justifyContent(FlexAlign.Center)
.onClick(() => {
this.showConfirmDialog = false;
// 点击背景关闭对话框,保持在搜索页面
})
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildConfirmDialog AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { // 顶部装饰 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '✨' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#E8F4FD' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 20 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '选择城市' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#333333' AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 8 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#template_literal#Left ` 即将为您切换到 ` AST#template_literal#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#666666' AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 4 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#template_literal#Left ` 📍 AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedCity AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 18 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#4A90E2' AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 32 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left '取消' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 110 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 48 AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#666666' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#F8F9FA' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Left . border ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left 1 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left '#E9ECEF' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showConfirmDialog AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 取消后保持在搜索页面 } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Blank ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '🌤️' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 6 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '确认选择' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 130 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 48 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#FFFFFF' AST#expression#Right ) AST#modifier_chain_expression#Left . linearGradient ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left direction AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left GradientDirection AST#expression#Right . Right AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left colors AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#array_literal#Left [ AST#expression#Left '#4A90E2' AST#expression#Right , AST#expression#Left 0.0 AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left '#7B68EE' AST#expression#Right , AST#expression#Left 1.0 AST#expression#Right ] AST#array_literal#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Left . shadow ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left 8 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left '#304A90E2' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetX AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetY AST#property_name#Right : AST#expression#Left 4 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showConfirmDialog AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectCity AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedCity AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 确认后会跳转到天气页面,不需要关闭搜索页面 } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 320 AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left 32 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#FFFFFF' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Left . shadow ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left 25 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left '#30000000' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetX AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetY AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 'rgba(0, 0, 0, 0.5)' AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showConfirmDialog AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 点击背景关闭对话框,保持在搜索页面 } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
buildConfirmDialog() {
Column() {
Column() {
Row() {
Text('✨')
.fontSize(24)
}
.width(60)
.height(60)
.backgroundColor('#E8F4FD')
.borderRadius(30)
.justifyContent(FlexAlign.Center)
.margin({ bottom: 20 })
Text('选择城市')
.fontSize(20)
.fontWeight(FontWeight.Bold)
.fontColor('#333333')
.margin({ bottom: 8 })
Text(`即将为您切换到`)
.fontSize(14)
.fontColor('#666666')
.margin({ bottom: 4 })
Text(`📍 ${this.selectedCity}`)
.fontSize(18)
.fontColor('#4A90E2')
.fontWeight(FontWeight.Bold)
.margin({ bottom: 32 })
Row() {
Button('取消')
.width(110)
.height(48)
.fontSize(16)
.fontColor('#666666')
.backgroundColor('#F8F9FA')
.borderRadius(24)
.border({ width: 1, color: '#E9ECEF' })
.onClick(() => {
this.showConfirmDialog = false;
})
Blank()
Button() {
Row() {
Text('🌤️')
.fontSize(16)
.margin({ right: 6 })
Text('确认选择')
.fontSize(16)
.fontWeight(FontWeight.Medium)
}
}
.width(130)
.height(48)
.fontColor('#FFFFFF')
.linearGradient({
direction: GradientDirection.Right,
colors: [['#4A90E2', 0.0], ['#7B68EE', 1.0]]
})
.borderRadius(24)
.shadow({
radius: 8,
color: '#304A90E2',
offsetX: 0,
offsetY: 4
})
.onClick(() => {
this.showConfirmDialog = false;
this.selectCity(this.selectedCity);
})
}
.width('100%')
}
.width(320)
.padding(32)
.backgroundColor('#FFFFFF')
.borderRadius(24)
.shadow({
radius: 25,
color: '#30000000',
offsetX: 0,
offsetY: 12
})
}
.width('100%')
.height('100%')
.backgroundColor('rgba(0, 0, 0, 0.5)')
.justifyContent(FlexAlign.Center)
.onClick(() => {
this.showConfirmDialog = false;
})
}
|
https://github.com/LiuAnclouds/Harmony-ArkTS-App.git/blob/2119ce333927599b81a31081bc913e1416837308/WeatherMind/entry/src/main/ets/pages/ChooseCity.ets#L960-L1060
|
a6b521a92227c9dfe4b03cfabb3ab860b2867495
|
github
|
openharmony/xts_acts
|
5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686
|
arkui/ace_ets_module_ui/ace_ets_module_navigation/ace_ets_module_navigation_api12/entry/src/main/ets/MainAbility/pages/MultiNavigation/mainpage/NavAttributeModifier.ets
|
arkts
|
NavWidthRangeAttrModifier
|
Copyright (C) 2024 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
@Observed
export class NavWidthRangeAttrModifier implements AttributeModifier<NavigationAttribute> {
isApplicationSet: boolean = false;
minHomeWidth: Percentage = '50%';
maxHomeWidth: Percentage = '50%';
applyNormalAttribute(instance: NavigationAttribute): void {
if (this.isApplicationSet) {
instance.navBarWidthRange([this.minHomeWidth, this.maxHomeWidth]);
}
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Observed AST#decorator#Right export class NavWidthRangeAttrModifier AST#implements_clause#Left implements AST#generic_type#Left AttributeModifier AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left NavigationAttribute AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#implements_clause#Right AST#class_body#Left { AST#property_declaration#Left isApplicationSet : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left minHomeWidth : AST#type_annotation#Left AST#primary_type#Left Percentage AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '50%' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left maxHomeWidth : AST#type_annotation#Left AST#primary_type#Left Percentage AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '50%' AST#expression#Right ; AST#property_declaration#Right AST#method_declaration#Left applyNormalAttribute AST#parameter_list#Left ( AST#parameter#Left instance : AST#type_annotation#Left AST#primary_type#Left NavigationAttribute AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isApplicationSet AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left instance AST#expression#Right . navBarWidthRange AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . minHomeWidth AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . maxHomeWidth AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#class_body#Right AST#decorated_export_declaration#Right
|
@Observed
export class NavWidthRangeAttrModifier implements AttributeModifier<NavigationAttribute> {
isApplicationSet: boolean = false;
minHomeWidth: Percentage = '50%';
maxHomeWidth: Percentage = '50%';
applyNormalAttribute(instance: NavigationAttribute): void {
if (this.isApplicationSet) {
instance.navBarWidthRange([this.minHomeWidth, this.maxHomeWidth]);
}
}
}
|
https://github.com/openharmony/xts_acts/blob/5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686/arkui/ace_ets_module_ui/ace_ets_module_navigation/ace_ets_module_navigation_api12/entry/src/main/ets/MainAbility/pages/MultiNavigation/mainpage/NavAttributeModifier.ets#L16-L27
|
93129515682ed0be420092a701b92272fcaca83a
|
gitee
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
LoadPerformanceInWeb/entry/src/main/ets/pages/ByteCodeCache.ets
|
arkts
|
aboutToAppear
|
[Start about_to_appear]
|
aboutToAppear(): void {
try {
webview.WebviewController.customizeSchemes([this.scheme1])
} catch (error) {
let e: business_error.BusinessError = error as business_error.BusinessError;
console.error(`ErrorCode: ${e.code}, Message: ${e.message}`);
}
}
|
AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left webview AST#expression#Right . WebviewController AST#member_expression#Right AST#expression#Right . customizeSchemes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scheme1 AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left e : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left business_error . BusinessError AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left business_error . BusinessError AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` ErrorCode: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left e AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , Message: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left e AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
aboutToAppear(): void {
try {
webview.WebviewController.customizeSchemes([this.scheme1])
} catch (error) {
let e: business_error.BusinessError = error as business_error.BusinessError;
console.error(`ErrorCode: ${e.code}, Message: ${e.message}`);
}
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/LoadPerformanceInWeb/entry/src/main/ets/pages/ByteCodeCache.ets#L14-L21
|
de03bf9754f9e60ba193d5018e6b62639d65dbf0
|
gitee
|
Duke_Bit/ElfRefresh
|
56faf5431c1643ec5ae227dc854a31b391778b2c
|
library/src/main/ets/model/ElfRefreshHeader.ets
|
arkts
|
ElfRefreshHeader
|
@author duke
@description 下拉刷新控制器
|
@ObservedV2
export class ElfRefreshHeader {
/**
* 最大位移量
*/
maxTranslate: number
/**
* 容器高度
*/
@Trace
height: number
/**
* 当前状态
*/
@Trace
state: RefreshState
/**
* 下拉过程中的百分比
*/
@Trace
percent: number
/**
* 下拉过程中的位移量
*/
@Trace
offset: number
/**
* 内部API请勿外部调用
* 设置位移量
* @param offset
*/
setOffset(offset: number) {
this.offset = offset
if (this.height != 0) {
this.percent = this.offset / this.height
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ ObservedV2 AST#decorator#Right export class ElfRefreshHeader AST#ERROR#Left { /**
* 最大位移量
*/ AST#property_declaration#Left maxTranslate : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right /**
* 容器高度
*/ AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Trace AST#decorator#Right height : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right /**
* 当前状态
*/ AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Trace AST#decorator#Right state : AST#type_annotation#Left AST#primary_type#Left RefreshState AST#primary_type#Right AST#type_annotation#Right /**
* 下拉过程中的百分比
*/ AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Trace AST#decorator#Right percent : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right /**
* 下拉过程中的位移量
*/ AST#property_declaration#Right AST#decorator#Left @ Trace AST#decorator#Right offset : AST#ERROR#Left number /**
* 内部API请勿外部调用
* 设置位移量
* @param offset
*/ setOffset AST#ERROR#Right AST#parameter_list#Left ( AST#parameter#Left offset : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#ERROR#Right AST#class_body#Left { AST#ERROR#Left this AST#ERROR#Left . of fset AST#ERROR#Right = AST#ERROR#Left AST#expression#Left AST#call_expression#Left AST#expression#Left offset AST#expression#Right AST#ERROR#Left if AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . height AST#member_expression#Right AST#expression#Right != AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Right AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left this AST#property_assignment#Right AST#object_literal#Right AST#expression#Right . percent AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . offset AST#member_expression#Right AST#expression#Right / AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right } AST#ERROR#Right } AST#class_body#Right AST#decorated_export_declaration#Right
|
@ObservedV2
export class ElfRefreshHeader {
maxTranslate: number
@Trace
height: number
@Trace
state: RefreshState
@Trace
percent: number
@Trace
offset: number
setOffset(offset: number) {
this.offset = offset
if (this.height != 0) {
this.percent = this.offset / this.height
}
}
|
https://github.com/Duke_Bit/ElfRefresh/blob/56faf5431c1643ec5ae227dc854a31b391778b2c/library/src/main/ets/model/ElfRefreshHeader.ets#L7-L44
|
ebf832db971d98fa6ece71d4af09a3433fea768f
|
gitee
|
Rayawa/dashboard.git
|
9107efe7fb69a58d799a378b79ea8ffa4041cec8
|
entry/src/main/ets/common/SettingsStorage.ets
|
arkts
|
清除所有设置(恢复默认)
|
export async function resetAllSettings(): Promise<void> {
const settings = getSettingsInstance();
await settings.set("defaultSiteT", false);
await settings.set("vibrationON", true);
await settings.set("holdCheckON", true);
await settings.set("buttonPositionRIGHT", false);
await settings.set("themeColor", "blue");
await setTDev(false);
}
|
AST#export_declaration#Left export AST#function_declaration#Left async function resetAllSettings AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left settings = AST#expression#Left AST#call_expression#Left AST#expression#Left getSettingsInstance AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left settings AST#expression#Right AST#await_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "defaultSiteT" AST#expression#Right , AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left settings AST#expression#Right AST#await_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "vibrationON" AST#expression#Right , AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left settings AST#expression#Right AST#await_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "holdCheckON" AST#expression#Right , AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left settings AST#expression#Right AST#await_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "buttonPositionRIGHT" AST#expression#Right , AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left settings AST#expression#Right AST#await_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "themeColor" AST#expression#Right , AST#expression#Left "blue" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left setTDev AST#expression#Right AST#await_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export async function resetAllSettings(): Promise<void> {
const settings = getSettingsInstance();
await settings.set("defaultSiteT", false);
await settings.set("vibrationON", true);
await settings.set("holdCheckON", true);
await settings.set("buttonPositionRIGHT", false);
await settings.set("themeColor", "blue");
await setTDev(false);
}
|
https://github.com/Rayawa/dashboard.git/blob/9107efe7fb69a58d799a378b79ea8ffa4041cec8/entry/src/main/ets/common/SettingsStorage.ets#L95-L103
|
edb2ddfc60fdfd60c3d37832f35649aec6a9a29d
|
github
|
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/ObjectUtil.ets
|
arkts
|
deepCopy
|
深度拷贝
@param obj 被拷贝对象
@returns
|
static deepCopy<T>(obj: T): T {
return ObjectUtils.deepCopy<T>(obj);
}
|
AST#method_declaration#Left static deepCopy AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left obj : AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ObjectUtils AST#expression#Right . deepCopy AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left obj AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static deepCopy<T>(obj: T): T {
return ObjectUtils.deepCopy<T>(obj);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/ObjectUtil.ets#L116-L118
|
2b29fc6e041c68b4bc15032e475c2e817715146d
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/ai/AIAssistantService.ets
|
arkts
|
消息反应接口
|
export interface MessageReaction {
emoji: string;
count: number;
users: string[];
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface MessageReaction AST#object_type#Left { AST#type_member#Left emoji : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left count : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left users : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
|
export interface MessageReaction {
emoji: string;
count: number;
users: string[];
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/ai/AIAssistantService.ets#L80-L84
|
65d23b9091d20b5b1b9997e8537c524e4fc8e367
|
github
|
|
lulululing/calendar.git
|
c87b7e3ffb50a34941a5db50afe6a513c113bd0b
|
entry/src/main/ets/manager/SubscriptionManager.ets
|
arkts
|
deleteSubscription
|
删除订阅
|
deleteSubscription(id: string): boolean {
const result = this.subscriptions.delete(id)
if (result) {
this.saveSubscriptions()
console.info('✅ 删除订阅成功:', id)
}
return result
}
|
AST#method_declaration#Left deleteSubscription AST#parameter_list#Left ( AST#parameter#Left id : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left result = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . subscriptions AST#member_expression#Right AST#expression#Right . delete AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left id AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left result AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . saveSubscriptions AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '✅ 删除订阅成功:' AST#expression#Right , AST#expression#Left id AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
deleteSubscription(id: string): boolean {
const result = this.subscriptions.delete(id)
if (result) {
this.saveSubscriptions()
console.info('✅ 删除订阅成功:', id)
}
return result
}
|
https://github.com/lulululing/calendar.git/blob/c87b7e3ffb50a34941a5db50afe6a513c113bd0b/entry/src/main/ets/manager/SubscriptionManager.ets#L71-L78
|
e0e80dcdb62d0c04536afe32f6507b5f63fb61ce
|
github
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/ai/GreetingGenerationService.ets
|
arkts
|
getRelationName
|
以下是各种个性化替换的辅助方法
|
private getRelationName(contact: Contact): string {
const prefix = this.getRelationText(contact.relation);
return `${prefix}${contact.name}`;
}
|
AST#method_declaration#Left private getRelationName AST#parameter_list#Left ( AST#parameter#Left contact : AST#type_annotation#Left AST#primary_type#Left Contact AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left prefix = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getRelationText AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left contact AST#expression#Right . relation AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left prefix AST#expression#Right } AST#template_substitution#Right AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left contact AST#expression#Right . name AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private getRelationName(contact: Contact): string {
const prefix = this.getRelationText(contact.relation);
return `${prefix}${contact.name}`;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/ai/GreetingGenerationService.ets#L583-L586
|
9ab88ab2bed549c8aafb83545c74e9f64dc90ae4
|
github
|
zl3624/harmonyos_network_samples
|
b8664f8bf6ef5c5a60830fe616c6807e83c21f96
|
code/rcp/OpenAIWithRCP/entry/src/main/ets/pages/OpenAI.ets
|
arkts
|
AI正常返回的信息
|
export class ChatResponse {
public choices: Array<Choice> = new Array()
public object: string = ""
public usage: Usage = new Usage(0, 0, 0)
public created: number = 0
public system_fingerprint: string = ""
public model: string = ""
public id: string = ""
constructor
|
AST#export_declaration#Left export AST#ERROR#Left class ChatResponse { AST#property_declaration#Left public choices : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Choice AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left public object : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left public usage : AST#type_annotation#Left AST#primary_type#Left Usage AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Usage AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left 0 AST#expression#Right , AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left public created : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left public system_fingerprint : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left public model : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "" AST#expression#Right AST#property_declaration#Right public id : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "" AST#expression#Right AST#ERROR#Right AST#variable_declaration#Left const AST#variable_declarator#Left ructor AST#variable_declarator#Right AST#variable_declaration#Right AST#export_declaration#Right
|
export class ChatResponse {
public choices: Array<Choice> = new Array()
public object: string = ""
public usage: Usage = new Usage(0, 0, 0)
public created: number = 0
public system_fingerprint: string = ""
public model: string = ""
public id: string = ""
constructor
|
https://github.com/zl3624/harmonyos_network_samples/blob/b8664f8bf6ef5c5a60830fe616c6807e83c21f96/code/rcp/OpenAIWithRCP/entry/src/main/ets/pages/OpenAI.ets#L49-L58
|
67b0af9537d1f045fb494b7f9a2d9c5673614075
|
gitee
|
|
kico0909/crazy_miner.git
|
13eae3ac4d8ca11ecf2c97b375f82f24ab7919b9
|
entry/src/main/ets/common/game/core/world.ets
|
arkts
|
calcPerStepVal
|
计算一次挖掘的步长值
|
function calcPerStepVal(world: WORLD): number {
/*
* 计算一次挖掘的步长: 用户等级 + 地图级别修正 + 用户幸运修正 + 当前矿坑深度修正 +
* */
// 基础进度
const base = utils.getRandomInt(90, 100) / 100
// 等级 修正
const level = 0
// 随机修正
const random = utils.getRandomInt(1,3) / 10
// 地图修正
const mapIndex = 0
// 幸运修正
const randomInt = utils.getRandomInt(0, 100)
const luck = randomInt < world.player.attr.luck ? utils.getRandomInt(0, 2) : 0
// 深度修正
const deep = 0
// 计算结果
let perStep = base + level + mapIndex + luck + deep + random
// 修正结果边界
perStep = perStep < 1 ? 1 : perStep // 修正最小值边界
perStep = perStep > 100 ? 100 : perStep // 修正最大值边界
return perStep
}
|
AST#function_declaration#Left function calcPerStepVal AST#parameter_list#Left ( AST#parameter#Left world : AST#type_annotation#Left AST#primary_type#Left WORLD AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { /*
* 计算一次挖掘的步长: 用户等级 + 地图级别修正 + 用户幸运修正 + 当前矿坑深度修正 +
* */ // 基础进度 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left base = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left utils AST#expression#Right . getRandomInt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 90 AST#expression#Right , AST#expression#Left 100 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right / AST#expression#Left 100 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right // 等级 修正 AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left level = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right // 随机修正 AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left random = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left utils AST#expression#Right . getRandomInt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1 AST#expression#Right , AST#expression#Left 3 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right / AST#expression#Left 10 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right // 地图修正 AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left mapIndex = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right // 幸运修正 AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left randomInt = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left utils AST#expression#Right . getRandomInt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left 100 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left luck = AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left randomInt AST#expression#Right < AST#expression#Left world AST#expression#Right AST#binary_expression#Right AST#expression#Right . player AST#member_expression#Right AST#expression#Right . attr AST#member_expression#Right AST#expression#Right . luck AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left utils AST#expression#Right . getRandomInt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left 2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left 0 AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#variable_declarator#Right // 深度修正 AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left deep = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right // 计算结果 AST#variable_declaration#Right AST#statement#Right AST#ERROR#Left let perStep = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left base AST#expression#Right + AST#expression#Left level AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left mapIndex AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left luck AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left deep AST#expression#Right AST#binary_expression#Right AST#expression#Right + random // 修正结果边界 AST#ERROR#Left perStep AST#ERROR#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left perStep AST#expression#Right < AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 1 AST#expression#Right : AST#assignment_expression#Left perStep // 修正最小值边界 AST#ERROR#Left perStep AST#ERROR#Right = AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left perStep AST#expression#Right > AST#expression#Left 100 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 100 AST#expression#Right : AST#expression#Left perStep AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#assignment_expression#Right AST#ERROR#Right // 修正最大值边界 AST#statement#Left AST#return_statement#Left return AST#expression#Left perStep AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
|
function calcPerStepVal(world: WORLD): number {
const base = utils.getRandomInt(90, 100) / 100
const level = 0
const random = utils.getRandomInt(1,3) / 10
const mapIndex = 0
const randomInt = utils.getRandomInt(0, 100)
const luck = randomInt < world.player.attr.luck ? utils.getRandomInt(0, 2) : 0
const deep = 0
let perStep = base + level + mapIndex + luck + deep + random
perStep = perStep < 1 ? 1 : perStep
perStep = perStep > 100 ? 100 : perStep
return perStep
}
|
https://github.com/kico0909/crazy_miner.git/blob/13eae3ac4d8ca11ecf2c97b375f82f24ab7919b9/entry/src/main/ets/common/game/core/world.ets#L91-L114
|
a32fd9a0f7a601172db5c6d9af30333700e3594c
|
github
|
jjjjjjava/ffmpeg_tools.git
|
6c73f7540bc7ca3f0d5b3edd7a6c10cb84a26161
|
src/main/ets/ffmpeg/FFmpegFactory.ets
|
arkts
|
concat
|
视频拼接
|
public static concat(inputFiles: string[], output: string): string[] {
const cmd: string[] = ['ffmpeg', '-c:v', FFmpegFactory.HW_CODEC];
for (let i = 0; i < inputFiles.length; i++) {
cmd.push('-i', inputFiles[i]);
}
let filterInputs = '';
for (let i = 0; i < inputFiles.length; i++) {
filterInputs += `[${i}:v][${i}:a]`;
}
cmd.push(
'-filter_complex', `${filterInputs}concat=n=${inputFiles.length}:v=1:a=1[outv][outa]`,
'-map', '[outv]',
'-map', '[outa]',
'-c:v', FFmpegFactory.HW_CODEC,
'-c:a', 'aac',
'-y', output
);
return cmd;
}
|
AST#method_declaration#Left public static concat AST#parameter_list#Left ( AST#parameter#Left inputFiles : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left output : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left cmd : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'ffmpeg' AST#expression#Right , AST#expression#Left '-c:v' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left FFmpegFactory AST#expression#Right . HW_CODEC AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left inputFiles AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cmd AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '-i' AST#expression#Right , AST#expression#Left AST#subscript_expression#Left AST#expression#Left inputFiles AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left filterInputs = AST#expression#Left '' AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left inputFiles AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left filterInputs += AST#expression#Left AST#template_literal#Left ` [ AST#template_substitution#Left $ { AST#expression#Left i AST#expression#Right } AST#template_substitution#Right :v][ AST#template_substitution#Left $ { AST#expression#Left i AST#expression#Right } AST#template_substitution#Right :a] ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cmd AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '-filter_complex' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left filterInputs AST#expression#Right } AST#template_substitution#Right concat=n= AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left inputFiles AST#expression#Right . length AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right :v=1:a=1[outv][outa] ` AST#template_literal#Right AST#expression#Right , AST#expression#Left '-map' AST#expression#Right , AST#expression#Left '[outv]' AST#expression#Right , AST#expression#Left '-map' AST#expression#Right , AST#expression#Left '[outa]' AST#expression#Right , AST#expression#Left '-c:v' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left FFmpegFactory AST#expression#Right . HW_CODEC AST#member_expression#Right AST#expression#Right , AST#expression#Left '-c:a' AST#expression#Right , AST#expression#Left 'aac' AST#expression#Right , AST#expression#Left '-y' AST#expression#Right , AST#expression#Left output AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left cmd AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public static concat(inputFiles: string[], output: string): string[] {
const cmd: string[] = ['ffmpeg', '-c:v', FFmpegFactory.HW_CODEC];
for (let i = 0; i < inputFiles.length; i++) {
cmd.push('-i', inputFiles[i]);
}
let filterInputs = '';
for (let i = 0; i < inputFiles.length; i++) {
filterInputs += `[${i}:v][${i}:a]`;
}
cmd.push(
'-filter_complex', `${filterInputs}concat=n=${inputFiles.length}:v=1:a=1[outv][outa]`,
'-map', '[outv]',
'-map', '[outa]',
'-c:v', FFmpegFactory.HW_CODEC,
'-c:a', 'aac',
'-y', output
);
return cmd;
}
|
https://github.com/jjjjjjava/ffmpeg_tools.git/blob/6c73f7540bc7ca3f0d5b3edd7a6c10cb84a26161/src/main/ets/ffmpeg/FFmpegFactory.ets#L172-L193
|
a325263a96259efefccf78389c5934dd9ebafb6c
|
github
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
ef_core/src/main/ets/core/util/IdCardUtil.ets
|
arkts
|
getProvinceCodeByIdCard
|
根据身份编号获取户籍省份编码,只支持15或18位身份证号码
@param idCard 身份编码
@return 省份编码
|
static getProvinceCodeByIdCard(idCard: string): OutDTO<string> {
if (IdCardUtil.PROVINCE_CODES.size == 0) {
IdCardUtil.init();
}
let len = idCard.length;
if (len == IdCardUtil.CHINA_ID_MIN_LENGTH || len == IdCardUtil.CHINA_ID_MAX_LENGTH) {
let province = IdCardUtil.PROVINCE_CODES.get(idCard.substring(0, 2) + "0000");
if (!province) {
return OutDTO.Error("根据身份证号获取省份信息错误");
}
return OutDTO.OKByDataRow(province.toString(), idCard.substring(0, 2) + "0000");
} else {
return OutDTO.Error("身份证长度不正确");
}
}
|
AST#method_declaration#Left static getProvinceCodeByIdCard AST#parameter_list#Left ( AST#parameter#Left idCard : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left OutDTO AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left IdCardUtil AST#expression#Right . PROVINCE_CODES AST#member_expression#Right AST#expression#Right . size AST#member_expression#Right AST#expression#Right == AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left IdCardUtil AST#expression#Right . init AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left let AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left len = AST#expression#Left AST#member_expression#Left AST#expression#Left idCard AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left len AST#expression#Right == AST#expression#Left IdCardUtil AST#expression#Right AST#binary_expression#Right AST#expression#Right . CHINA_ID_MIN_LENGTH AST#member_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left len AST#expression#Right == AST#expression#Left IdCardUtil AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . CHINA_ID_MAX_LENGTH AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left let AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left province = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left IdCardUtil AST#expression#Right . PROVINCE_CODES AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left idCard AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left 2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left "0000" AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left province AST#expression#Right AST#unary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left OutDTO AST#expression#Right . Error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "根据身份证号获取省份信息错误" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left OutDTO AST#expression#Right . OKByDataRow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left province AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left idCard AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left 2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left "0000" AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } else { AST#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left OutDTO AST#expression#Right . Error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "身份证长度不正确" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
static getProvinceCodeByIdCard(idCard: string): OutDTO<string> {
if (IdCardUtil.PROVINCE_CODES.size == 0) {
IdCardUtil.init();
}
let len = idCard.length;
if (len == IdCardUtil.CHINA_ID_MIN_LENGTH || len == IdCardUtil.CHINA_ID_MAX_LENGTH) {
let province = IdCardUtil.PROVINCE_CODES.get(idCard.substring(0, 2) + "0000");
if (!province) {
return OutDTO.Error("根据身份证号获取省份信息错误");
}
return OutDTO.OKByDataRow(province.toString(), idCard.substring(0, 2) + "0000");
} else {
return OutDTO.Error("身份证长度不正确");
}
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_core/src/main/ets/core/util/IdCardUtil.ets#L235-L249
|
965e5788cb4400ba8acf26952a0c2b42cdd3334d
|
gitee
|
Joker-x-dev/CoolMallArkTS.git
|
9f3fabf89fb277692cb82daf734c220c7282919c
|
core/database/src/main/ets/datasource/cart/CartLocalDataSourceImpl.ets
|
arkts
|
toEntity
|
将领域模型转换为数据库实体
@param {Cart} cart 购物车领域模型
@returns {CartEntity} 数据库实体
|
private toEntity(cart: Cart): CartEntity {
const entity: CartEntity = new CartEntity();
entity.goodsId = cart.goodsId;
entity.goodsName = cart.goodsName;
entity.goodsMainPic = cart.goodsMainPic;
entity.specJson = JSON.stringify(cart.spec ?? []);
return entity;
}
|
AST#method_declaration#Left private toEntity AST#parameter_list#Left ( AST#parameter#Left cart : AST#type_annotation#Left AST#primary_type#Left Cart AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left CartEntity AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left entity : AST#type_annotation#Left AST#primary_type#Left CartEntity AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left CartEntity AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left entity AST#expression#Right . goodsId AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . goodsId AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left entity AST#expression#Right . goodsName AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . goodsName AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left entity AST#expression#Right . goodsMainPic AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . goodsMainPic AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left entity AST#expression#Right . specJson AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . spec AST#member_expression#Right AST#expression#Right ?? AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left entity AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private toEntity(cart: Cart): CartEntity {
const entity: CartEntity = new CartEntity();
entity.goodsId = cart.goodsId;
entity.goodsName = cart.goodsName;
entity.goodsMainPic = cart.goodsMainPic;
entity.specJson = JSON.stringify(cart.spec ?? []);
return entity;
}
|
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/database/src/main/ets/datasource/cart/CartLocalDataSourceImpl.ets#L166-L173
|
3a2de14874b6d96cc97576f3bf0d6b2bbdef2354
|
github
|
LiuAnclouds/Harmony-ArkTS-App.git
|
2119ce333927599b81a31081bc913e1416837308
|
WeatherMind/entry/src/main/ets/pages/ChooseCity.ets
|
arkts
|
getWeatherByLocation
|
根据位置获取天气
|
private async getWeatherByLocation(latitude: number, longitude: number) {
try {
let httpRequest = http.createHttp();
let response = await httpRequest.request(Config.API.WEATHER_BY_LOCATION, {
method: http.RequestMethod.POST,
extraData: JSON.stringify({
latitude: latitude,
longitude: longitude
}),
header: {
"Content-Type": "application/json"
}
});
let result = JSON.parse(response.result as string) as LocationWeatherResponse;
if (result.code === 0) {
this.currentLocation = result.data.city_name;
this.selectedCity = this.currentLocation;
promptAction.showToast({ message: `已定位到: ${this.currentLocation}` });
// 跳转到天气页面查看定位城市的天气
router.pushUrl({
url: 'pages/CityWeather',
params: {
cityName: this.currentLocation
}
});
}
} catch (error) {
console.error('获取位置天气失败:', error);
promptAction.showToast({ message: '获取位置天气失败' });
}
}
|
AST#method_declaration#Left private async getWeatherByLocation AST#parameter_list#Left ( AST#parameter#Left latitude : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left longitude : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left httpRequest = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . createHttp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left response = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left httpRequest AST#expression#Right AST#await_expression#Right AST#expression#Right . request AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Config AST#expression#Right . API AST#member_expression#Right AST#expression#Right . WEATHER_BY_LOCATION AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left method AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . RequestMethod AST#member_expression#Right AST#expression#Right . POST AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left extraData AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left latitude AST#property_name#Right : AST#expression#Left latitude AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left longitude AST#property_name#Right : AST#expression#Left longitude AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left header AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left "Content-Type" AST#property_name#Right : AST#expression#Left "application/json" AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left result = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . result AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left LocationWeatherResponse AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . code AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentLocation AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . data AST#member_expression#Right AST#expression#Right . city_name AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedCity AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentLocation AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` 已定位到: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentLocation AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 跳转到天气页面查看定位城市的天气 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left router AST#expression#Right . pushUrl AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left 'pages/CityWeather' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left params AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left cityName AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentLocation AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '获取位置天气失败:' AST#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left '获取位置天气失败' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private async getWeatherByLocation(latitude: number, longitude: number) {
try {
let httpRequest = http.createHttp();
let response = await httpRequest.request(Config.API.WEATHER_BY_LOCATION, {
method: http.RequestMethod.POST,
extraData: JSON.stringify({
latitude: latitude,
longitude: longitude
}),
header: {
"Content-Type": "application/json"
}
});
let result = JSON.parse(response.result as string) as LocationWeatherResponse;
if (result.code === 0) {
this.currentLocation = result.data.city_name;
this.selectedCity = this.currentLocation;
promptAction.showToast({ message: `已定位到: ${this.currentLocation}` });
router.pushUrl({
url: 'pages/CityWeather',
params: {
cityName: this.currentLocation
}
});
}
} catch (error) {
console.error('获取位置天气失败:', error);
promptAction.showToast({ message: '获取位置天气失败' });
}
}
|
https://github.com/LiuAnclouds/Harmony-ArkTS-App.git/blob/2119ce333927599b81a31081bc913e1416837308/WeatherMind/entry/src/main/ets/pages/ChooseCity.ets#L227-L260
|
400d47ce64998f04183f263ed89b6ae115528bb5
|
github
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/models/datas/book/Book.ets
|
arkts
|
CigenData.ts
|
export class CigenData {
cigenId : number | null = null
cigenName : string | null = null
textDb : string | null = null
static equals(lhs: CigenData, rhs: CigenData): boolean {
return lhs.cigenId === rhs.cigenId
}
constructor(json?: Record<string, Object>) {
if (json) {
this.cigenId = (json['cigenId'] as number) ?? null
this.cigenName = (json['cigenName'] as string) ?? null
this.textDb = (json['textDb'] as string) ?? null
}
}
static fromArray(arr: Object[] | null): CigenData[] {
if (!arr) return []
return arr.map(o => new CigenData(o as Record<string, Object>))
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class CigenData AST#class_body#Left { AST#property_declaration#Left cigenId AST#ERROR#Left : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right cigenName : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right textDb AST#ERROR#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#property_declaration#Right AST#method_declaration#Left static equals AST#parameter_list#Left ( AST#parameter#Left lhs : AST#type_annotation#Left AST#primary_type#Left CigenData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left rhs : AST#type_annotation#Left AST#primary_type#Left CigenData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left lhs AST#expression#Right . cigenId AST#member_expression#Right AST#expression#Right === AST#expression#Left rhs AST#expression#Right AST#binary_expression#Right AST#expression#Right . cigenId AST#member_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left json ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left json AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cigenId AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left json AST#expression#Right [ AST#expression#Left 'cigenId' AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ?? AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cigenName AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left json AST#expression#Right [ AST#expression#Left 'cigenName' AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ?? AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . textDb AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left json AST#expression#Right [ AST#expression#Left 'textDb' AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ?? AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right AST#method_declaration#Left static fromArray AST#parameter_list#Left ( AST#parameter#Left arr : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#array_type#Left Object [ ] AST#array_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left CigenData [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left arr AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left arr AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left o => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left CigenData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left o AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class CigenData {
cigenId : number | null = null
cigenName : string | null = null
textDb : string | null = null
static equals(lhs: CigenData, rhs: CigenData): boolean {
return lhs.cigenId === rhs.cigenId
}
constructor(json?: Record<string, Object>) {
if (json) {
this.cigenId = (json['cigenId'] as number) ?? null
this.cigenName = (json['cigenName'] as string) ?? null
this.textDb = (json['textDb'] as string) ?? null
}
}
static fromArray(arr: Object[] | null): CigenData[] {
if (!arr) return []
return arr.map(o => new CigenData(o as Record<string, Object>))
}
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/datas/book/Book.ets#L74-L96
|
206bc48de542d55940a4e7765e76852822b413bc
|
github
|
|
robotzzh/AgricultureApp.git
|
7b12c588dd1d07cc07a8b25577d785d30bd838f6
|
entry/src/main/ets/common/bean/FarmBean.ets
|
arkts
|
JSON_to
|
给一个JSON对象,返回一个FarmBean
|
static JSON_to(message):FarmBean{
var temp:FarmBean = new FarmBean(
message.fieldId,
message.name,
message.temperature,
message.humidity,
message.co2,
message.lumination,
message.soilHumidity,
message.sensor_IP,
message.sensor_port,
message. NPK,
message.PH,
message.conductivity,
);
return temp;
}
|
AST#method_declaration#Left static JSON_to AST#parameter_list#Left ( AST#parameter#Left message AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left FarmBean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left var AST#variable_declarator#Left temp : AST#type_annotation#Left AST#primary_type#Left FarmBean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left FarmBean AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . fieldId AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . name AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . temperature AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . humidity AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . co2 AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . lumination AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . soilHumidity AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . sensor_IP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . sensor_port AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . NPK AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . PH AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . conductivity AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left temp AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static JSON_to(message):FarmBean{
var temp:FarmBean = new FarmBean(
message.fieldId,
message.name,
message.temperature,
message.humidity,
message.co2,
message.lumination,
message.soilHumidity,
message.sensor_IP,
message.sensor_port,
message. NPK,
message.PH,
message.conductivity,
);
return temp;
}
|
https://github.com/robotzzh/AgricultureApp.git/blob/7b12c588dd1d07cc07a8b25577d785d30bd838f6/entry/src/main/ets/common/bean/FarmBean.ets#L81-L97
|
9fa90ef7c1a677fabd0570feceb54cb71af563f1
|
github
|
Joker-x-dev/HarmonyKit.git
|
f97197ce157df7f303244fba42e34918306dfb08
|
core/util/src/main/ets/toast/ToastUtils.ets
|
arkts
|
showBreakAll
|
显示强制截断换行 Toast
@param {string | ResourceStr} message - 提示内容
@returns {void} 无返回值
|
static showBreakAll(message: string | ResourceStr): void {
IBestToast.show({
wordBreak: "break-all",
message: message
});
}
|
AST#method_declaration#Left static showBreakAll AST#parameter_list#Left ( AST#parameter#Left message : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left ResourceStr AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left IBestToast AST#expression#Right . show AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left wordBreak AST#property_name#Right : AST#expression#Left "break-all" AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left message AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
static showBreakAll(message: string | ResourceStr): void {
IBestToast.show({
wordBreak: "break-all",
message: message
});
}
|
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/util/src/main/ets/toast/ToastUtils.ets#L119-L124
|
44d9edeba12499b6f0626b33bedc436ff37268c9
|
github
|
mayuanwei/harmonyOS_bilibili
|
8a36b68b1ddf4433e2e17ee10fee4993cce2a6c5
|
HCIA/complete/ArkData/PreferencesDemo/entry/src/main/ets/model/PreferenceModel.ets
|
arkts
|
deleteData
|
4-删除数据
|
deleteData(key: string) {
let promise = dataPreferences.delete(key);
promise.then(() => {
this.showToastMessage($r('app.string.data_delete_msg'));
console.info("成功删除"+key+"值对应数据");
}).catch((err: BusinessError) => {
console.error("删除"+key+"值对应数据失败 =" + err.code + ", message =" + err.message);
})
}
|
AST#method_declaration#Left deleteData AST#parameter_list#Left ( AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left promise = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dataPreferences AST#expression#Right . delete AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promise AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showToastMessage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.data_delete_msg' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left "成功删除" AST#expression#Right + AST#expression#Left key AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left "值对应数据" AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left "删除" AST#expression#Right + AST#expression#Left key AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left "值对应数据失败 =" AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left err AST#expression#Right AST#binary_expression#Right AST#expression#Right . code AST#member_expression#Right AST#expression#Right + AST#expression#Left ", message =" AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left err AST#expression#Right AST#binary_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
deleteData(key: string) {
let promise = dataPreferences.delete(key);
promise.then(() => {
this.showToastMessage($r('app.string.data_delete_msg'));
console.info("成功删除"+key+"值对应数据");
}).catch((err: BusinessError) => {
console.error("删除"+key+"值对应数据失败 =" + err.code + ", message =" + err.message);
})
}
|
https://github.com/mayuanwei/harmonyOS_bilibili/blob/8a36b68b1ddf4433e2e17ee10fee4993cce2a6c5/HCIA/complete/ArkData/PreferencesDemo/entry/src/main/ets/model/PreferenceModel.ets#L82-L90
|
5dbe075599148ce09a9f48fdcf3d7a8e9e73c78e
|
gitee
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/ArrayUtil.ets
|
arkts
|
TODO 集合工具类
author: 桃花镇童长老ᥫ᭡
since: 2024/05/01
|
export class ArrayUtil {
/**
* 判断集合是否为非空集合。
* @param array
* @returns
*/
static isNotEmpty<T>(array: T[]): boolean {
return undefined !== array && null !== array && array.length !== 0;
}
/**
* 判断集合是否为空集合。
* @param array
* @returns
*/
static isEmpty<T>(array: T[]): boolean {
return array === undefined || array === null || array.length === 0;
}
/**
* 去除字符串数组中的空值
* @param arr 待处理的集合
* @returns 处理后的集合
*/
static removeEmpty(arr: string[]): string[] {
return arr.filter((value) => StrUtil.isNotEmpty(value));
}
/**
* 去除字符串数组的每个值的前后空格
* @param strs
* @returns
*/
static trim(strs: String[]): String[] {
return strs.map((value) => value.trim());
}
/**
* 将数组去重,去重后生成新的数组,原数组不变。
* @param array 数组
* @return 去重后的数组
*/
static distinct<T>(array: Array<T>): T[] {
return Array.from(new Set(array));
}
/**
* 将数组反转,会修改原始数组。
* @param <T> 数组元素类型
* @param array 数组
* @return 变更后的原数组
*/
static reverse<T>(array: T[]): T[] {
return array.reverse();
}
/**
* 数组过滤,通过filter函数实现来过滤返回需要的元素
* @param array
* @param filter 过滤函数
* @returns
*/
static filter<T>(array: T[], filter: (item: T) => boolean): T[] {
return filter ? array.filter(filter) : array;
}
/**
* 拼接数据,使用扩展运算符,不影响原数组。
* @param source
* @param item
* @returns
*/
static append<T>(source: T[], item: T | T[]): T[] {
if (Array.isArray(item)) {
return [...source, ...item];
} else {
return [...source, item];
}
}
/**
* 获取数组最小值(数值、字符串、日期)。
* @param array
* @returns
*/
static min<T extends number | string | Date>(array: T[]): T | null {
if (array.length === 0) {
return null;
}
let minValue = array[0];
for (let i = 1; i < array.length; i++) {
if (array[i] < minValue) {
minValue = array[i];
}
}
return minValue;
}
/**
* 获取数组最大值(数值、字符串、日期)。
* @param array
* @returns
*/
static max<T extends number | string | Date>(array: T[]): T | null {
if (array.length === 0) {
return null;
}
let maxValue = array[0];
for (let i = 1; i < array.length; i++) {
if (array[i] > maxValue) {
maxValue = array[i];
}
}
return maxValue;
}
/**
* 平铺二维数组。
* @param arrays 数组
* @returns 返回一个新的数组
*/
static flatten(arrays: string[][]): string[] {
return arrays.flat();
}
/**
* 平铺二维数组,并去重。
* @param arrays 数组
* @returns 返回一个新的数组
*/
static union(arrays: string[][]): string[] {
return Array.from(new Set(arrays.flat()));
}
/**
* 数组分块
* @param array
* @param size
* @returns
*/
static chunk<T>(array: T[], size: number): T[][] {
let length = array.length;
if (length < 1 || size < 1) {
return [];
}
let index = 0;
let resIndex = 0;
let result = new Array<Array<T>>(Math.ceil(length / size));
while (index < length) {
result[resIndex++] = array.slice(index, (index += size));
}
|
AST#export_declaration#Left export AST#class_declaration#Left class ArrayUtil AST#class_body#Left { /**
* 判断集合是否为非空集合。
* @param array
* @returns
*/ AST#method_declaration#Left static isNotEmpty AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left array : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left T [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left undefined AST#expression#Right !== AST#expression#Left array AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right !== AST#expression#Left array AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left array AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right !== AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 判断集合是否为空集合。
* @param array
* @returns
*/ AST#method_declaration#Left static isEmpty AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left array : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left T [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left array AST#expression#Right === AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left array AST#expression#Right === AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left array AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 去除字符串数组中的空值
* @param arr 待处理的集合
* @returns 处理后的集合
*/ AST#method_declaration#Left static removeEmpty AST#parameter_list#Left ( AST#parameter#Left arr : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left arr AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StrUtil AST#expression#Right . isNotEmpty AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left value AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 去除字符串数组的每个值的前后空格
* @param strs
* @returns
*/ AST#method_declaration#Left static trim AST#parameter_list#Left ( AST#parameter#Left strs : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left String [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left String [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left strs AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left value AST#expression#Right . trim AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 将数组去重,去重后生成新的数组,原数组不变。
* @param array 数组
* @return 去重后的数组
*/ AST#method_declaration#Left static distinct AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left array : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left T [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Array AST#expression#Right . from AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Set AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left array AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 将数组反转,会修改原始数组。
* @param <T> 数组元素类型
* @param array 数组
* @return 变更后的原数组
*/ AST#method_declaration#Left static reverse AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left array : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left T [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left T [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left array AST#expression#Right . reverse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 数组过滤,通过filter函数实现来过滤返回需要的元素
* @param array
* @param filter 过滤函数
* @returns
*/ AST#method_declaration#Left static filter AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left array : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left T [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left filter : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left T [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#conditional_expression#Left AST#expression#Left filter AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left array AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left filter AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left array AST#expression#Right AST#conditional_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 拼接数据,使用扩展运算符,不影响原数组。
* @param source
* @param item
* @returns
*/ AST#method_declaration#Left static append AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left source : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left T [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left item : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left T AST#primary_type#Right | AST#primary_type#Left AST#array_type#Left T [ ] AST#array_type#Right AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left T [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Array AST#expression#Right . isArray AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left item AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ ... AST#expression#Left source AST#expression#Right , ... AST#expression#Left item AST#expression#Right ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ ... AST#expression#Left source AST#expression#Right , AST#expression#Left item AST#expression#Right ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 获取数组最小值(数值、字符串、日期)。
* @param array
* @returns
*/ AST#method_declaration#Left static min AST#type_parameters#Left < AST#type_parameter#Left T extends AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Date AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left array : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left T [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left T AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left array AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left minValue = AST#expression#Left AST#subscript_expression#Left AST#expression#Left array AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 1 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left array AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left array AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right < AST#expression#Left minValue AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left minValue = AST#expression#Left AST#subscript_expression#Left AST#expression#Left array AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left minValue AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 获取数组最大值(数值、字符串、日期)。
* @param array
* @returns
*/ AST#method_declaration#Left static max AST#type_parameters#Left < AST#type_parameter#Left T extends AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Date AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left array : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left T [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left T AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left array AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left maxValue = AST#expression#Left AST#subscript_expression#Left AST#expression#Left array AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 1 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left array AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left array AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right > AST#expression#Left maxValue AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left maxValue = AST#expression#Left AST#subscript_expression#Left AST#expression#Left array AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left maxValue AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 平铺二维数组。
* @param arrays 数组
* @returns 返回一个新的数组
*/ AST#method_declaration#Left static flatten AST#parameter_list#Left ( AST#parameter#Left arrays : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left arrays AST#expression#Right . flat AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 平铺二维数组,并去重。
* @param arrays 数组
* @returns 返回一个新的数组
*/ AST#method_declaration#Left static union AST#parameter_list#Left ( AST#parameter#Left arrays : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Array AST#expression#Right . from AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Set AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left arrays AST#expression#Right . flat AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 数组分块
* @param array
* @param size
* @returns
*/ AST#property_declaration#Left static chunk AST#ERROR#Left AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left array : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left T [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left size : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left T [ ] [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left length = AST#expression#Left AST#member_expression#Left AST#expression#Left array AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left length AST#expression#Right < AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left size AST#expression#Right AST#binary_expression#Right AST#expression#Right < AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left index = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left resIndex = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left result = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . ceil AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left length AST#expression#Right / AST#expression#Left size AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right while ( AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right < AST#expression#Left length AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression#Left AST#subscript_expression#Left AST#expression#Left result AST#expression#Right [ AST#expression#Left AST#update_expression#Left AST#expression#Left resIndex AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left array AST#expression#Right . slice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right , AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#assignment_expression#Left index += AST#expression#Left size AST#expression#Right AST#assignment_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class ArrayUtil {
static isNotEmpty<T>(array: T[]): boolean {
return undefined !== array && null !== array && array.length !== 0;
}
static isEmpty<T>(array: T[]): boolean {
return array === undefined || array === null || array.length === 0;
}
static removeEmpty(arr: string[]): string[] {
return arr.filter((value) => StrUtil.isNotEmpty(value));
}
static trim(strs: String[]): String[] {
return strs.map((value) => value.trim());
}
static distinct<T>(array: Array<T>): T[] {
return Array.from(new Set(array));
}
static reverse<T>(array: T[]): T[] {
return array.reverse();
}
static filter<T>(array: T[], filter: (item: T) => boolean): T[] {
return filter ? array.filter(filter) : array;
}
static append<T>(source: T[], item: T | T[]): T[] {
if (Array.isArray(item)) {
return [...source, ...item];
} else {
return [...source, item];
}
}
static min<T extends number | string | Date>(array: T[]): T | null {
if (array.length === 0) {
return null;
}
let minValue = array[0];
for (let i = 1; i < array.length; i++) {
if (array[i] < minValue) {
minValue = array[i];
}
}
return minValue;
}
static max<T extends number | string | Date>(array: T[]): T | null {
if (array.length === 0) {
return null;
}
let maxValue = array[0];
for (let i = 1; i < array.length; i++) {
if (array[i] > maxValue) {
maxValue = array[i];
}
}
return maxValue;
}
static flatten(arrays: string[][]): string[] {
return arrays.flat();
}
static union(arrays: string[][]): string[] {
return Array.from(new Set(arrays.flat()));
}
static chunk<T>(array: T[], size: number): T[][] {
let length = array.length;
if (length < 1 || size < 1) {
return [];
}
let index = 0;
let resIndex = 0;
let result = new Array<Array<T>>(Math.ceil(length / size));
while (index < length) {
result[resIndex++] = array.slice(index, (index += size));
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/ArrayUtil.ets#L24-L188
|
4117036527470d57797e3e080b08c4227cac7814
|
gitee
|
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/videotrimmer/src/main/ets/uploadanddownload/RequestDownload.ets
|
arkts
|
downloadFile
|
失败回调
下载文件
|
async downloadFile(folder: string, url: string,
callback: (progress: number, isSuccess: boolean, localPath: string) => void) {
logger.info(TAG, 'downloadFile,url:' + url);
// Found an ongoing download task, prompted and returned.
let tasks = await request.agent.search({
state: request.agent.State.RUNNING,
action: request.agent.Action.DOWNLOAD,
mode: request.agent.Mode.FOREGROUND
});
if (tasks.length > 0) {
promptAction.showToast({ message: $r('app.string.video_trimmer_have_download_task_tips'), bottom: TOAST_BOTTOM });
return;
}
let splitUrl = url.split('//')[1].split('/');
let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
// 下载保存的本地路径
let localPath = `${folder}/${splitUrl[splitUrl.length-1]}`;
logger.info(TAG, 'downloadFile, localPath:' + localPath);
let downloadConfig: request.agent.Config = {
action: request.agent.Action.DOWNLOAD,
url: url,
method: 'GET',
title: 'download',
mode: request.agent.Mode.BACKGROUND,
retry: true,
network: request.agent.Network.ANY,
saveas: `./${localPath}`,
overwrite: true
}
logger.info(TAG, `downloadFile, downloadConfig = ${JSON.stringify(downloadConfig)}`);
try {
this.downloadTask = await request.agent.create(context, downloadConfig);
// 监听下载进度
this.downloadTask.on('progress', this.progressCallback = (progress: request.agent.Progress) => {
logger.info(TAG, `progress = ${progress.processed} ,state = ${progress.state}`);
let processed = Number(progress.processed.toString()).valueOf();
let size = progress.sizes[0];
let process: number = Math.floor(processed / size * CommonConstants.PROGRESS_MAX);
if (process < CommonConstants.PROGRESS_MAX) {
callback(process, false, '');
}
})
// 监听下载完成
this.downloadTask.on('completed', this.completedCallback = (progress: request.agent.Progress) => {
logger.info(TAG, `download complete, file= ${url}, progress = ${progress.processed}, localPath=${localPath}`);
callback(CommonConstants.PROGRESS_MAX, true, localPath);
this.deleteTask();
})
// 监听暂停事件
this.downloadTask.on('pause', this.failedCallback = async (progress: request.agent.Progress) => {
if (this.downloadTask) {
let taskInfo = await request.agent.show(this.downloadTask.tid);
logger.info(TAG,
`pause, resean = ${taskInfo.reason}, progress = ${progress.processed}, faults = ${JSON.stringify(taskInfo.faults)}`);
isNetPause = taskInfo.faults === 0;
if (isNetPause) {
callback(TaskConstants.TASK_NET_PAUSE_MSG, isNetPause, '');
} else {
callback(TaskConstants.TASK_PAUSE_MSG, isNetPause, '');
}
}
})
// 监听恢复下载事件
this.downloadTask.on('resume', this.failedCallback = async (progress: request.agent.Progress) => {
if (this.downloadTask) {
let taskInfo = await request.agent.show(this.downloadTask.tid);
logger.info(TAG,
`resume, resean = ${taskInfo.reason}, progress = ${progress.processed}, faults = ${JSON.stringify(taskInfo.faults)}`);
if (isNetPause) {
isNetPause = false;
callback(TaskConstants.TASK_NET_RESUME_MSG, isNetPause, '');
} else {
callback(TaskConstants.TASK_RESUME_MSG, isNetPause, '');
}
}
})
// 监听下载失败事件
this.downloadTask.on('failed', this.failedCallback = async (progress: request.agent.Progress) => {
if (this.downloadTask) {
let taskInfo = await request.agent.show(this.downloadTask.tid);
logger.info(TAG,
`fail, resean = ${taskInfo.reason}, progress = ${progress.processed}, faults = ${JSON.stringify(taskInfo.faults)}`);
}
callback(CommonConstants.PROGRESS_MAX, false, '');
this.deleteTask();
})
await this.downloadTask.start();
} catch (error) {
const err: BusinessError = error as BusinessError;
logger.error(TAG, `task err, Code is ${err.code}, message is ${err.message}`);
callback(CommonConstants.PROGRESS_MAX, false, '');
}
}
|
AST#method_declaration#Left async downloadFile AST#parameter_list#Left ( AST#parameter#Left folder : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left url : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left callback : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left progress : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left isSuccess : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left localPath : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left 'downloadFile,url:' AST#expression#Right + AST#expression#Left url AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // Found an ongoing download task, prompted and returned. AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left tasks = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left request AST#expression#Right AST#await_expression#Right AST#expression#Right . agent AST#member_expression#Right AST#expression#Right . search AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left state AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left request AST#expression#Right . agent AST#member_expression#Right AST#expression#Right . State AST#member_expression#Right AST#expression#Right . RUNNING AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left action AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left request AST#expression#Right . agent AST#member_expression#Right AST#expression#Right . Action AST#member_expression#Right AST#expression#Right . DOWNLOAD AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left mode AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left request AST#expression#Right . agent AST#member_expression#Right AST#expression#Right . Mode AST#member_expression#Right AST#expression#Right . FOREGROUND AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left tasks AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.video_trimmer_have_download_task_tips' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left TOAST_BOTTOM AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left splitUrl = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left url AST#expression#Right . split AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '//' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . split AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '/' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( AST#expression#Left this AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 下载保存的本地路径 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left localPath = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left folder AST#expression#Right } AST#template_substitution#Right / AST#template_substitution#Left $ { AST#expression#Left AST#subscript_expression#Left AST#expression#Left splitUrl AST#expression#Right [ AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left splitUrl AST#expression#Right . length AST#member_expression#Right AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left 'downloadFile, localPath:' AST#expression#Right + AST#expression#Left localPath AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left downloadConfig : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left request . agent . Config AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left action AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left request AST#expression#Right . agent AST#member_expression#Right AST#expression#Right . Action AST#member_expression#Right AST#expression#Right . DOWNLOAD AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left url AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left method AST#property_name#Right : AST#expression#Left 'GET' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left 'download' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left mode AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left request AST#expression#Right . agent AST#member_expression#Right AST#expression#Right . Mode AST#member_expression#Right AST#expression#Right . BACKGROUND AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left retry AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left network AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left request AST#expression#Right . agent AST#member_expression#Right AST#expression#Right . Network AST#member_expression#Right AST#expression#Right . ANY AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left saveas AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` ./ AST#template_substitution#Left $ { AST#expression#Left localPath AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left overwrite AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#ERROR#Left logger AST#ERROR#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` downloadFile, downloadConfig = AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left downloadConfig AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadTask AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left request AST#expression#Right AST#await_expression#Right AST#expression#Right . agent AST#member_expression#Right AST#expression#Right . create AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left downloadConfig AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 监听下载进度 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadTask AST#member_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'progress' AST#expression#Right , AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . progressCallback AST#member_expression#Right = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left progress : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left request . agent . Progress AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` progress = AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . processed AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ,state = AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . state AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left processed = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left Number AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . processed AST#member_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . valueOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left size = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . sizes AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left process : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left processed AST#expression#Right / AST#expression#Left size AST#expression#Right AST#binary_expression#Right AST#expression#Right * AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . PROGRESS_MAX AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left process AST#expression#Right < AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . PROGRESS_MAX AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left callback AST#expression#Right AST#argument_list#Left ( AST#expression#Left process AST#expression#Right , AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right , AST#expression#Left '' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // 监听下载完成 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadTask AST#member_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'completed' AST#expression#Right , AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . completedCallback AST#member_expression#Right = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left progress : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left request . agent . Progress AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` download complete, file= AST#template_substitution#Left $ { AST#expression#Left url AST#expression#Right } AST#template_substitution#Right , progress = AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . processed AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , localPath= AST#template_substitution#Left $ { AST#expression#Left localPath AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left callback AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . PROGRESS_MAX AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right , AST#expression#Left localPath AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . deleteTask AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // 监听暂停事件 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadTask AST#member_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'pause' AST#expression#Right , AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . failedCallback AST#member_expression#Right = AST#expression#Left AST#arrow_function#Left async AST#parameter_list#Left ( AST#parameter#Left progress : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left request . agent . Progress AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadTask AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left taskInfo = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left request AST#expression#Right AST#await_expression#Right AST#expression#Right . agent AST#member_expression#Right AST#expression#Right . show AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadTask AST#member_expression#Right AST#expression#Right . tid AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` pause, resean = AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left taskInfo AST#expression#Right . reason AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , progress = AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . processed AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , faults = AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left taskInfo AST#expression#Right . faults AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left isNetPause = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left taskInfo AST#expression#Right . faults AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left isNetPause AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left callback AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left TaskConstants AST#expression#Right . TASK_NET_PAUSE_MSG AST#member_expression#Right AST#expression#Right , AST#expression#Left isNetPause AST#expression#Right , AST#expression#Left '' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left callback AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left TaskConstants AST#expression#Right . TASK_PAUSE_MSG AST#member_expression#Right AST#expression#Right , AST#expression#Left isNetPause AST#expression#Right , AST#expression#Left '' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // 监听恢复下载事件 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadTask AST#member_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'resume' AST#expression#Right , AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . failedCallback AST#member_expression#Right = AST#expression#Left AST#arrow_function#Left async AST#parameter_list#Left ( AST#parameter#Left progress : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left request . agent . Progress AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadTask AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left taskInfo = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left request AST#expression#Right AST#await_expression#Right AST#expression#Right . agent AST#member_expression#Right AST#expression#Right . show AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadTask AST#member_expression#Right AST#expression#Right . tid AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` resume, resean = AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left taskInfo AST#expression#Right . reason AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , progress = AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . processed AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , faults = AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left taskInfo AST#expression#Right . faults AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left isNetPause AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left isNetPause = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left callback AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left TaskConstants AST#expression#Right . TASK_NET_RESUME_MSG AST#member_expression#Right AST#expression#Right , AST#expression#Left isNetPause AST#expression#Right , AST#expression#Left '' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left callback AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left TaskConstants AST#expression#Right . TASK_RESUME_MSG AST#member_expression#Right AST#expression#Right , AST#expression#Left isNetPause AST#expression#Right , AST#expression#Left '' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // 监听下载失败事件 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadTask AST#member_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'failed' AST#expression#Right , AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . failedCallback AST#member_expression#Right = AST#expression#Left AST#arrow_function#Left async AST#parameter_list#Left ( AST#parameter#Left progress : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left request . agent . Progress AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadTask AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left taskInfo = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left request AST#expression#Right AST#await_expression#Right AST#expression#Right . agent AST#member_expression#Right AST#expression#Right . show AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadTask AST#member_expression#Right AST#expression#Right . tid AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` fail, resean = AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left taskInfo AST#expression#Right . reason AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , progress = AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . processed AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , faults = AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left taskInfo AST#expression#Right . faults AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left callback AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . PROGRESS_MAX AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right , AST#expression#Left '' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . deleteTask AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . downloadTask AST#member_expression#Right AST#expression#Right . start AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left err : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` task err, Code is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , message is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left callback AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . PROGRESS_MAX AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right , AST#expression#Left '' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async downloadFile(folder: string, url: string,
callback: (progress: number, isSuccess: boolean, localPath: string) => void) {
logger.info(TAG, 'downloadFile,url:' + url);
let tasks = await request.agent.search({
state: request.agent.State.RUNNING,
action: request.agent.Action.DOWNLOAD,
mode: request.agent.Mode.FOREGROUND
});
if (tasks.length > 0) {
promptAction.showToast({ message: $r('app.string.video_trimmer_have_download_task_tips'), bottom: TOAST_BOTTOM });
return;
}
let splitUrl = url.split('//')[1].split('/');
let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
let localPath = `${folder}/${splitUrl[splitUrl.length-1]}`;
logger.info(TAG, 'downloadFile, localPath:' + localPath);
let downloadConfig: request.agent.Config = {
action: request.agent.Action.DOWNLOAD,
url: url,
method: 'GET',
title: 'download',
mode: request.agent.Mode.BACKGROUND,
retry: true,
network: request.agent.Network.ANY,
saveas: `./${localPath}`,
overwrite: true
}
logger.info(TAG, `downloadFile, downloadConfig = ${JSON.stringify(downloadConfig)}`);
try {
this.downloadTask = await request.agent.create(context, downloadConfig);
this.downloadTask.on('progress', this.progressCallback = (progress: request.agent.Progress) => {
logger.info(TAG, `progress = ${progress.processed} ,state = ${progress.state}`);
let processed = Number(progress.processed.toString()).valueOf();
let size = progress.sizes[0];
let process: number = Math.floor(processed / size * CommonConstants.PROGRESS_MAX);
if (process < CommonConstants.PROGRESS_MAX) {
callback(process, false, '');
}
})
this.downloadTask.on('completed', this.completedCallback = (progress: request.agent.Progress) => {
logger.info(TAG, `download complete, file= ${url}, progress = ${progress.processed}, localPath=${localPath}`);
callback(CommonConstants.PROGRESS_MAX, true, localPath);
this.deleteTask();
})
this.downloadTask.on('pause', this.failedCallback = async (progress: request.agent.Progress) => {
if (this.downloadTask) {
let taskInfo = await request.agent.show(this.downloadTask.tid);
logger.info(TAG,
`pause, resean = ${taskInfo.reason}, progress = ${progress.processed}, faults = ${JSON.stringify(taskInfo.faults)}`);
isNetPause = taskInfo.faults === 0;
if (isNetPause) {
callback(TaskConstants.TASK_NET_PAUSE_MSG, isNetPause, '');
} else {
callback(TaskConstants.TASK_PAUSE_MSG, isNetPause, '');
}
}
})
this.downloadTask.on('resume', this.failedCallback = async (progress: request.agent.Progress) => {
if (this.downloadTask) {
let taskInfo = await request.agent.show(this.downloadTask.tid);
logger.info(TAG,
`resume, resean = ${taskInfo.reason}, progress = ${progress.processed}, faults = ${JSON.stringify(taskInfo.faults)}`);
if (isNetPause) {
isNetPause = false;
callback(TaskConstants.TASK_NET_RESUME_MSG, isNetPause, '');
} else {
callback(TaskConstants.TASK_RESUME_MSG, isNetPause, '');
}
}
})
this.downloadTask.on('failed', this.failedCallback = async (progress: request.agent.Progress) => {
if (this.downloadTask) {
let taskInfo = await request.agent.show(this.downloadTask.tid);
logger.info(TAG,
`fail, resean = ${taskInfo.reason}, progress = ${progress.processed}, faults = ${JSON.stringify(taskInfo.faults)}`);
}
callback(CommonConstants.PROGRESS_MAX, false, '');
this.deleteTask();
})
await this.downloadTask.start();
} catch (error) {
const err: BusinessError = error as BusinessError;
logger.error(TAG, `task err, Code is ${err.code}, message is ${err.message}`);
callback(CommonConstants.PROGRESS_MAX, false, '');
}
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/videotrimmer/src/main/ets/uploadanddownload/RequestDownload.ets#L41-L133
|
8ee1256bd1c616237e7a63e91b8c7e2dd1ff0208
|
gitee
|
iotjin/JhHarmonyDemo.git
|
819e6c3b1db9984c042a181967784550e171b2e8
|
JhCommon/src/main/ets/JhCommon/components/JhProgressHUD.ets
|
arkts
|
initUIConfig
|
/ 初始化Loading(在全局入口 page 处挂载)
|
public static initUIConfig(context: UIContext) {
JhProgressHUD.initXTPromptHUDConfig(context)
}
|
AST#method_declaration#Left public static initUIConfig AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JhProgressHUD AST#expression#Right . initXTPromptHUDConfig AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
public static initUIConfig(context: UIContext) {
JhProgressHUD.initXTPromptHUDConfig(context)
}
|
https://github.com/iotjin/JhHarmonyDemo.git/blob/819e6c3b1db9984c042a181967784550e171b2e8/JhCommon/src/main/ets/JhCommon/components/JhProgressHUD.ets#L34-L36
|
b6c9e6814d776fa2ea31eb66d532cfedcbd2af6f
|
github
|
liuchao0739/arkTS_universal_starter.git
|
0ca845f5ae0e78db439dc09f712d100c0dd46ed3
|
entry/src/main/ets/services/CartService.ets
|
arkts
|
saveCart
|
保存购物车
|
private async saveCart(): Promise<void> {
try {
await StorageManager.setString('cart', JSON.stringify(this.cartItems));
this.notifyListeners();
} catch (error) {
Logger.error('CartService', `Failed to save cart: ${String(error)}`);
}
}
|
AST#method_declaration#Left private async saveCart AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left StorageManager AST#expression#Right AST#await_expression#Right AST#expression#Right . setString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'cart' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartItems AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . notifyListeners AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'CartService' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to save cart: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left String AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private async saveCart(): Promise<void> {
try {
await StorageManager.setString('cart', JSON.stringify(this.cartItems));
this.notifyListeners();
} catch (error) {
Logger.error('CartService', `Failed to save cart: ${String(error)}`);
}
}
|
https://github.com/liuchao0739/arkTS_universal_starter.git/blob/0ca845f5ae0e78db439dc09f712d100c0dd46ed3/entry/src/main/ets/services/CartService.ets#L64-L71
|
5e92b6f738dc0555a4daaa47a84852d5dcf6fe58
|
github
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/Performance/PerformanceLibrary/feature/ThreadDataTransfer/src/main/ets/utils/TreadUtil.ets
|
arkts
|
根据参数由TaskPool处理pixelMap
@param pixelMap 源数据
@param lastAdjustData 之前的饱和度值
@param currentAdjustData 将要调整到饱和度值
@param taskNum 开启的线程任务数
@param isParamsByTransfer 参数是否通过传递方式传参
@param callback 线程处理结束后的回调
@returns
|
export async function pixelMapProcessByTaskPool(pixelMap: image.PixelMap, lastAdjustData: number, currentAdjustData: number, taskNum: number, isParamsByTransfer: boolean, callback?: Callback<ArrayBuffer>): Promise<void> {
let arrayBuffer: ArrayBuffer = await convertPixelMapToArrayBuffer(pixelMap);
let taskPoolGroup: taskpool.TaskGroup = new taskpool.TaskGroup();
for (let i: number = 0; i < taskNum; i++) {
let arrayBufferSlice: ArrayBuffer = arrayBuffer.slice(arrayBuffer.byteLength / taskNum * i, arrayBuffer.byteLength / taskNum * (i + 1));
taskPoolGroup.addTask(createImageTask(arrayBufferSlice, lastAdjustData, currentAdjustData, isParamsByTransfer));
}
let start: number = new Date().getTime();
taskpool.execute(taskPoolGroup).then((data: Object[]) => {
if (callback !== undefined) {
let end: number = new Date().getTime();
AppStorage.set<String>('timeCost', util.format('%s s', ((end - start) / 1000).toFixed(2).toString()));
callback(concatenateArrayBuffers(data as ArrayBuffer[]));
}
}).catch((e: BusinessError) => {
Logger.error(e.message);
})
}
|
AST#export_declaration#Left export AST#function_declaration#Left async function pixelMapProcessByTaskPool AST#parameter_list#Left ( AST#parameter#Left pixelMap : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left image . PixelMap AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left lastAdjustData : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left currentAdjustData : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left taskNum : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left isParamsByTransfer : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left callback ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left ArrayBuffer AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left arrayBuffer : AST#type_annotation#Left AST#primary_type#Left ArrayBuffer AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left convertPixelMapToArrayBuffer AST#expression#Right AST#await_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left pixelMap AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left taskPoolGroup : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left taskpool . TaskGroup AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left taskpool AST#expression#Right AST#new_expression#Right AST#expression#Right . TaskGroup AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left taskNum AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left arrayBufferSlice : AST#type_annotation#Left AST#primary_type#Left ArrayBuffer AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left arrayBuffer AST#expression#Right . slice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left arrayBuffer AST#expression#Right . byteLength AST#member_expression#Right AST#expression#Right / AST#expression#Left taskNum AST#expression#Right AST#binary_expression#Right AST#expression#Right * AST#expression#Left i AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left arrayBuffer AST#expression#Right . byteLength AST#member_expression#Right AST#expression#Right / AST#expression#Left taskNum AST#expression#Right AST#binary_expression#Right AST#expression#Right * AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left taskPoolGroup AST#expression#Right . addTask AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left createImageTask AST#expression#Right AST#argument_list#Left ( AST#expression#Left arrayBufferSlice AST#expression#Right , AST#expression#Left lastAdjustData AST#expression#Right , AST#expression#Left currentAdjustData AST#expression#Right , AST#expression#Left isParamsByTransfer AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left start : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getTime AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left taskpool AST#expression#Right . execute AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left taskPoolGroup AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Object [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left callback AST#expression#Right !== AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left end : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getTime AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left String AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left 'timeCost' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left util AST#expression#Right . format AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '%s s' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left end AST#expression#Right - AST#expression#Left start AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left 1000 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . toFixed AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left callback AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left concatenateArrayBuffers AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left data AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ArrayBuffer [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left e : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left e AST#expression#Right . message AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export async function pixelMapProcessByTaskPool(pixelMap: image.PixelMap, lastAdjustData: number, currentAdjustData: number, taskNum: number, isParamsByTransfer: boolean, callback?: Callback<ArrayBuffer>): Promise<void> {
let arrayBuffer: ArrayBuffer = await convertPixelMapToArrayBuffer(pixelMap);
let taskPoolGroup: taskpool.TaskGroup = new taskpool.TaskGroup();
for (let i: number = 0; i < taskNum; i++) {
let arrayBufferSlice: ArrayBuffer = arrayBuffer.slice(arrayBuffer.byteLength / taskNum * i, arrayBuffer.byteLength / taskNum * (i + 1));
taskPoolGroup.addTask(createImageTask(arrayBufferSlice, lastAdjustData, currentAdjustData, isParamsByTransfer));
}
let start: number = new Date().getTime();
taskpool.execute(taskPoolGroup).then((data: Object[]) => {
if (callback !== undefined) {
let end: number = new Date().getTime();
AppStorage.set<String>('timeCost', util.format('%s s', ((end - start) / 1000).toFixed(2).toString()));
callback(concatenateArrayBuffers(data as ArrayBuffer[]));
}
}).catch((e: BusinessError) => {
Logger.error(e.message);
})
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Performance/PerformanceLibrary/feature/ThreadDataTransfer/src/main/ets/utils/TreadUtil.ets#L32-L49
|
6dda371602954037917c595f9c8f9bd450b11da6
|
gitee
|
|
didi/dimina.git
|
7ad9d89af58cd54e624b2e3d3eb14801cc8e05d2
|
harmony/dimina/src/main/ets/Service/DMPSendableObjects.ets
|
arkts
|
这个是 Worker 使用,之所以要用两个,是因为 Sendable 在有些类里面不能成为成员变量
|
export class AppData {
appIndex: number = -1;
appId: string = '';
jsAppVersion: string = '';
}
|
AST#export_declaration#Left export AST#class_declaration#Left class AppData AST#class_body#Left { AST#property_declaration#Left appIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left appId : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left jsAppVersion : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class AppData {
appIndex: number = -1;
appId: string = '';
jsAppVersion: string = '';
}
|
https://github.com/didi/dimina.git/blob/7ad9d89af58cd54e624b2e3d3eb14801cc8e05d2/harmony/dimina/src/main/ets/Service/DMPSendableObjects.ets#L15-L19
|
2c6d0d7fa478968d5af1e8ad7b5d81a66437f5d7
|
github
|
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/SystemFeature/Media/VoiceCallDemo/entry/src/main/ets/model/AudioManagerModel.ets
|
arkts
|
setVoiceScene
|
设置通话场景
AudioVolumeGroupManager.setAudioScene用于调整音频场景,属于系统接口。
目前版本(4.0.7.1之后)已实现自动切换AudioScene。
对于非系统应用,若使用AudioRenderer播放VOICE_CALL类型的音频,
则调用start函数时会自动切换至AUDIO_SCENE_VOICE_CHAT,
播放结束后自动切换回默认场景,无需调用setAudioScene。
|
async setVoiceScene(calling: boolean): Promise<void> {
Logger.info(TAG,`setVoiceScene ${calling}`);
if (!this.mAudioManager) {
return;
}
try {
if (calling) {
await this.mAudioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
Logger.info(TAG,`setVoiceScene AUDIO_SCENE_VOICE_CHAT sucess`);
} else {
await this.mAudioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_DEFAULT);
Logger.info(TAG,`setVoiceScene AUDIO_SCENE_DEFAULT sucess`);
}
} catch (err) {
Logger.error(TAG,`setVoiceScene failed, code is ${err.code}, message is ${err.message}`);
}
}
|
AST#method_declaration#Left async setVoiceScene AST#parameter_list#Left ( AST#parameter#Left calling : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` setVoiceScene AST#template_substitution#Left $ { AST#expression#Left calling AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . mAudioManager AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left calling AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . mAudioManager AST#member_expression#Right AST#expression#Right . setAudioScene AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left audio AST#expression#Right . AudioScene AST#member_expression#Right AST#expression#Right . AUDIO_SCENE_VOICE_CHAT AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` setVoiceScene AUDIO_SCENE_VOICE_CHAT sucess ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . mAudioManager AST#member_expression#Right AST#expression#Right . setAudioScene AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left audio AST#expression#Right . AudioScene AST#member_expression#Right AST#expression#Right . AUDIO_SCENE_DEFAULT AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` setVoiceScene AUDIO_SCENE_DEFAULT sucess ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` setVoiceScene failed, code is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , message is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async setVoiceScene(calling: boolean): Promise<void> {
Logger.info(TAG,`setVoiceScene ${calling}`);
if (!this.mAudioManager) {
return;
}
try {
if (calling) {
await this.mAudioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
Logger.info(TAG,`setVoiceScene AUDIO_SCENE_VOICE_CHAT sucess`);
} else {
await this.mAudioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_DEFAULT);
Logger.info(TAG,`setVoiceScene AUDIO_SCENE_DEFAULT sucess`);
}
} catch (err) {
Logger.error(TAG,`setVoiceScene failed, code is ${err.code}, message is ${err.message}`);
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/Media/VoiceCallDemo/entry/src/main/ets/model/AudioManagerModel.ets#L63-L80
|
34d22d54d37c7779bc1214cf55f9ba3a5a3e586c
|
gitee
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
ETSUI/SimpleCalculator/entry/src/main/ets/common/constants/CommonConstants.ets
|
arkts
|
Common constants for all features.
|
export class CommonConstants {
/**
* Full percent.
*/
static readonly FULL_PERCENT: string = '100%';
/**
* Operator Collection.
*/
static readonly OPERATORS: string = '+-×÷';
/**
* Operators with high precedence.
*/
static readonly OPERATORS_PRIORITY: string = '×÷';
/**
* Addition.
*/
static readonly ADD: string = '+';
/**
* Minus.
*/
static readonly MIN: string = '-';
/**
* Multiplication.
*/
static readonly MUL: string = '×';
/**
* Division.
*/
static readonly DIV: string = '÷';
/**
* Percent sign.
*/
static readonly PERCENT_SIGN: string = '%';
/**
* Decimal point.
*/
static readonly DOTS: string = '.';
/**
* Number two.
*/
static readonly TWO: number = 2;
/**
* Digit ten.
*/
static readonly TEN: number = 10;
/**
* One hundred.
*/
static readonly ONE_HUNDRED: string = '100';
/**
* Display Maximum Length of Large Fonts.
*/
static readonly INPUT_LENGTH_MAX: number = 9;
/**
* Subscript is two.
*/
static readonly INDEX_TWO: number = 2;
/**
* Maximum length of a single digit.
*/
static readonly NUM_MAX_LEN: number = 16;
/**
* Letter e.
*/
static readonly E: string = 'e';
/**
* String Zero.
*/
static readonly ZERO: string = '0'
/**
* zero point.
*/
static readonly ZERO_DOTS: string = '0.'
}
|
AST#export_declaration#Left export AST#class_declaration#Left class CommonConstants AST#class_body#Left { /**
* Full percent.
*/ AST#property_declaration#Left static readonly FULL_PERCENT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '100%' AST#expression#Right ; AST#property_declaration#Right /**
* Operator Collection.
*/ AST#property_declaration#Left static readonly OPERATORS : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '+-×÷' AST#expression#Right ; AST#property_declaration#Right /**
* Operators with high precedence.
*/ AST#property_declaration#Left static readonly OPERATORS_PRIORITY : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '×÷' AST#expression#Right ; AST#property_declaration#Right /**
* Addition.
*/ AST#property_declaration#Left static readonly ADD : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '+' AST#expression#Right ; AST#property_declaration#Right /**
* Minus.
*/ AST#property_declaration#Left static readonly MIN : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '-' AST#expression#Right ; AST#property_declaration#Right /**
* Multiplication.
*/ AST#property_declaration#Left static readonly MUL : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '×' AST#expression#Right ; AST#property_declaration#Right /**
* Division.
*/ AST#property_declaration#Left static readonly DIV : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '÷' AST#expression#Right ; AST#property_declaration#Right /**
* Percent sign.
*/ AST#property_declaration#Left static readonly PERCENT_SIGN : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '%' AST#expression#Right ; AST#property_declaration#Right /**
* Decimal point.
*/ AST#property_declaration#Left static readonly DOTS : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '.' AST#expression#Right ; AST#property_declaration#Right /**
* Number two.
*/ AST#property_declaration#Left static readonly TWO : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 2 AST#expression#Right ; AST#property_declaration#Right /**
* Digit ten.
*/ AST#property_declaration#Left static readonly TEN : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 10 AST#expression#Right ; AST#property_declaration#Right /**
* One hundred.
*/ AST#property_declaration#Left static readonly ONE_HUNDRED : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '100' AST#expression#Right ; AST#property_declaration#Right /**
* Display Maximum Length of Large Fonts.
*/ AST#property_declaration#Left static readonly INPUT_LENGTH_MAX : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 9 AST#expression#Right ; AST#property_declaration#Right /**
* Subscript is two.
*/ AST#property_declaration#Left static readonly INDEX_TWO : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 2 AST#expression#Right ; AST#property_declaration#Right /**
* Maximum length of a single digit.
*/ AST#property_declaration#Left static readonly NUM_MAX_LEN : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 16 AST#expression#Right ; AST#property_declaration#Right /**
* Letter e.
*/ AST#property_declaration#Left static readonly E : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'e' AST#expression#Right ; AST#property_declaration#Right /**
* String Zero.
*/ AST#property_declaration#Left static readonly ZERO : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '0' AST#expression#Right /**
* zero point.
*/ AST#property_declaration#Right AST#property_declaration#Left static readonly ZERO_DOTS : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '0.' AST#expression#Right AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class CommonConstants {
static readonly FULL_PERCENT: string = '100%';
static readonly OPERATORS: string = '+-×÷';
static readonly OPERATORS_PRIORITY: string = '×÷';
static readonly ADD: string = '+';
static readonly MIN: string = '-';
static readonly MUL: string = '×';
static readonly DIV: string = '÷';
static readonly PERCENT_SIGN: string = '%';
static readonly DOTS: string = '.';
static readonly TWO: number = 2;
static readonly TEN: number = 10;
static readonly ONE_HUNDRED: string = '100';
static readonly INPUT_LENGTH_MAX: number = 9;
static readonly INDEX_TWO: number = 2;
static readonly NUM_MAX_LEN: number = 16;
static readonly E: string = 'e';
static readonly ZERO: string = '0'
static readonly ZERO_DOTS: string = '0.'
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/ETSUI/SimpleCalculator/entry/src/main/ets/common/constants/CommonConstants.ets#L19-L109
|
27f82597fabc478abe9e58e5f6ac60bb5c7902f7
|
gitee
|
|
JHB11Hinson/mineMointorAPP.git
|
b6b853cf534021ac39e66c9b3a35113896a272b2
|
entry/src/main/ets/pages/DustMonitoringPage.ets
|
arkts
|
fetchData
|
获取数据的方法
|
async fetchData() {
this.isLoading = true;
try {
// 调用静态方法获取灰尘监测数据
this.dustList = await DustService.getDustList();
} catch (error) {
console.error('获取灰尘监测数据失败:', error);
// 错误提示
promptAction.showToast({
message: '获取灰尘监测数据失败,请检查网络连接',
duration: 2000
});
} finally {
this.isLoading = false;
}
}
|
AST#method_declaration#Left async fetchData AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLoading AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 调用静态方法获取灰尘监测数据 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dustList AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left DustService AST#expression#Right AST#await_expression#Right AST#expression#Right . getDustList AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '获取灰尘监测数据失败:' AST#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 错误提示 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left '获取灰尘监测数据失败,请检查网络连接' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left 2000 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#finally_clause#Left finally AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLoading AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#finally_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async fetchData() {
this.isLoading = true;
try {
this.dustList = await DustService.getDustList();
} catch (error) {
console.error('获取灰尘监测数据失败:', error);
promptAction.showToast({
message: '获取灰尘监测数据失败,请检查网络连接',
duration: 2000
});
} finally {
this.isLoading = false;
}
}
|
https://github.com/JHB11Hinson/mineMointorAPP.git/blob/b6b853cf534021ac39e66c9b3a35113896a272b2/entry/src/main/ets/pages/DustMonitoringPage.ets#L17-L33
|
f7b476eff3c983870654d37b42243cbb3aae64f6
|
github
|
chongzi/Lucky-ArkTs.git
|
84fc104d4a68def780a483e2543ebf9f53e793fd
|
entry/src/main/ets/common/AchievementManager.ets
|
arkts
|
initializeDefaultAchievements
|
初始化默认成就到数据库
|
async initializeDefaultAchievements(): Promise<void> {
try {
const existingAchievements = await this.databaseManager.getAllAchievements()
if (existingAchievements.length === 0) {
const defaultAchievements = this.getDefaultAchievements()
for (const achievement of defaultAchievements) {
await this.databaseManager.addAchievement(achievement)
}
console.info('默认成就初始化完成')
}
} catch (error) {
console.error('初始化默认成就失败:', error)
}
}
|
AST#method_declaration#Left async initializeDefaultAchievements AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left existingAchievements = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . databaseManager AST#member_expression#Right AST#expression#Right . getAllAchievements AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left existingAchievements AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left defaultAchievements = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getDefaultAchievements AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( const achievement of AST#expression#Left defaultAchievements AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . databaseManager AST#member_expression#Right AST#expression#Right . addAchievement AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left achievement AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '默认成就初始化完成' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '初始化默认成就失败:' AST#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async initializeDefaultAchievements(): Promise<void> {
try {
const existingAchievements = await this.databaseManager.getAllAchievements()
if (existingAchievements.length === 0) {
const defaultAchievements = this.getDefaultAchievements()
for (const achievement of defaultAchievements) {
await this.databaseManager.addAchievement(achievement)
}
console.info('默认成就初始化完成')
}
} catch (error) {
console.error('初始化默认成就失败:', error)
}
}
|
https://github.com/chongzi/Lucky-ArkTs.git/blob/84fc104d4a68def780a483e2543ebf9f53e793fd/entry/src/main/ets/common/AchievementManager.ets#L20-L33
|
f6c02ceb0ed604ec68f3f04905567b926935c364
|
github
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/SystemFeature/Security/DLP/entry/src/main/ets/component/CustomDialog.ets
|
arkts
|
promptPopup
|
弹窗函数
|
promptPopup() {
Logger.info(`promptPopup start`);
try {
promptAction.showToast({
message: $r('app.string.authorization_reminder'),
// 弹窗延迟时间
duration: 2000
});
} catch (error) {
let message = (error as BusinessError).message;
let code = (error as BusinessError).code;
Logger.error(`showToast args error code is ${code}, message is ${message}`);
}
}
|
AST#method_declaration#Left promptPopup AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` promptPopup start ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.authorization_reminder' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , // 弹窗延迟时间 AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left 2000 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left message = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left code = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . code AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` showToast args error code is AST#template_substitution#Left $ { AST#expression#Left code AST#expression#Right } AST#template_substitution#Right , message is AST#template_substitution#Left $ { AST#expression#Left message AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
promptPopup() {
Logger.info(`promptPopup start`);
try {
promptAction.showToast({
message: $r('app.string.authorization_reminder'),
duration: 2000
});
} catch (error) {
let message = (error as BusinessError).message;
let code = (error as BusinessError).code;
Logger.error(`showToast args error code is ${code}, message is ${message}`);
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/Security/DLP/entry/src/main/ets/component/CustomDialog.ets#L38-L51
|
9e6836a1ae1440bbd35af07afb009e2f48f3ae0c
|
gitee
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
AdaptiveCapabilities/entry/src/main/ets/pages/atomicLayoutCapability/flexibleCapability/FlexibleCapability2.ets
|
arkts
|
slider
|
Bottom slider - resize container by dragging the slider control.
|
@Builder
slider() {
Slider({ value: this.rate * 100, min: 55, max: 80 })
.blockColor(Color.White)
.width('60%')
.onChange((value: number) => {
this.rate = value / 100;
})
.position({ x: '20%', y: '80%' })
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right slider AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Slider ( AST#component_parameters#Left { AST#component_parameter#Left value : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rate AST#member_expression#Right AST#expression#Right * AST#expression#Left 100 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left min : AST#expression#Left 55 AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left max : AST#expression#Left 80 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . blockColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '60%' AST#expression#Right ) AST#modifier_chain_expression#Left . onChange ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rate AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left value AST#expression#Right / AST#expression#Left 100 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Left . position ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left '20%' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left '80%' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
slider() {
Slider({ value: this.rate * 100, min: 55, max: 80 })
.blockColor(Color.White)
.width('60%')
.onChange((value: number) => {
this.rate = value / 100;
})
.position({ x: '20%', y: '80%' })
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/AdaptiveCapabilities/entry/src/main/ets/pages/atomicLayoutCapability/flexibleCapability/FlexibleCapability2.ets#L23-L32
|
dbde637477c84a39747bf5f3db0f27adb576a97b
|
gitee
|
Piagari/arkts_example.git
|
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
|
hmos_app-main/hmos_app-main/legado-Harmony-master/entry/src/main/ets/common/constants/MySetConstants.ets
|
arkts
|
Common constants for all features.
|
export default class MySetConstants {
/**
* 自动刷新
*/
static readonly SET_REFRESH: string = 'setRefresh';
/**
* 自动跳转最近阅读
*/
static readonly SET_JUMP: string = 'setJump';
/**
* 默认启用替换净化
*/
static readonly SET_REPLACE: string = 'setReplace';
/**
*返回时提示放入书架
*/
static readonly SET_TIP: string = 'setTip';
/**
*图片抗锯齿
*/
static readonly SET_IMG_ANTI: string = 'setImgAnti';
/**
*Webservice唤醒锁
*/
static readonly SET_AWAKEN: string = 'setAwaken';
/**
*全程响应耳机按键
*/
static readonly SET_HEAD: string = 'setHead';
/**
*文字操作显示搜索
*/
static readonly SET_SEARCH: string = 'setSearch';
static readonly SET_BOOK_SAVE: string = 'setBookSave';
static readonly SET_PRE_DOWNLOAD: string = 'setPreDownload';
static readonly SET_IMG_CACHE: string = 'setImgCache';
static readonly SET_WEB_PORT: string = 'setWebPort';
static readonly SET_CLEAR_WEB: string = 'setClearWeb';
static readonly SET_USER_AGENT: string = 'setUserAgent';
static readonly SET_LANGUAGE: string = 'setLanguage';
}
|
AST#export_declaration#Left export default AST#class_declaration#Left class MySetConstants AST#class_body#Left { /**
* 自动刷新
*/ AST#property_declaration#Left static readonly SET_REFRESH : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'setRefresh' AST#expression#Right ; AST#property_declaration#Right /**
* 自动跳转最近阅读
*/ AST#property_declaration#Left static readonly SET_JUMP : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'setJump' AST#expression#Right ; AST#property_declaration#Right /**
* 默认启用替换净化
*/ AST#property_declaration#Left static readonly SET_REPLACE : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'setReplace' AST#expression#Right ; AST#property_declaration#Right /**
*返回时提示放入书架
*/ AST#property_declaration#Left static readonly SET_TIP : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'setTip' AST#expression#Right ; AST#property_declaration#Right /**
*图片抗锯齿
*/ AST#property_declaration#Left static readonly SET_IMG_ANTI : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'setImgAnti' AST#expression#Right ; AST#property_declaration#Right /**
*Webservice唤醒锁
*/ AST#property_declaration#Left static readonly SET_AWAKEN : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'setAwaken' AST#expression#Right ; AST#property_declaration#Right /**
*全程响应耳机按键
*/ AST#property_declaration#Left static readonly SET_HEAD : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'setHead' AST#expression#Right ; AST#property_declaration#Right /**
*文字操作显示搜索
*/ AST#property_declaration#Left static readonly SET_SEARCH : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'setSearch' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly SET_BOOK_SAVE : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'setBookSave' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly SET_PRE_DOWNLOAD : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'setPreDownload' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly SET_IMG_CACHE : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'setImgCache' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly SET_WEB_PORT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'setWebPort' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly SET_CLEAR_WEB : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'setClearWeb' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly SET_USER_AGENT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'setUserAgent' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left static readonly SET_LANGUAGE : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'setLanguage' AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export default class MySetConstants {
static readonly SET_REFRESH: string = 'setRefresh';
static readonly SET_JUMP: string = 'setJump';
static readonly SET_REPLACE: string = 'setReplace';
static readonly SET_TIP: string = 'setTip';
static readonly SET_IMG_ANTI: string = 'setImgAnti';
static readonly SET_AWAKEN: string = 'setAwaken';
static readonly SET_HEAD: string = 'setHead';
static readonly SET_SEARCH: string = 'setSearch';
static readonly SET_BOOK_SAVE: string = 'setBookSave';
static readonly SET_PRE_DOWNLOAD: string = 'setPreDownload';
static readonly SET_IMG_CACHE: string = 'setImgCache';
static readonly SET_WEB_PORT: string = 'setWebPort';
static readonly SET_CLEAR_WEB: string = 'setClearWeb';
static readonly SET_USER_AGENT: string = 'setUserAgent';
static readonly SET_LANGUAGE: string = 'setLanguage';
}
|
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/legado-Harmony-master/entry/src/main/ets/common/constants/MySetConstants.ets#L19-L74
|
5f93516d4d51b2522aefaf1084c117d4c8547494
|
github
|
|
zl3624/harmonyos_network_samples
|
b8664f8bf6ef5c5a60830fe616c6807e83c21f96
|
code/web/UploadInWeb/entry/src/main/ets/pages/Index.ets
|
arkts
|
copySelFile2Sandbox
|
复制选中文件到沙箱
|
copySelFile2Sandbox(selectFile: string): boolean {
let context = getContext(this)
let segments = selectFile.split('/')
//文件名称
let fileName = segments[segments.length-1]
//计划复制到的目标路径
let realUri = context.cacheDir + "/" + fileName
//复制选择的文件到沙箱cache文件夹
try {
let file = fs.openSync(selectFile);
fs.copyFileSync(file.fd, realUri)
this.sandboxFilePath = realUri
return true
} catch (err) {
console.error(err.message)
}
return false
}
|
AST#method_declaration#Left copySelFile2Sandbox AST#parameter_list#Left ( AST#parameter#Left selectFile : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left context = AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( AST#expression#Left this AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left segments = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left selectFile AST#expression#Right . split AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '/' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right //文件名称 AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left fileName = AST#expression#Left AST#subscript_expression#Left AST#expression#Left segments AST#expression#Right [ AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left segments AST#expression#Right . length AST#member_expression#Right AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right //计划复制到的目标路径 AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left realUri = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . cacheDir AST#member_expression#Right AST#expression#Right + AST#expression#Left "/" AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left fileName AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right //复制选择的文件到沙箱cache文件夹 AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left file = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fs AST#expression#Right . openSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left selectFile AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fs AST#expression#Right . copyFileSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left file AST#expression#Right . fd AST#member_expression#Right AST#expression#Right , AST#expression#Left realUri AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sandboxFilePath AST#member_expression#Right = AST#expression#Left realUri AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
copySelFile2Sandbox(selectFile: string): boolean {
let context = getContext(this)
let segments = selectFile.split('/')
let fileName = segments[segments.length-1]
let realUri = context.cacheDir + "/" + fileName
try {
let file = fs.openSync(selectFile);
fs.copyFileSync(file.fd, realUri)
this.sandboxFilePath = realUri
return true
} catch (err) {
console.error(err.message)
}
return false
}
|
https://github.com/zl3624/harmonyos_network_samples/blob/b8664f8bf6ef5c5a60830fe616c6807e83c21f96/code/web/UploadInWeb/entry/src/main/ets/pages/Index.ets#L175-L192
|
1daba02d33910eeb39fbb656694ce12253db1019
|
gitee
|
openharmony-tpc/ohos_mpchart
|
4fb43a7137320ef2fee2634598f53d93975dfb4a
|
library/src/main/ets/components/components/AxisBase.ets
|
arkts
|
setAxisLineWidth
|
Sets the width of the border surrounding the chart in vp.
@param width
|
public setAxisLineWidth(width: number): void {
this.mAxisLineWidth = Utils.handleDataValues(width);
}
|
AST#method_declaration#Left public setAxisLineWidth AST#parameter_list#Left ( AST#parameter#Left width : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mAxisLineWidth AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Utils AST#expression#Right . handleDataValues AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left width AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
public setAxisLineWidth(width: number): void {
this.mAxisLineWidth = Utils.handleDataValues(width);
}
|
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/components/AxisBase.ets#L285-L287
|
dd653ce1c307f3ffa2ddefc0f3ee2387fb6d0328
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
harmonyos/src/main/ets/pages/CalendarPage.ets
|
arkts
|
loadUpcomingBirthdays
|
加载即将到来的生日
|
private async loadUpcomingBirthdays(): Promise<void> {
try {
this.upcomingBirthdays = await this.contactService.getUpcomingBirthdayContacts(30);
} catch (error) {
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to load upcoming birthdays: ${error}`);
}
}
|
AST#method_declaration#Left private async loadUpcomingBirthdays AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . upcomingBirthdays AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . contactService AST#member_expression#Right AST#expression#Right . getUpcomingBirthdayContacts AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 30 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to load upcoming birthdays: AST#template_substitution#Left $ { AST#expression#Left error AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private async loadUpcomingBirthdays(): Promise<void> {
try {
this.upcomingBirthdays = await this.contactService.getUpcomingBirthdayContacts(30);
} catch (error) {
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to load upcoming birthdays: ${error}`);
}
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/pages/CalendarPage.ets#L83-L89
|
74000cd110adf48c4d2dae707b96b79a76a4d861
|
github
|
jxdiaodeyi/YX_Sports.git
|
af5346bd3d5003c33c306ff77b4b5e9184219893
|
YX_Sports/entry/src/main/ets/pages/practice/TrainRecordPage.ets
|
arkts
|
getDayData
|
收取数据
|
async getDayData() {
let httpRequest=http.createHttp();
let encodeduserId = encodeURIComponent(this.userId); // 编码中文
let encodedDate = encodeURIComponent(this.firstDayOfWeek); // 起始日期
let url = address.IP+`/getWeekPracticeInfo?userId=${encodeduserId}&startDate=${encodedDate}`;
try {
let response=await httpRequest.request(url,{
method:http.RequestMethod.GET,
header:{
'Content-Type': 'application/json',
'Authorization': `Bearer ${this.token}`
}
});
let result=JSON.parse(response.result as string) as ResponseData;
if(result.code===200)
{
this.workoutDayData=result.data
//this.isfetchGraphData=true;
}
}
catch (err) {
promptAction.showToast({message:"网络错误"})
}
// 模拟数据
// this.workoutTimeDayData = {
//
// totalDuration: 102,
// dailyData: [
// { dayOfWeek: '一', duration: 25 },
// { dayOfWeek: '二', duration: 67 },
// { dayOfWeek: '三', duration: 39 },
// { dayOfWeek: '四', duration: 100 },
// { dayOfWeek: '五', duration: 20 },
// { dayOfWeek: '六', duration: 0 },
// { dayOfWeek: '日', duration: 10 }
// ]
// };
}
|
AST#method_declaration#Left async getDayData AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left httpRequest = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . createHttp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left encodeduserId = AST#expression#Left AST#call_expression#Left AST#expression#Left encodeURIComponent AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . userId AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 编码中文 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left encodedDate = AST#expression#Left AST#call_expression#Left AST#expression#Left encodeURIComponent AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . firstDayOfWeek AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 起始日期 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left url = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left address AST#expression#Right . IP AST#member_expression#Right AST#expression#Right + AST#expression#Left AST#template_literal#Left ` /getWeekPracticeInfo?userId= AST#template_substitution#Left $ { AST#expression#Left encodeduserId AST#expression#Right } AST#template_substitution#Right &startDate= AST#template_substitution#Left $ { AST#expression#Left encodedDate AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left response = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left httpRequest AST#expression#Right AST#await_expression#Right AST#expression#Right . request AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left url AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left method AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . RequestMethod AST#member_expression#Right AST#expression#Right . GET AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left header AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left 'Content-Type' AST#property_name#Right : AST#expression#Left 'application/json' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'Authorization' AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` Bearer AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . token AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left result = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . result AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left ResponseData AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . code AST#member_expression#Right AST#expression#Right === AST#expression#Left 200 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . workoutDayData AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . data AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right //this.isfetchGraphData=true; } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left "网络错误" AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right // 模拟数据 // this.workoutTimeDayData = { // // totalDuration: 102, // dailyData: [ // { dayOfWeek: '一', duration: 25 }, // { dayOfWeek: '二', duration: 67 }, // { dayOfWeek: '三', duration: 39 }, // { dayOfWeek: '四', duration: 100 }, // { dayOfWeek: '五', duration: 20 }, // { dayOfWeek: '六', duration: 0 }, // { dayOfWeek: '日', duration: 10 } // ] // }; } AST#block_statement#Right AST#method_declaration#Right
|
async getDayData() {
let httpRequest=http.createHttp();
let encodeduserId = encodeURIComponent(this.userId);
let encodedDate = encodeURIComponent(this.firstDayOfWeek);
let url = address.IP+`/getWeekPracticeInfo?userId=${encodeduserId}&startDate=${encodedDate}`;
try {
let response=await httpRequest.request(url,{
method:http.RequestMethod.GET,
header:{
'Content-Type': 'application/json',
'Authorization': `Bearer ${this.token}`
}
});
let result=JSON.parse(response.result as string) as ResponseData;
if(result.code===200)
{
this.workoutDayData=result.data
}
}
catch (err) {
promptAction.showToast({message:"网络错误"})
}
totalDuration: 102,
dailyData: [
{ dayOfWeek: '一', duration: 25 },
{ dayOfWeek: '二', duration: 67 },
{ dayOfWeek: '三', duration: 39 },
{ dayOfWeek: '四', duration: 100 },
{ dayOfWeek: '五', duration: 20 },
{ dayOfWeek: '六', duration: 0 },
{ dayOfWeek: '日', duration: 10 }
]
};
}
|
https://github.com/jxdiaodeyi/YX_Sports.git/blob/af5346bd3d5003c33c306ff77b4b5e9184219893/YX_Sports/entry/src/main/ets/pages/practice/TrainRecordPage.ets#L210-L248
|
9f2a7b0e4cdcf54ebeab4f5b3bbb25c2d1ebc5be
|
github
|
buqiuz/game-puzzle.git
|
605dc0fac0738466db308a8ba255b5e9094c52ac
|
entry/build/default/generated/profile/default/BuildProfile.ets
|
arkts
|
Use these variables when you tailor your ArkTS code. They must be of the const type.
|
export const BUNDLE_NAME = 'ohos.samples.gamepuzzle';
|
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left BUNDLE_NAME = AST#expression#Left 'ohos.samples.gamepuzzle' AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
|
export const BUNDLE_NAME = 'ohos.samples.gamepuzzle';
|
https://github.com/buqiuz/game-puzzle.git/blob/605dc0fac0738466db308a8ba255b5e9094c52ac/entry/build/default/generated/profile/default/BuildProfile.ets#L4-L4
|
48fdfc60821c5c2a267e3abc706077864061d194
|
github
|
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/RandomUtil.ets
|
arkts
|
getRandomNumber
|
生成指定范围内的随机数
@return 随机数
|
static getRandomNumber(min: number, max: number): number {
return Math.floor(Math.random() * (max - min) + min);
}
|
AST#method_declaration#Left static getRandomNumber AST#parameter_list#Left ( AST#parameter#Left min : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left max : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . random AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right * AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left max AST#expression#Right - AST#expression#Left min AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left min AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static getRandomNumber(min: number, max: number): number {
return Math.floor(Math.random() * (max - min) + min);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/RandomUtil.ets#L50-L52
|
844dfbe6fef0cf4b507c43065931bdb2f61d8836
|
gitee
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/common/utils/strings/StringEncrypt.ets
|
arkts
|
stringToUint8Array
|
字符串转Uint8Array
@param str 要转换的字符串
@returns Uint8Array
|
private stringToUint8Array(str: string): Uint8Array {
// 方案1:推荐使用buffer.from(API 9+)
return new Uint8Array(buffer.from(str, 'utf-8').buffer);
// 方案2:TextEncoder标准方案(需处理缓冲区)
// const encoder = new util.TextEncoder('utf-8');
// const arr = new Uint8Array(encoder.getEncodedLength(str));
// encoder.encodeIntoUint8Array(str, arr);
// return arr;
}
|
AST#method_declaration#Left private stringToUint8Array AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 方案1:推荐使用buffer.from(API 9+) AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Uint8Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left buffer AST#expression#Right . from AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left 'utf-8' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . buffer AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right // 方案2:TextEncoder标准方案(需处理缓冲区) // const encoder = new util.TextEncoder('utf-8'); // const arr = new Uint8Array(encoder.getEncodedLength(str)); // encoder.encodeIntoUint8Array(str, arr); // return arr; } AST#block_statement#Right AST#method_declaration#Right
|
private stringToUint8Array(str: string): Uint8Array {
return new Uint8Array(buffer.from(str, 'utf-8').buffer);
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/utils/strings/StringEncrypt.ets#L130-L139
|
b2f78ef77f7809a27a4ee140d5c44f485272caf2
|
github
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/module.ets
|
arkts
|
[Start module_load_directly]
|
export function initialize() {
console.log('Module loaded!');
}
|
AST#export_declaration#Left export AST#function_declaration#Left function initialize AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Module loaded!' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export function initialize() {
console.log('Module loaded!');
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/TopCodeModification/module.ets#L17-L19
|
2782cd35962fa755c18ff30b21db3e1a31bc0ed3
|
gitee
|
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/pages/Index.ets
|
arkts
|
handleDateClick
|
处理日期点击事件
|
private async handleDateClick(week: number, dayOfWeek: number): Promise<void> {
const dayNumber: number = this.getDayNumber(week, dayOfWeek);
const currentDate = new Date(this.currentYear, this.currentMonth - 1, dayNumber);
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[Debug] handleDateClick called for ${currentDate.toDateString()}`);
try {
// 获取日期详细信息
const birthdays = this.getBirthdayContactsOnDay(dayNumber);
const anniversaries = this.getAnniversariesOnDate(currentDate);
const todos = this.getTodosOnDate(currentDate);
// 简化农历和节日信息获取,避免复杂的异步调用
const lunarInfo = LunarCalendar.solarToLunar(currentDate.getFullYear(), currentDate.getMonth() + 1, currentDate.getDate());
const lunarDate: LunarDate = lunarInfo ? {
year: lunarInfo.year,
month: lunarInfo.month,
day: lunarInfo.day,
isLeapMonth: lunarInfo.isLeapMonth,
yearText: lunarInfo.ganZhi,
monthText: lunarInfo.monthName,
dayText: lunarInfo.dayName,
fullText: `${lunarInfo.monthName}${lunarInfo.dayName}`,
zodiac: lunarInfo.zodiac,
ganZhi: lunarInfo.ganZhi
} : {
year: currentDate.getFullYear(),
month: currentDate.getMonth() + 1,
day: currentDate.getDate(),
isLeapMonth: false,
yearText: '',
monthText: '',
dayText: '',
fullText: `${currentDate.getMonth() + 1}月${currentDate.getDate()}日`,
zodiac: '',
ganZhi: ''
};
const dateDetail: DateDetail = {
gregorianDate: currentDate,
lunarDate: lunarDate,
festivals: [], // 简化处理
solarTerm: undefined, // 简化处理
weekday: this.getWeekdayName(currentDate.getDay()),
isWorkday: currentDate.getDay() !== 0 && currentDate.getDay() !== 6,
birthdays,
anniversaries,
todos
};
// 缓存农历信息
const dateKey = this.formatDateKey(currentDate);
this.lunarDateCache.set(dateKey, lunarDate);
// 设置选中的日期和详情
this.selectedDate = currentDate;
this.selectedDateDetail = dateDetail;
this.showDateActionPanel = true;
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[Debug] Date action panel should now show for ${currentDate.toDateString()}`);
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[Debug] State values - selectedDate: ${this.selectedDate !== null}, selectedDateDetail: ${this.selectedDateDetail !== null}, showDateActionPanel: ${this.showDateActionPanel}`);
} catch (error) {
console.error('获取日期详情失败:', error);
// 显示简单的日期信息
promptAction.showToast({
message: `${this.currentYear}年${this.currentMonth}月${dayNumber}日`,
duration: 1500
});
}
}
|
AST#method_declaration#Left private async handleDateClick AST#parameter_list#Left ( AST#parameter#Left week : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left dayOfWeek : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left dayNumber : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getDayNumber AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left week AST#expression#Right , AST#expression#Left dayOfWeek AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left currentDate = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentYear AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentMonth AST#member_expression#Right AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left dayNumber AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` [Debug] handleDateClick called for AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentDate AST#expression#Right . toDateString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 获取日期详细信息 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left birthdays = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getBirthdayContactsOnDay AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left dayNumber AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left anniversaries = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getAnniversariesOnDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left currentDate AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left todos = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getTodosOnDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left currentDate AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 简化农历和节日信息获取,避免复杂的异步调用 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left lunarInfo = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LunarCalendar AST#expression#Right . solarToLunar AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentDate AST#expression#Right . getFullYear AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentDate AST#expression#Right . getMonth AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentDate AST#expression#Right . getDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left lunarDate : AST#type_annotation#Left AST#primary_type#Left LunarDate AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#conditional_expression#Left AST#expression#Left lunarInfo AST#expression#Right ? AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left year AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left lunarInfo AST#expression#Right . year AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left month AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left lunarInfo AST#expression#Right . month AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left day AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left lunarInfo AST#expression#Right . day AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left isLeapMonth AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left lunarInfo AST#expression#Right . isLeapMonth AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left yearText AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left lunarInfo AST#expression#Right . ganZhi AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left monthText AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left lunarInfo AST#expression#Right . monthName AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left dayText AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left lunarInfo AST#expression#Right . dayName AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left fullText AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left lunarInfo AST#expression#Right . monthName AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left lunarInfo AST#expression#Right . dayName AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left zodiac AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left lunarInfo AST#expression#Right . zodiac AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left ganZhi AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left lunarInfo AST#expression#Right . ganZhi AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left year AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentDate AST#expression#Right . getFullYear AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left month AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentDate AST#expression#Right . getMonth AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left day AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentDate AST#expression#Right . getDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left isLeapMonth AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left yearText AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left monthText AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left dayText AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left fullText AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentDate AST#expression#Right . getMonth AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right } AST#template_substitution#Right 月 AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentDate AST#expression#Right . getDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right 日 ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left zodiac AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left ganZhi AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left dateDetail : AST#type_annotation#Left AST#primary_type#Left DateDetail AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left gregorianDate AST#property_name#Right : AST#expression#Left currentDate AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left lunarDate AST#property_name#Right : AST#expression#Left lunarDate AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left festivals AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right , // 简化处理 AST#property_assignment#Left AST#property_name#Left solarTerm AST#property_name#Right : AST#expression#Left undefined AST#expression#Right AST#property_assignment#Right , // 简化处理 AST#property_assignment#Left AST#property_name#Left weekday AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getWeekdayName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentDate AST#expression#Right . getDay AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left isWorkday AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentDate AST#expression#Right . getDay AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right !== AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left currentDate AST#expression#Right AST#binary_expression#Right AST#expression#Right . getDay AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right !== AST#expression#Left 6 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left birthdays AST#property_assignment#Right , AST#property_assignment#Left anniversaries AST#property_assignment#Right , AST#property_assignment#Left todos AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 缓存农历信息 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left dateKey = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . formatDateKey AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left currentDate AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . lunarDateCache AST#member_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left dateKey AST#expression#Right , AST#expression#Left lunarDate AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 设置选中的日期和详情 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedDate AST#member_expression#Right = AST#expression#Left currentDate AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedDateDetail AST#member_expression#Right = AST#expression#Left dateDetail AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showDateActionPanel AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` [Debug] Date action panel should now show for AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentDate AST#expression#Right . toDateString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` [Debug] State values - selectedDate: AST#template_substitution#Left $ { AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedDate AST#member_expression#Right AST#expression#Right !== AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right } AST#template_substitution#Right , selectedDateDetail: AST#template_substitution#Left $ { AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedDateDetail AST#member_expression#Right AST#expression#Right !== AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right } AST#template_substitution#Right , showDateActionPanel: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showDateActionPanel AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '获取日期详情失败:' AST#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 显示简单的日期信息 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentYear AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right 年 AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentMonth AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right 月 AST#template_substitution#Left $ { AST#expression#Left dayNumber AST#expression#Right } AST#template_substitution#Right 日 ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left 1500 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private async handleDateClick(week: number, dayOfWeek: number): Promise<void> {
const dayNumber: number = this.getDayNumber(week, dayOfWeek);
const currentDate = new Date(this.currentYear, this.currentMonth - 1, dayNumber);
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[Debug] handleDateClick called for ${currentDate.toDateString()}`);
try {
const birthdays = this.getBirthdayContactsOnDay(dayNumber);
const anniversaries = this.getAnniversariesOnDate(currentDate);
const todos = this.getTodosOnDate(currentDate);
const lunarInfo = LunarCalendar.solarToLunar(currentDate.getFullYear(), currentDate.getMonth() + 1, currentDate.getDate());
const lunarDate: LunarDate = lunarInfo ? {
year: lunarInfo.year,
month: lunarInfo.month,
day: lunarInfo.day,
isLeapMonth: lunarInfo.isLeapMonth,
yearText: lunarInfo.ganZhi,
monthText: lunarInfo.monthName,
dayText: lunarInfo.dayName,
fullText: `${lunarInfo.monthName}${lunarInfo.dayName}`,
zodiac: lunarInfo.zodiac,
ganZhi: lunarInfo.ganZhi
} : {
year: currentDate.getFullYear(),
month: currentDate.getMonth() + 1,
day: currentDate.getDate(),
isLeapMonth: false,
yearText: '',
monthText: '',
dayText: '',
fullText: `${currentDate.getMonth() + 1}月${currentDate.getDate()}日`,
zodiac: '',
ganZhi: ''
};
const dateDetail: DateDetail = {
gregorianDate: currentDate,
lunarDate: lunarDate,
festivals: [],
solarTerm: undefined,
weekday: this.getWeekdayName(currentDate.getDay()),
isWorkday: currentDate.getDay() !== 0 && currentDate.getDay() !== 6,
birthdays,
anniversaries,
todos
};
const dateKey = this.formatDateKey(currentDate);
this.lunarDateCache.set(dateKey, lunarDate);
this.selectedDate = currentDate;
this.selectedDateDetail = dateDetail;
this.showDateActionPanel = true;
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[Debug] Date action panel should now show for ${currentDate.toDateString()}`);
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[Debug] State values - selectedDate: ${this.selectedDate !== null}, selectedDateDetail: ${this.selectedDateDetail !== null}, showDateActionPanel: ${this.showDateActionPanel}`);
} catch (error) {
console.error('获取日期详情失败:', error);
promptAction.showToast({
message: `${this.currentYear}年${this.currentMonth}月${dayNumber}日`,
duration: 1500
});
}
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/Index.ets#L4226-L4297
|
9eac3fe674aa0337c680b4b4fcba13a8ab47b2eb
|
github
|
BohanSu/LumosAgent-HarmonyOS.git
|
9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76
|
entry/src/main/ets/view/AvatarComponent.ets
|
arkts
|
getEmotionColorBlend
|
根据情绪返回颜色叠加效果
|
private getEmotionColorBlend(): Color | string {
if (this.emotion === 'angry') {
return 'rgba(255, 45, 45, 0.2)'; // 红色叠加
} else if (this.emotion === 'sad') {
return 'rgba(43, 76, 138, 0.15)'; // 蓝色叠加
} else if (this.emotion === 'happy' || this.emotion === 'excited') {
return 'rgba(255, 143, 177, 0.1)'; // 粉色叠加
}
return Color.Transparent;
}
|
AST#method_declaration#Left private getEmotionColorBlend AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Color AST#primary_type#Right | AST#primary_type#Left string AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . emotion AST#member_expression#Right AST#expression#Right === AST#expression#Left 'angry' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left 'rgba(255, 45, 45, 0.2)' AST#expression#Right ; AST#return_statement#Right AST#statement#Right // 红色叠加 } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . emotion AST#member_expression#Right AST#expression#Right === AST#expression#Left 'sad' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left 'rgba(43, 76, 138, 0.15)' AST#expression#Right ; AST#return_statement#Right AST#statement#Right // 蓝色叠加 } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . emotion AST#member_expression#Right AST#expression#Right === AST#expression#Left 'happy' AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . emotion AST#member_expression#Right AST#expression#Right === AST#expression#Left 'excited' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left 'rgba(255, 143, 177, 0.1)' AST#expression#Right ; AST#return_statement#Right AST#statement#Right // 粉色叠加 } AST#block_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Transparent AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private getEmotionColorBlend(): Color | string {
if (this.emotion === 'angry') {
return 'rgba(255, 45, 45, 0.2)';
} else if (this.emotion === 'sad') {
return 'rgba(43, 76, 138, 0.15)';
} else if (this.emotion === 'happy' || this.emotion === 'excited') {
return 'rgba(255, 143, 177, 0.1)';
}
return Color.Transparent;
}
|
https://github.com/BohanSu/LumosAgent-HarmonyOS.git/blob/9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76/entry/src/main/ets/view/AvatarComponent.ets#L572-L581
|
33daf823db030a6c20a545f5223206f2a49688f7
|
github
|
Joker-x-dev/CoolMallArkTS.git
|
9f3fabf89fb277692cb82daf734c220c7282919c
|
feature/cs/Index.ets
|
arkts
|
CsGraph
|
@file cs 模块统一导出
@author Joker.X
|
export { CsGraph } from "./src/main/ets/navigation/CsGraph";
|
AST#export_declaration#Left export { CsGraph } from "./src/main/ets/navigation/CsGraph" ; AST#export_declaration#Right
|
export { CsGraph } from "./src/main/ets/navigation/CsGraph";
|
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/cs/Index.ets#L6-L6
|
0a4054a35ae0b64121187012c1d0664d23e8ceb5
|
github
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/groupavatar/src/main/ets/utils/ImageCombination.ets
|
arkts
|
ImageCombination
|
功能描述:点击完成之后,将选定的用户头像进行拼接,最终合成一个图片进行渲染。
实现原理:
绘制组件
1)使用divideImage2Group函数分割选择的用户头像数据,生成二维数组,已达到群头像排列方式,并设置图片宽高
2)结合二位数组,嵌套2层ForEach组件实现纵向与横向的线性布局,绘制群头像
3)设置id与visibility属性,用于隐藏组件及后续的组件截图
@param {PersonData} imageArr - 已选择的联系人头像
@param {SnapShotModel | null} snapShotModel - 组件截图属性类
|
@Component
export struct ImageCombination {
// ---------------对外暴露变量-----------------
// 已选择的联系人头像
imageArr: (ResourceStr | image.PixelMap)[] = [];
// 组件截图属性类
snapShotModel: SnapShotModel | null = null;
aboutToAppear(): void {
if (!this.snapShotModel) {
this.snapShotModel = new SnapShotModel();
}
}
build() {
// 绘制组件,用于绘制群组头像
Column({ space: 2 }) {
ForEach(divideImage2Group(this.imageArr), (item: GroupAvatarModel[]) => {
RowComponent(item)
})
}
// 设置组件ID,用于进行组件截图
.id(this.snapShotModel?.getComponentId())
.width($r('app.integer.group_avatar_custom_loading_drawing_size'))
.height($r('app.integer.group_avatar_custom_loading_drawing_size'))
.justifyContent(FlexAlign.Center)
// 设置组件隐藏
.visibility(Visibility.Hidden)
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ImageCombination AST#component_body#Left { // ---------------对外暴露变量----------------- // 已选择的联系人头像 AST#property_declaration#Left imageArr : AST#ERROR#Left AST#primary_type#Left AST#parenthesized_type#Left ( AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ResourceStr AST#primary_type#Right | AST#primary_type#Left AST#qualified_type#Left image . PixelMap AST#qualified_type#Right AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ) AST#parenthesized_type#Right AST#primary_type#Right AST#ERROR#Right AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right // 组件截图属性类 AST#property_declaration#Left snapShotModel : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left SnapShotModel AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . snapShotModel AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . snapShotModel AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left SnapShotModel AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { // 绘制组件,用于绘制群组头像 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 2 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#for_each_statement#Left ForEach ( AST#expression#Left AST#call_expression#Left AST#expression#Left divideImage2Group AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imageArr AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left GroupAvatarModel [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left RowComponent ( AST#expression#Left item AST#expression#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right // 设置组件ID,用于进行组件截图 AST#modifier_chain_expression#Left . id ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . snapShotModel AST#member_expression#Right AST#expression#Right ?. getComponentId AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.group_avatar_custom_loading_drawing_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.group_avatar_custom_loading_drawing_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) // 设置组件隐藏 AST#modifier_chain_expression#Left . visibility ( AST#expression#Left AST#member_expression#Left AST#expression#Left Visibility AST#expression#Right . Hidden AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct ImageCombination {
imageArr: (ResourceStr | image.PixelMap)[] = [];
snapShotModel: SnapShotModel | null = null;
aboutToAppear(): void {
if (!this.snapShotModel) {
this.snapShotModel = new SnapShotModel();
}
}
build() {
Column({ space: 2 }) {
ForEach(divideImage2Group(this.imageArr), (item: GroupAvatarModel[]) => {
RowComponent(item)
})
}
.id(this.snapShotModel?.getComponentId())
.width($r('app.integer.group_avatar_custom_loading_drawing_size'))
.height($r('app.integer.group_avatar_custom_loading_drawing_size'))
.justifyContent(FlexAlign.Center)
.visibility(Visibility.Hidden)
}
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/groupavatar/src/main/ets/utils/ImageCombination.ets#L32-L61
|
d4d742294150b1b95133c36ed8dfff2e2e4766d2
|
gitee
|
L1rics06/arkTS-.git
|
991fd131bfdb11e2933152133c97453d86092ac0
|
entry/src/main/ets/pages/NetworkUtil.ets
|
arkts
|
getAuthToken
|
添加获取token的方法
|
private static getAuthToken(): string {
return authToken;
}
|
AST#method_declaration#Left private static getAuthToken AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left authToken AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private static getAuthToken(): string {
return authToken;
}
|
https://github.com/L1rics06/arkTS-.git/blob/991fd131bfdb11e2933152133c97453d86092ac0/entry/src/main/ets/pages/NetworkUtil.ets#L555-L557
|
a76da65d7b2bfcf73c443ef6cd6d16bb99ad8856
|
github
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/verticalhorizontallinkage/src/main/ets/view/VerticalAndHorizontalList.ets
|
arkts
|
VerticalAndHorizontalListComponent
|
listItem的宽度
功能描述: 本示例主要通过List组件绑定Scroller滚动控制器和LazyForEach数据懒加载来实现纵向横向列表联动。
推荐场景: 汽车参数对比,股票信息查看
核心组件:
1. List
2. Scroller
3. LazyForEach
实现步骤:
1. 顶部List0:存放列标题,车型,底部左侧List1:存放行标题,车辆参数信息,底部右侧List3:存放不同车型对应的不同参数信息,List3里每一行内容对应一个List,不同List绑定不同的Scroller对象。
2. List0和List3里每一行内容对应的List的滚动偏移量保持一致,实现横向列表联动。
3. List1和List3的滚动偏移量保持一致,实现纵向列表联动。
|
@Component
export struct VerticalAndHorizontalListComponent {
private carType: string[] = ['车型1', '车型2', '车型3', '车型4', '车型5', '车型6', '车型7', '车型8']; // 顶部List内容,列标题
topListScroller: Scroller = new Scroller(); // 顶部列表(列标题)的滚动控制器
private bottomLeftListScroller: Scroller = new Scroller(); // 底部列表左侧(行标题)的滚动控制器
private bottomRightListScroller: Scroller = new Scroller(); // 底部列表右侧(展示内容)的滚动控制器
private showDataArray: Array<ShowData> = []; // 存储list内容,参数名(行标题)和不同车型的参数信息
private dataSource: BasicDataSource<ShowData> = new BasicDataSource();
private carTypeData: BasicDataSource<string> = new BasicDataSource();
private topListItemIndex: number = 0; // 顶部列表滚动到的第一个listItem索引号
private scrollerIndex: number = 0; // 右下列表横向滚动到的第一个listItem索引号
aboutToAppear(): void {
// 加载数据
this.loadShowData();
}
/**
* 读取car.json里的数据,用于展示行标题
*/
loadShowData(): void {
this.carTypeData.setData(this.carType);
const context: Context = getContext(this);
// 读取car.json里的数据
let jsonData: Uint8Array = context.resourceManager.getRawFileContentSync('car.json');
// 将数据解码,转成字符串
let stringData: string = util.TextDecoder.create('utf-8').decodeToString(jsonData);
let data: [] = JSON.parse(stringData) as [];
for (let i = 0; i < data.length; i++) {
const dataItem = data[i] as CarTypeData;
let showData: ShowData = new ShowData();
showData.sticky = dataItem.sticky;
showData.sub.setData(dataItem.sub)
// 保存Scroller数组,与左侧标题一一对应
showData.sub.getAllData().forEach((element: PartInfo) => {
let scroller: Scroller = new Scroller();
showData.scrollerArray.push(scroller);
})
this.showDataArray.push(showData);
}
this.dataSource.setData(this.showDataArray);
}
build() {
Column() {
this.topComponent();
Row() {
this.bottomLeftComponent();
this.bottomRightComponent();
}
.layoutWeight(1)
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
}
}
/**
* 顶部横向滚动列表,用于展示列标题:车型
*/
@Builder
topComponent() {
Row() {
Column() {
Text($r('app.string.vertical_horizontal_linkage_top_left_text_message'))
.fontColor(Color.Black)
.fontSize($r('app.string.vertical_horizontal_linkage_top_left_message_font_size'))
.fontWeight(FontWeight.Bold)
}
.padding($r('app.string.vertical_horizontal_linkage_vertical_horizontal_container_padding_size'))
.height($r('app.string.vertical_horizontal_linkage_list_item_height'))
.width($r('app.string.vertical_horizontal_linkage_list_item_width'))
.justifyContent(FlexAlign.Center)
// 分隔线
Line()
.height($r('app.string.vertical_horizontal_linkage_list_item_height'))
.width($r('app.string.vertical_horizontal_linkage_vertical_divider_line_width'))
.backgroundColor($r('app.color.vertical_horizontal_linkage_list_item_divider_line_color'))
List({ scroller: this.topListScroller }) {
LazyForEach(this.carTypeData, (item: string, index: number) => {
ListItem() {
CarTypeInfoItem({ info: item });
}
.id(`topListItem${index}`)
}, (item: string, index: number) => item);
}
.cachedCount(LIST_PRElOAD_NUMBER)
.edgeEffect(EdgeEffect.None) // 将边缘滑动效果设置为无
.listDirection(Axis.Horizontal) // 设置滚动方向为横向滚动
.divider({ strokeWidth: 0.5, color: $r('app.color.vertical_horizontal_linkage_list_item_divider_line_color') })
.scrollBar(BarState.Off)
.width(CALCULATED_SIZE)
.height($r('app.string.vertical_horizontal_linkage_top_List_height_size'))
.onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => {
this.topListItemIndex = firstIndex;
})
.onScrollFrameBegin((offset: number, state: ScrollState) => {
// list列表滚动到指定index后的额外偏移量
let scrollerOffset: number =
this.topListScroller.currentOffset().xOffset + offset - this.topListItemIndex * LIST_ITEM_WIDTH;
if (this.topListScroller.currentOffset().xOffset === 0) {
scrollerOffset = 0;
}
// 顶部列标题列表滚动时,让每一行的滚动控制器保持同步滚动,实现联动
this.showDataArray.forEach((showData: ShowData) => {
showData.scrollerArray.forEach((scroller: Scroller) => {
// 和顶部列表的listItem索引号保持一致
scroller.scrollToIndex(this.topListItemIndex, false, ScrollAlign.START,
{ extraOffset: LengthMetrics.vp(scrollerOffset) });
});
});
return { offsetRemain: offset };
})
}
.height($r('app.string.vertical_horizontal_linkage_list_item_height'))
}
/**
* 下部分左侧纵向滚动列表里的每一个行标题
* @param item 展示的数据
*/
@Builder
bottomLeftList(item: ShowData) {
// TODO:性能知识点:数据量较大,使用了[LazyForEach](https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-rendering-control-lazyforeach-V5) 进行数据懒加载优化,以降低内存占用和渲染开销
LazyForEach(item.sub, (partInfo: PartInfo, index: number) => {
ListItem() {
bottomLeftListItem({ partInfo: partInfo });
}
.id(`bottomLeftListItem${index}`)
}, (partInfo: PartInfo, index: number) => partInfo.part);
}
/**
* 下部分左侧纵向滚动列表,用于展示行标题
*/
@Builder
bottomLeftComponent() {
List({ scroller: this.bottomLeftListScroller }) {
// TODO:性能知识点:数据量较大,使用了[LazyForEach](https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-rendering-control-lazyforeach-V5) 进行数据懒加载优化,以降低内存占用和渲染开销
LazyForEach(this.dataSource, (item: ShowData, index: number) => {
ListItemGroup({ header: this.leftFixedTitle(item.sticky) }) {
this.bottomLeftList(item);
}
.border({
width: { right: '2px' },
color: $r('app.color.vertical_horizontal_linkage_list_item_divider_line_color'),
style: BorderStyle.Solid
})
}, (item: ShowData, index: number) => item.sticky + index);
}
.onScrollFrameBegin((offset: number, state: ScrollState) => {
// 通过控制右下列表的滚动控制器来保持和左下列表的联动
this.bottomRightListScroller.scrollTo({
xOffset: 0,
// 滚动偏移量为左下列表滚动控制器的当前偏移量+本次滚动的的偏移量
yOffset: this.bottomLeftListScroller.currentOffset().yOffset + offset
});
return { offsetRemain: offset };
})
.cachedCount(LIST_PRElOAD_NUMBER) // TODO:性能知识点: 列表较长,设置预加载数量减少性能消耗
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None) // 将边缘滑动效果设置为无,避免列表划动到底部后出现左右列表不联动问题
.listDirection(Axis.Vertical) // 设置滚动方向为纵向滚动
.sticky(StickyStyle.Header) // 设置ListItemGroup标题的吸顶效果
.width($r('app.string.vertical_horizontal_linkage_list_item_width'))
.height($r('app.string.vertical_horizontal_linkage_bottom_left_list_height_size'))
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
}
/**
* 下部分右侧纵向滚动列表里的每一行参数信息
* @param item 展示数据
*/
@Builder
bottomRightListItem(item: ShowData) {
// TODO:性能知识点:数据量较大,使用了[LazyForEach](https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-rendering-control-lazyforeach-V5) 进行数据懒加载优化,以降低内存占用和渲染开销
LazyForEach(item.sub, (partInfo: PartInfo, key: number) => {
ListItem() {
ItemComponent({
listContent: partInfo.info,
scroller: item.scrollerArray[key],
// 展示内容横向滚动时,控制顶部标题的滚动控制器和每一行内容的滚动控制器,保持联动
scrollCallback: (value) => {
// 顶部车型列表保持联动
this.topListScroller.scrollTo({ xOffset: value, yOffset: 0 });
// list列表滚动到指定index后的额外偏移量
let offsetX = value - this.scrollerIndex * LIST_ITEM_WIDTH;
if (item.scrollerArray[key].currentOffset().xOffset === 0) {
offsetX = 0;
}
this.showDataArray.forEach((showData: ShowData) => {
// 通过scroller数组保持联动
showData.scrollerArray.forEach((scroller: Scroller) => {
if (scroller !== item.scrollerArray[key]) {
// 其余List与当前正在滑动的List的索引号和额外偏移量保持一致
scroller.scrollToIndex(this.scrollerIndex, false, ScrollAlign.START,
{ extraOffset: LengthMetrics.vp(offsetX) });
}
})
})
},
// 展示内容横向滚动时,实时传回滚动偏移量
remainOffsetCallback: (index) => {
this.scrollerIndex = index;
}
});
}
.id(`bottomRightListItem${key}`)
}, (partInfo: PartInfo, key: number) => partInfo.part + key);
}
/**
* 下部分右侧纵向滚动列表,用于展示车型信息
*/
@Builder
bottomRightComponent() {
List({ scroller: this.bottomRightListScroller }) {
// TODO:性能知识点:数据量较大,使用了[LazyForEach](https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-rendering-control-lazyforeach-V5) 进行数据懒加载优化,以降低内存占用和渲染开销
LazyForEach(this.dataSource, (item: ShowData, index: number) => {
ListItemGroup({ header: this.rightFixedTitle(index) }) {
this.bottomRightListItem(item);
};
}, (item: ShowData, index: number) => item.sticky + index);
}
.onScrollFrameBegin((offset: number, state: ScrollState) => {
// 下方左侧行标题列表与下方右侧列表的滚动偏移量保持一致
this.bottomLeftListScroller.scrollTo({
xOffset: 0,
// 滚动偏移量为右下列表滚动控制器的当前偏移量+本次滚动的的偏移量
yOffset: this.bottomRightListScroller.currentOffset().yOffset + offset
});
return { offsetRemain: offset };
})
.onDidScroll((scrollOffset: number, scrollState: ScrollState) => {
// 行标题列表纵向滚动时,计算额外偏移量
let xOffset: number = this.topListScroller.currentOffset().xOffset - this.scrollerIndex * LIST_ITEM_WIDTH;
this.showDataArray.forEach((showData: ShowData) => {
showData.scrollerArray.forEach((scroller: Scroller) => {
// 行标题列表纵向滚动时,下方右侧的每一行展示内容的索引号和横向偏移量保持一致
scroller.scrollToIndex(this.scrollerIndex, false, ScrollAlign.START,
{ extraOffset: LengthMetrics.vp(xOffset) });
})
});
})
.cachedCount(LIST_PRElOAD_NUMBER) // TODO:性能知识点: 列表较长,设置预加载数量减少性能消耗
.width(CALCULATED_SIZE)
.height($r('app.string.vertical_horizontal_linkage_bottom_left_list_height_size'))
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None) // 将边缘滑动效果设置为无
.listDirection(Axis.Vertical) // 设置滚动方向为纵向滚动
.sticky(StickyStyle.Header) // 设置ListItemGroup标题的吸顶效果
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
}
/**
* 底部左侧纵向滚动列表的标题
* @param title 标题名
*/
@Builder
leftFixedTitle(title: string) {
Column() {
Text(title)
.fontWeight(FontWeight.Bold)
.height($r('app.string.vertical_horizontal_linkage_fixed_title_height_size'))
.textAlign(TextAlign.Start)
.padding($r('app.string.vertical_horizontal_linkage_vertical_horizontal_container_padding_size'))
}
.width($r('app.string.vertical_horizontal_linkage_list_item_width'))
.backgroundColor($r('app.color.vertical_horizontal_linkage_bottom_list_title_background_color'))
}
/**
* 底部右侧纵向滚动的标题
* @param index 索引值
*/
@Builder
rightFixedTitle(index: number) {
Text(index === 0 ? $r('app.string.vertical_horizontal_linkage_bottom_right_title_initial_content') :
$r('app.string.vertical_horizontal_linkage_bottom_right_title_content'))
.fontWeight(FontWeight.Bold)
.height($r('app.string.vertical_horizontal_linkage_fixed_title_height_size'))
.textAlign(TextAlign.End)
.padding($r('app.string.vertical_horizontal_linkage_vertical_horizontal_container_padding_size'))
.backgroundColor($r('app.color.vertical_horizontal_linkage_bottom_list_title_background_color'))
.width($r('app.string.vertical_horizontal_linkage_bottom_right_title_width_size'))
.onClick(() => {
promptAction.showToast({
message: $r('app.string.vertical_horizontal_linkage_bottom_right_title_click_content')
});
})
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct VerticalAndHorizontalListComponent AST#component_body#Left { AST#property_declaration#Left private carType : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left '车型1' AST#expression#Right , AST#expression#Left '车型2' AST#expression#Right , AST#expression#Left '车型3' AST#expression#Right , AST#expression#Left '车型4' AST#expression#Right , AST#expression#Left '车型5' AST#expression#Right , AST#expression#Left '车型6' AST#expression#Right , AST#expression#Left '车型7' AST#expression#Right , AST#expression#Left '车型8' AST#expression#Right ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right // 顶部List内容,列标题 AST#property_declaration#Left topListScroller : AST#type_annotation#Left AST#primary_type#Left Scroller AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Scroller AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right // 顶部列表(列标题)的滚动控制器 AST#property_declaration#Left private bottomLeftListScroller : AST#type_annotation#Left AST#primary_type#Left Scroller AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Scroller AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right // 底部列表左侧(行标题)的滚动控制器 AST#property_declaration#Left private bottomRightListScroller : AST#type_annotation#Left AST#primary_type#Left Scroller AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Scroller AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right // 底部列表右侧(展示内容)的滚动控制器 AST#property_declaration#Left private showDataArray : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left ShowData AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right // 存储list内容,参数名(行标题)和不同车型的参数信息 AST#property_declaration#Left private dataSource : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left BasicDataSource AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left ShowData AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left BasicDataSource AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private carTypeData : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left BasicDataSource AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left BasicDataSource AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private topListItemIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right // 顶部列表滚动到的第一个listItem索引号 AST#property_declaration#Left private scrollerIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right // 右下列表横向滚动到的第一个listItem索引号 AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { // 加载数据 AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . loadShowData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* 读取car.json里的数据,用于展示行标题
*/ AST#method_declaration#Left loadShowData AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . carTypeData AST#member_expression#Right AST#expression#Right . setData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . carType AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left context : AST#type_annotation#Left AST#primary_type#Left Context AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( AST#expression#Left this AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 读取car.json里的数据 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left jsonData : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . resourceManager AST#member_expression#Right AST#expression#Right . getRawFileContentSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'car.json' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 将数据解码,转成字符串 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left stringData : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left util AST#expression#Right . TextDecoder AST#member_expression#Right AST#expression#Right . create AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'utf-8' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . decodeToString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left jsonData AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left data : AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left stringData AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left data AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left dataItem = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left data AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left CarTypeData AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left showData : AST#type_annotation#Left AST#primary_type#Left ShowData AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ShowData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left showData AST#expression#Right . sticky AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left dataItem AST#expression#Right . sticky AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left showData AST#expression#Right . sub AST#member_expression#Right AST#expression#Right . setData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left dataItem AST#expression#Right . sub AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // 保存Scroller数组,与左侧标题一一对应 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left showData AST#expression#Right . sub AST#member_expression#Right AST#expression#Right . getAllData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left element : AST#type_annotation#Left AST#primary_type#Left PartInfo AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left scroller : AST#type_annotation#Left AST#primary_type#Left Scroller AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Scroller AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left showData AST#expression#Right . scrollerArray AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left scroller AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showDataArray AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left showData AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataSource AST#member_expression#Right AST#expression#Right . setData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showDataArray AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . topComponent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bottomLeftComponent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bottomRightComponent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . expandSafeArea ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left SafeAreaType AST#expression#Right . SYSTEM AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left SafeAreaEdge AST#expression#Right . BOTTOM AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right /**
* 顶部横向滚动列表,用于展示列标题:车型
*/ AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right topComponent AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_top_left_text_message' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Black AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_top_left_message_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_vertical_horizontal_container_padding_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_list_item_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_list_item_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 分隔线 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Line ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_list_item_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_vertical_divider_line_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.vertical_horizontal_linkage_list_item_divider_line_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left List ( AST#component_parameters#Left { AST#component_parameter#Left scroller : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . topListScroller AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#lazy_for_each_statement#Left LazyForEach ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . carTypeData AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ListItem ( ) AST#container_content_body#Left { AST#ui_custom_component_statement#Left CarTypeInfoItem ( AST#component_parameters#Left { AST#component_parameter#Left info : AST#expression#Left item AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . id ( AST#expression#Left AST#template_literal#Left ` topListItem AST#template_substitution#Left $ { AST#expression#Left index AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left item AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#lazy_for_each_statement#Right AST#ui_control_flow#Right AST#ERROR#Left ; AST#ERROR#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . cachedCount ( AST#expression#Left LIST_PRElOAD_NUMBER AST#expression#Right ) AST#modifier_chain_expression#Left . edgeEffect ( AST#expression#Left AST#member_expression#Left AST#expression#Left EdgeEffect AST#expression#Right . None AST#member_expression#Right AST#expression#Right ) // 将边缘滑动效果设置为无 AST#modifier_chain_expression#Left . listDirection ( AST#expression#Left AST#member_expression#Left AST#expression#Left Axis AST#expression#Right . Horizontal AST#member_expression#Right AST#expression#Right ) // 设置滚动方向为横向滚动 AST#modifier_chain_expression#Left . divider ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left strokeWidth AST#property_name#Right : AST#expression#Left 0.5 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.vertical_horizontal_linkage_list_item_divider_line_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . scrollBar ( AST#expression#Left AST#member_expression#Left AST#expression#Left BarState AST#expression#Right . Off AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left CALCULATED_SIZE AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_top_List_height_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onScrollIndex ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left firstIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left lastIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left centerIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . topListItemIndex AST#member_expression#Right = AST#expression#Left firstIndex AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onScrollFrameBegin ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left offset : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left state : AST#type_annotation#Left AST#primary_type#Left ScrollState AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // list列表滚动到指定index后的额外偏移量 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left scrollerOffset : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . topListScroller AST#member_expression#Right AST#expression#Right . currentOffset AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . xOffset AST#member_expression#Right AST#expression#Right + AST#expression#Left offset AST#expression#Right AST#binary_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . topListItemIndex AST#member_expression#Right AST#expression#Right * AST#expression#Left LIST_ITEM_WIDTH AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . topListScroller AST#member_expression#Right AST#expression#Right . currentOffset AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . xOffset AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left scrollerOffset = AST#expression#Left 0 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 顶部列标题列表滚动时,让每一行的滚动控制器保持同步滚动,实现联动 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showDataArray AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left showData : AST#type_annotation#Left AST#primary_type#Left ShowData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left showData AST#expression#Right . scrollerArray AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left scroller : AST#type_annotation#Left AST#primary_type#Left Scroller AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // 和顶部列表的listItem索引号保持一致 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left scroller AST#expression#Right . scrollToIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . topListItemIndex AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left ScrollAlign AST#expression#Right . START AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left extraOffset AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LengthMetrics AST#expression#Right . vp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left scrollerOffset AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left offsetRemain AST#property_name#Right : AST#expression#Left offset AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_list_item_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* 下部分左侧纵向滚动列表里的每一个行标题
* @param item 展示的数据
*/ AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right bottomLeftList AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left ShowData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { // TODO:性能知识点:数据量较大,使用了[LazyForEach](https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-rendering-control-lazyforeach-V5) 进行数据懒加载优化,以降低内存占用和渲染开销 AST#ui_control_flow#Left AST#lazy_for_each_statement#Left LazyForEach ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . sub AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left partInfo : AST#type_annotation#Left AST#primary_type#Left PartInfo AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ListItem ( ) AST#container_content_body#Left { AST#ui_custom_component_statement#Left bottomLeftListItem ( AST#component_parameters#Left { AST#component_parameter#Left partInfo : AST#expression#Left partInfo AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . id ( AST#expression#Left AST#template_literal#Left ` bottomLeftListItem AST#template_substitution#Left $ { AST#expression#Left index AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left partInfo : AST#type_annotation#Left AST#primary_type#Left PartInfo AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#member_expression#Left AST#expression#Left partInfo AST#expression#Right . part AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#lazy_for_each_statement#Right AST#ui_control_flow#Right AST#ERROR#Left ; AST#ERROR#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* 下部分左侧纵向滚动列表,用于展示行标题
*/ AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right bottomLeftComponent AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left List ( AST#component_parameters#Left { AST#component_parameter#Left scroller : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bottomLeftListScroller AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { // TODO:性能知识点:数据量较大,使用了[LazyForEach](https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-rendering-control-lazyforeach-V5) 进行数据懒加载优化,以降低内存占用和渲染开销 AST#ui_control_flow#Left AST#lazy_for_each_statement#Left LazyForEach ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataSource AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left ShowData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ListItemGroup ( AST#component_parameters#Left { AST#component_parameter#Left header : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftFixedTitle AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . sticky AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bottomLeftList AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left item AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . border ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left '2px' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.vertical_horizontal_linkage_list_item_divider_line_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left style AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left BorderStyle AST#expression#Right . Solid AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left ShowData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . sticky AST#member_expression#Right AST#expression#Right + AST#expression#Left index AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#lazy_for_each_statement#Right AST#ui_control_flow#Right AST#ERROR#Left ; AST#ERROR#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . onScrollFrameBegin ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left offset : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left state : AST#type_annotation#Left AST#primary_type#Left ScrollState AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // 通过控制右下列表的滚动控制器来保持和左下列表的联动 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bottomRightListScroller AST#member_expression#Right AST#expression#Right . scrollTo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left xOffset AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , // 滚动偏移量为左下列表滚动控制器的当前偏移量+本次滚动的的偏移量 AST#property_assignment#Left AST#property_name#Left yOffset AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bottomLeftListScroller AST#member_expression#Right AST#expression#Right . currentOffset AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . yOffset AST#member_expression#Right AST#expression#Right + AST#expression#Left offset AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left offsetRemain AST#property_name#Right : AST#expression#Left offset AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Left . cachedCount ( AST#expression#Left LIST_PRElOAD_NUMBER AST#expression#Right ) // TODO:性能知识点: 列表较长,设置预加载数量减少性能消耗 AST#modifier_chain_expression#Left . scrollBar ( AST#expression#Left AST#member_expression#Left AST#expression#Left BarState AST#expression#Right . Off AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . edgeEffect ( AST#expression#Left AST#member_expression#Left AST#expression#Left EdgeEffect AST#expression#Right . None AST#member_expression#Right AST#expression#Right ) // 将边缘滑动效果设置为无,避免列表划动到底部后出现左右列表不联动问题 AST#modifier_chain_expression#Left . listDirection ( AST#expression#Left AST#member_expression#Left AST#expression#Left Axis AST#expression#Right . Vertical AST#member_expression#Right AST#expression#Right ) // 设置滚动方向为纵向滚动 AST#modifier_chain_expression#Left . sticky ( AST#expression#Left AST#member_expression#Left AST#expression#Left StickyStyle AST#expression#Right . Header AST#member_expression#Right AST#expression#Right ) // 设置ListItemGroup标题的吸顶效果 AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_list_item_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_bottom_left_list_height_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . expandSafeArea ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left SafeAreaType AST#expression#Right . SYSTEM AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left SafeAreaEdge AST#expression#Right . BOTTOM AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* 下部分右侧纵向滚动列表里的每一行参数信息
* @param item 展示数据
*/ AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right bottomRightListItem AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left ShowData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { // TODO:性能知识点:数据量较大,使用了[LazyForEach](https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-rendering-control-lazyforeach-V5) 进行数据懒加载优化,以降低内存占用和渲染开销 AST#ui_control_flow#Left AST#lazy_for_each_statement#Left LazyForEach ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . sub AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left partInfo : AST#type_annotation#Left AST#primary_type#Left PartInfo AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ListItem ( ) AST#container_content_body#Left { AST#ui_custom_component_statement#Left ItemComponent ( AST#component_parameters#Left { AST#component_parameter#Left listContent : AST#expression#Left AST#member_expression#Left AST#expression#Left partInfo AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left scroller : AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . scrollerArray AST#member_expression#Right AST#expression#Right [ AST#expression#Left key AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#component_parameter#Right , // 展示内容横向滚动时,控制顶部标题的滚动控制器和每一行内容的滚动控制器,保持联动 AST#component_parameter#Left scrollCallback : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // 顶部车型列表保持联动 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . topListScroller AST#member_expression#Right AST#expression#Right . scrollTo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left xOffset AST#property_name#Right : AST#expression#Left value AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left yOffset AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // list列表滚动到指定index后的额外偏移量 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left offsetX = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left value AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . scrollerIndex AST#member_expression#Right AST#expression#Right * AST#expression#Left LIST_ITEM_WIDTH AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . scrollerArray AST#member_expression#Right AST#expression#Right [ AST#expression#Left key AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . currentOffset AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . xOffset AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left offsetX = AST#expression#Left 0 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showDataArray AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left showData : AST#type_annotation#Left AST#primary_type#Left ShowData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // 通过scroller数组保持联动 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left showData AST#expression#Right . scrollerArray AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left scroller : AST#type_annotation#Left AST#primary_type#Left Scroller AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left scroller AST#expression#Right !== AST#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . scrollerArray AST#member_expression#Right AST#expression#Right [ AST#expression#Left key AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#block_statement#Left { // 其余List与当前正在滑动的List的索引号和额外偏移量保持一致 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left scroller AST#expression#Right . scrollToIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scrollerIndex AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left ScrollAlign AST#expression#Right . START AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left extraOffset AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LengthMetrics AST#expression#Right . vp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left offsetX AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#component_parameter#Right , // 展示内容横向滚动时,实时传回滚动偏移量 AST#component_parameter#Left remainOffsetCallback : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left index AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scrollerIndex AST#member_expression#Right = AST#expression#Left index AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . id ( AST#expression#Left AST#template_literal#Left ` bottomRightListItem AST#template_substitution#Left $ { AST#expression#Left key AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left partInfo : AST#type_annotation#Left AST#primary_type#Left PartInfo AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left partInfo AST#expression#Right . part AST#member_expression#Right AST#expression#Right + AST#expression#Left key AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#lazy_for_each_statement#Right AST#ui_control_flow#Right AST#ERROR#Left ; AST#ERROR#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* 下部分右侧纵向滚动列表,用于展示车型信息
*/ AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right bottomRightComponent AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left List ( AST#component_parameters#Left { AST#component_parameter#Left scroller : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bottomRightListScroller AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { // TODO:性能知识点:数据量较大,使用了[LazyForEach](https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-rendering-control-lazyforeach-V5) 进行数据懒加载优化,以降低内存占用和渲染开销 AST#ui_control_flow#Left AST#lazy_for_each_statement#Left LazyForEach ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataSource AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left ShowData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ListItemGroup ( AST#component_parameters#Left { AST#component_parameter#Left header : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rightFixedTitle AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bottomRightListItem AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left item AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left ShowData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . sticky AST#member_expression#Right AST#expression#Right + AST#expression#Left index AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#lazy_for_each_statement#Right AST#ui_control_flow#Right AST#ERROR#Left ; AST#ERROR#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . onScrollFrameBegin ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left offset : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left state : AST#type_annotation#Left AST#primary_type#Left ScrollState AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // 下方左侧行标题列表与下方右侧列表的滚动偏移量保持一致 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bottomLeftListScroller AST#member_expression#Right AST#expression#Right . scrollTo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left xOffset AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , // 滚动偏移量为右下列表滚动控制器的当前偏移量+本次滚动的的偏移量 AST#property_assignment#Left AST#property_name#Left yOffset AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bottomRightListScroller AST#member_expression#Right AST#expression#Right . currentOffset AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . yOffset AST#member_expression#Right AST#expression#Right + AST#expression#Left offset AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left offsetRemain AST#property_name#Right : AST#expression#Left offset AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onDidScroll ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left scrollOffset : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left scrollState : AST#type_annotation#Left AST#primary_type#Left ScrollState AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // 行标题列表纵向滚动时,计算额外偏移量 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left xOffset : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . topListScroller AST#member_expression#Right AST#expression#Right . currentOffset AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . xOffset AST#member_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . scrollerIndex AST#member_expression#Right AST#expression#Right * AST#expression#Left LIST_ITEM_WIDTH AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showDataArray AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left showData : AST#type_annotation#Left AST#primary_type#Left ShowData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left showData AST#expression#Right . scrollerArray AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left scroller : AST#type_annotation#Left AST#primary_type#Left Scroller AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // 行标题列表纵向滚动时,下方右侧的每一行展示内容的索引号和横向偏移量保持一致 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left scroller AST#expression#Right . scrollToIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scrollerIndex AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left ScrollAlign AST#expression#Right . START AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left extraOffset AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LengthMetrics AST#expression#Right . vp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left xOffset AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Left . cachedCount ( AST#expression#Left LIST_PRElOAD_NUMBER AST#expression#Right ) // TODO:性能知识点: 列表较长,设置预加载数量减少性能消耗 AST#modifier_chain_expression#Left . width ( AST#expression#Left CALCULATED_SIZE AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_bottom_left_list_height_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . scrollBar ( AST#expression#Left AST#member_expression#Left AST#expression#Left BarState AST#expression#Right . Off AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . edgeEffect ( AST#expression#Left AST#member_expression#Left AST#expression#Left EdgeEffect AST#expression#Right . None AST#member_expression#Right AST#expression#Right ) // 将边缘滑动效果设置为无 AST#modifier_chain_expression#Left . listDirection ( AST#expression#Left AST#member_expression#Left AST#expression#Left Axis AST#expression#Right . Vertical AST#member_expression#Right AST#expression#Right ) // 设置滚动方向为纵向滚动 AST#modifier_chain_expression#Left . sticky ( AST#expression#Left AST#member_expression#Left AST#expression#Left StickyStyle AST#expression#Right . Header AST#member_expression#Right AST#expression#Right ) // 设置ListItemGroup标题的吸顶效果 AST#modifier_chain_expression#Left . expandSafeArea ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left SafeAreaType AST#expression#Right . SYSTEM AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left SafeAreaEdge AST#expression#Right . BOTTOM AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* 底部左侧纵向滚动列表的标题
* @param title 标题名
*/ AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right leftFixedTitle AST#parameter_list#Left ( AST#parameter#Left title : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left title AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_fixed_title_height_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_vertical_horizontal_container_padding_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_list_item_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.vertical_horizontal_linkage_bottom_list_title_background_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* 底部右侧纵向滚动的标题
* @param index 索引值
*/ AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right rightFixedTitle AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_bottom_right_title_initial_content' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_bottom_right_title_content' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_fixed_title_height_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . End AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_vertical_horizontal_container_padding_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.vertical_horizontal_linkage_bottom_list_title_background_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_bottom_right_title_width_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.vertical_horizontal_linkage_bottom_right_title_click_content' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct VerticalAndHorizontalListComponent {
private carType: string[] = ['车型1', '车型2', '车型3', '车型4', '车型5', '车型6', '车型7', '车型8'];
topListScroller: Scroller = new Scroller();
private bottomLeftListScroller: Scroller = new Scroller();
private bottomRightListScroller: Scroller = new Scroller();
private showDataArray: Array<ShowData> = [];
private dataSource: BasicDataSource<ShowData> = new BasicDataSource();
private carTypeData: BasicDataSource<string> = new BasicDataSource();
private topListItemIndex: number = 0;
private scrollerIndex: number = 0;
aboutToAppear(): void {
this.loadShowData();
}
loadShowData(): void {
this.carTypeData.setData(this.carType);
const context: Context = getContext(this);
let jsonData: Uint8Array = context.resourceManager.getRawFileContentSync('car.json');
let stringData: string = util.TextDecoder.create('utf-8').decodeToString(jsonData);
let data: [] = JSON.parse(stringData) as [];
for (let i = 0; i < data.length; i++) {
const dataItem = data[i] as CarTypeData;
let showData: ShowData = new ShowData();
showData.sticky = dataItem.sticky;
showData.sub.setData(dataItem.sub)
showData.sub.getAllData().forEach((element: PartInfo) => {
let scroller: Scroller = new Scroller();
showData.scrollerArray.push(scroller);
})
this.showDataArray.push(showData);
}
this.dataSource.setData(this.showDataArray);
}
build() {
Column() {
this.topComponent();
Row() {
this.bottomLeftComponent();
this.bottomRightComponent();
}
.layoutWeight(1)
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
}
}
@Builder
topComponent() {
Row() {
Column() {
Text($r('app.string.vertical_horizontal_linkage_top_left_text_message'))
.fontColor(Color.Black)
.fontSize($r('app.string.vertical_horizontal_linkage_top_left_message_font_size'))
.fontWeight(FontWeight.Bold)
}
.padding($r('app.string.vertical_horizontal_linkage_vertical_horizontal_container_padding_size'))
.height($r('app.string.vertical_horizontal_linkage_list_item_height'))
.width($r('app.string.vertical_horizontal_linkage_list_item_width'))
.justifyContent(FlexAlign.Center)
Line()
.height($r('app.string.vertical_horizontal_linkage_list_item_height'))
.width($r('app.string.vertical_horizontal_linkage_vertical_divider_line_width'))
.backgroundColor($r('app.color.vertical_horizontal_linkage_list_item_divider_line_color'))
List({ scroller: this.topListScroller }) {
LazyForEach(this.carTypeData, (item: string, index: number) => {
ListItem() {
CarTypeInfoItem({ info: item });
}
.id(`topListItem${index}`)
}, (item: string, index: number) => item);
}
.cachedCount(LIST_PRElOAD_NUMBER)
.edgeEffect(EdgeEffect.None)
.listDirection(Axis.Horizontal)
.divider({ strokeWidth: 0.5, color: $r('app.color.vertical_horizontal_linkage_list_item_divider_line_color') })
.scrollBar(BarState.Off)
.width(CALCULATED_SIZE)
.height($r('app.string.vertical_horizontal_linkage_top_List_height_size'))
.onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => {
this.topListItemIndex = firstIndex;
})
.onScrollFrameBegin((offset: number, state: ScrollState) => {
let scrollerOffset: number =
this.topListScroller.currentOffset().xOffset + offset - this.topListItemIndex * LIST_ITEM_WIDTH;
if (this.topListScroller.currentOffset().xOffset === 0) {
scrollerOffset = 0;
}
this.showDataArray.forEach((showData: ShowData) => {
showData.scrollerArray.forEach((scroller: Scroller) => {
scroller.scrollToIndex(this.topListItemIndex, false, ScrollAlign.START,
{ extraOffset: LengthMetrics.vp(scrollerOffset) });
});
});
return { offsetRemain: offset };
})
}
.height($r('app.string.vertical_horizontal_linkage_list_item_height'))
}
@Builder
bottomLeftList(item: ShowData) {
LazyForEach(item.sub, (partInfo: PartInfo, index: number) => {
ListItem() {
bottomLeftListItem({ partInfo: partInfo });
}
.id(`bottomLeftListItem${index}`)
}, (partInfo: PartInfo, index: number) => partInfo.part);
}
@Builder
bottomLeftComponent() {
List({ scroller: this.bottomLeftListScroller }) {
LazyForEach(this.dataSource, (item: ShowData, index: number) => {
ListItemGroup({ header: this.leftFixedTitle(item.sticky) }) {
this.bottomLeftList(item);
}
.border({
width: { right: '2px' },
color: $r('app.color.vertical_horizontal_linkage_list_item_divider_line_color'),
style: BorderStyle.Solid
})
}, (item: ShowData, index: number) => item.sticky + index);
}
.onScrollFrameBegin((offset: number, state: ScrollState) => {
this.bottomRightListScroller.scrollTo({
xOffset: 0,
yOffset: this.bottomLeftListScroller.currentOffset().yOffset + offset
});
return { offsetRemain: offset };
})
.cachedCount(LIST_PRElOAD_NUMBER)
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None) ,避免列表划动到底部后出现左右列表不联动问题
.listDirection(Axis.Vertical)
.sticky(StickyStyle.Header)
.width($r('app.string.vertical_horizontal_linkage_list_item_width'))
.height($r('app.string.vertical_horizontal_linkage_bottom_left_list_height_size'))
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
}
@Builder
bottomRightListItem(item: ShowData) {
LazyForEach(item.sub, (partInfo: PartInfo, key: number) => {
ListItem() {
ItemComponent({
listContent: partInfo.info,
scroller: item.scrollerArray[key],
scrollCallback: (value) => {
this.topListScroller.scrollTo({ xOffset: value, yOffset: 0 });
let offsetX = value - this.scrollerIndex * LIST_ITEM_WIDTH;
if (item.scrollerArray[key].currentOffset().xOffset === 0) {
offsetX = 0;
}
this.showDataArray.forEach((showData: ShowData) => {
showData.scrollerArray.forEach((scroller: Scroller) => {
if (scroller !== item.scrollerArray[key]) {
scroller.scrollToIndex(this.scrollerIndex, false, ScrollAlign.START,
{ extraOffset: LengthMetrics.vp(offsetX) });
}
})
})
},
remainOffsetCallback: (index) => {
this.scrollerIndex = index;
}
});
}
.id(`bottomRightListItem${key}`)
}, (partInfo: PartInfo, key: number) => partInfo.part + key);
}
@Builder
bottomRightComponent() {
List({ scroller: this.bottomRightListScroller }) {
LazyForEach(this.dataSource, (item: ShowData, index: number) => {
ListItemGroup({ header: this.rightFixedTitle(index) }) {
this.bottomRightListItem(item);
};
}, (item: ShowData, index: number) => item.sticky + index);
}
.onScrollFrameBegin((offset: number, state: ScrollState) => {
this.bottomLeftListScroller.scrollTo({
xOffset: 0,
yOffset: this.bottomRightListScroller.currentOffset().yOffset + offset
});
return { offsetRemain: offset };
})
.onDidScroll((scrollOffset: number, scrollState: ScrollState) => {
let xOffset: number = this.topListScroller.currentOffset().xOffset - this.scrollerIndex * LIST_ITEM_WIDTH;
this.showDataArray.forEach((showData: ShowData) => {
showData.scrollerArray.forEach((scroller: Scroller) => {
scroller.scrollToIndex(this.scrollerIndex, false, ScrollAlign.START,
{ extraOffset: LengthMetrics.vp(xOffset) });
})
});
})
.cachedCount(LIST_PRElOAD_NUMBER)
.width(CALCULATED_SIZE)
.height($r('app.string.vertical_horizontal_linkage_bottom_left_list_height_size'))
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None)
.listDirection(Axis.Vertical)
.sticky(StickyStyle.Header)
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
}
@Builder
leftFixedTitle(title: string) {
Column() {
Text(title)
.fontWeight(FontWeight.Bold)
.height($r('app.string.vertical_horizontal_linkage_fixed_title_height_size'))
.textAlign(TextAlign.Start)
.padding($r('app.string.vertical_horizontal_linkage_vertical_horizontal_container_padding_size'))
}
.width($r('app.string.vertical_horizontal_linkage_list_item_width'))
.backgroundColor($r('app.color.vertical_horizontal_linkage_bottom_list_title_background_color'))
}
@Builder
rightFixedTitle(index: number) {
Text(index === 0 ? $r('app.string.vertical_horizontal_linkage_bottom_right_title_initial_content') :
$r('app.string.vertical_horizontal_linkage_bottom_right_title_content'))
.fontWeight(FontWeight.Bold)
.height($r('app.string.vertical_horizontal_linkage_fixed_title_height_size'))
.textAlign(TextAlign.End)
.padding($r('app.string.vertical_horizontal_linkage_vertical_horizontal_container_padding_size'))
.backgroundColor($r('app.color.vertical_horizontal_linkage_bottom_list_title_background_color'))
.width($r('app.string.vertical_horizontal_linkage_bottom_right_title_width_size'))
.onClick(() => {
promptAction.showToast({
message: $r('app.string.vertical_horizontal_linkage_bottom_right_title_click_content')
});
})
}
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/verticalhorizontallinkage/src/main/ets/view/VerticalAndHorizontalList.ets#L41-L334
|
6956d5dcb2e927065a69a78a8a582bc11d8c4a07
|
gitee
|
open9527/OpenHarmony
|
fdea69ed722d426bf04e817ec05bff4002e81a4e
|
libs/core/src/main/ets/utils/StatusBarUtils.ets
|
arkts
|
getStatusBarHeight
|
获取状态栏的高度,单位为px。
@returns
|
public static getStatusBarHeight(): number {
let windowClass = AppUtils.getMainWindow();
let avoidArea = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM);
return avoidArea.topRect.height;
}
|
AST#method_declaration#Left public static getStatusBarHeight AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left windowClass = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtils AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left avoidArea = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . getWindowAvoidArea AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . AvoidAreaType AST#member_expression#Right AST#expression#Right . TYPE_SYSTEM AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left avoidArea AST#expression#Right . topRect AST#member_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public static getStatusBarHeight(): number {
let windowClass = AppUtils.getMainWindow();
let avoidArea = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM);
return avoidArea.topRect.height;
}
|
https://github.com/open9527/OpenHarmony/blob/fdea69ed722d426bf04e817ec05bff4002e81a4e/libs/core/src/main/ets/utils/StatusBarUtils.ets#L44-L48
|
b469d89a5627c6be898c53417dc9ba4f0c6e8fe5
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/common/types/SettingsTypes.ets
|
arkts
|
日志级别枚举
|
export enum LogLevel {
DEBUG = 'debug',
INFO = 'info',
WARN = 'warn',
ERROR = 'error'
}
|
AST#export_declaration#Left export AST#enum_declaration#Left enum LogLevel AST#enum_body#Left { AST#enum_member#Left DEBUG = AST#expression#Left 'debug' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left INFO = AST#expression#Left 'info' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left WARN = AST#expression#Left 'warn' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left ERROR = AST#expression#Left 'error' AST#expression#Right AST#enum_member#Right } AST#enum_body#Right AST#enum_declaration#Right AST#export_declaration#Right
|
export enum LogLevel {
DEBUG = 'debug',
INFO = 'info',
WARN = 'warn',
ERROR = 'error'
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/SettingsTypes.ets#L456-L461
|
7e168a696af0faadac1315248de065dde4ec84bb
|
github
|
|
pangpang20/wavecast.git
|
d3da8a0009eb44a576a2b9d9d9fe6195a2577e32
|
entry/src/main/ets/pages/PodcastDetailPage.ets
|
arkts
|
loadMore
|
加载更多单集
|
async loadMore() {
if (this.isLoadingMore || !this.hasMore) {
return;
}
this.isLoadingMore = true;
// 模拟网络延迟,提升用户体验
setTimeout(() => {
this.currentPage++;
this.updateDisplayedEpisodes();
this.isLoadingMore = false;
console.info(`[PodcastDetailPage] Loaded page ${this.currentPage}`);
}, 300);
}
|
AST#method_declaration#Left async loadMore AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLoadingMore AST#member_expression#Right AST#expression#Right || AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . hasMore AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLoadingMore AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 模拟网络延迟,提升用户体验 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left setTimeout AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#update_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentPage AST#member_expression#Right AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . updateDisplayedEpisodes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLoadingMore AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [PodcastDetailPage] Loaded page AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentPage AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right , AST#expression#Left 300 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async loadMore() {
if (this.isLoadingMore || !this.hasMore) {
return;
}
this.isLoadingMore = true;
setTimeout(() => {
this.currentPage++;
this.updateDisplayedEpisodes();
this.isLoadingMore = false;
console.info(`[PodcastDetailPage] Loaded page ${this.currentPage}`);
}, 300);
}
|
https://github.com/pangpang20/wavecast.git/blob/d3da8a0009eb44a576a2b9d9d9fe6195a2577e32/entry/src/main/ets/pages/PodcastDetailPage.ets#L107-L120
|
c5433effcc5cebb7ae450d0bb8d014f0ac1da262
|
github
|
Joker-x-dev/CoolMallArkTS.git
|
9f3fabf89fb277692cb82daf734c220c7282919c
|
feature/launch/src/main/ets/view/SplashPage.ets
|
arkts
|
SplashPage
|
@file 启动页视图
@author Joker.X
|
@ComponentV2
export struct SplashPage {
/**
* 启动页 ViewModel
*/
@Local
private vm: SplashViewModel = new SplashViewModel();
/**
* 构建启动页
* @returns {void} 无返回值
*/
build() {
AppNavDestination({
title: "启动页",
viewModel: this.vm
}) {
this.SplashContent();
}
}
/**
* 启动页内容视图
* @returns {void} 无返回值
*/
@Builder
private SplashContent() {
Text("启动页内容视图")
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ ComponentV2 AST#decorator#Right export struct SplashPage AST#component_body#Left { /**
* 启动页 ViewModel
*/ AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right private vm : AST#type_annotation#Left AST#primary_type#Left SplashViewModel AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left SplashViewModel AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right /**
* 构建启动页
* @returns {void} 无返回值
*/ AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left AppNavDestination ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left "启动页" AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left viewModel : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . SplashContent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right /**
* 启动页内容视图
* @returns {void} 无返回值
*/ AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right private SplashContent AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left "启动页内容视图" AST#expression#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@ComponentV2
export struct SplashPage {
@Local
private vm: SplashViewModel = new SplashViewModel();
build() {
AppNavDestination({
title: "启动页",
viewModel: this.vm
}) {
this.SplashContent();
}
}
@Builder
private SplashContent() {
Text("启动页内容视图")
}
}
|
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/launch/src/main/ets/view/SplashPage.ets#L8-L37
|
5fc330da11ace9f0364e0e19032a8ed389ce8625
|
github
|
lulululing/calendar.git
|
c87b7e3ffb50a34941a5db50afe6a513c113bd0b
|
entry/src/main/ets/manager/DataManager.ets
|
arkts
|
clearAllData
|
清除所有数据
|
async clearAllData(): Promise<boolean> {
if (!this.preferences) {
console.error('Preferences not initialized')
return false
}
try {
await this.preferences.clear()
await this.preferences.flush()
console.info('All data cleared')
return true
} catch (err) {
console.error('Failed to clear data:', JSON.stringify(err))
return false
}
}
|
AST#method_declaration#Left async clearAllData AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . preferences AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Preferences not initialized' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . preferences AST#member_expression#Right AST#expression#Right . clear AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . preferences AST#member_expression#Right AST#expression#Right . flush AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'All data cleared' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Failed to clear data:' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async clearAllData(): Promise<boolean> {
if (!this.preferences) {
console.error('Preferences not initialized')
return false
}
try {
await this.preferences.clear()
await this.preferences.flush()
console.info('All data cleared')
return true
} catch (err) {
console.error('Failed to clear data:', JSON.stringify(err))
return false
}
}
|
https://github.com/lulululing/calendar.git/blob/c87b7e3ffb50a34941a5db50afe6a513c113bd0b/entry/src/main/ets/manager/DataManager.ets#L127-L142
|
32d616ddb1b0755c8df7db990b0d25736f91071b
|
github
|
Joker-x-dev/HarmonyKit.git
|
f97197ce157df7f303244fba42e34918306dfb08
|
core/designsystem/src/main/ets/attribute/ColumnAttribute.ets
|
arkts
|
获取纵向居中 + 水平末尾的 Column 对齐修饰器
@returns {AttributeModifier<ColumnAttribute>} Column 对齐修饰器
@example
Column() { Text("Hi"); }.attributeModifier(columnCenterEnd());
|
export function columnCenterEnd(): AttributeModifier<ColumnAttribute> {
return {
applyNormalAttribute: (instance: ColumnAttribute): void => {
instance.justifyContent(FlexAlign.Center);
instance.alignItems(HorizontalAlign.End);
}
};
}
|
AST#export_declaration#Left export AST#function_declaration#Left function columnCenterEnd AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left AttributeModifier AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left ColumnAttribute AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left applyNormalAttribute AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left instance : AST#type_annotation#Left AST#primary_type#Left ColumnAttribute AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left instance AST#expression#Right . justifyContent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left instance AST#expression#Right . alignItems AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . End AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export function columnCenterEnd(): AttributeModifier<ColumnAttribute> {
return {
applyNormalAttribute: (instance: ColumnAttribute): void => {
instance.justifyContent(FlexAlign.Center);
instance.alignItems(HorizontalAlign.End);
}
};
}
|
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/designsystem/src/main/ets/attribute/ColumnAttribute.ets#L87-L94
|
4635258204a291bbc8d005781e7a78f7c94a9003
|
github
|
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/views/card/wordcard/WordCardOne.ets
|
arkts
|
buildExampleContentPanel
|
构建例句内容区域
|
@Builder
buildExampleContentPanel() {
Column({ space: 5 }) {
// 英文例句
WordClickableText({
text:this.word.exampleEn1 || '',
highlightWords: this.getHilightTexts(),
onWordClick:(word: string)=>{
this.onClickedText(word)
}
})
Stack(){
if (this.isHideExampleTranslation){
Text($r('app.string.wordcard_txt_show_translation'))
.width('100%')
.fontSize(18)
.minFontScale(0.1)
.fontColor($r('app.color.color_list_item_subtitle'))
.textAlign(TextAlign.Center)
.padding(5)
.margin({ top: 5, bottom: 5})
.backgroundColor(Color.White)
}else{
// 日文例句
Text(this.word.exampleCn1)
.width('100%')
.fontSize(20)
.fontColor($r('app.color.color_card_subtitle'))
.textAlign(TextAlign.Start)
.padding(5)
.margin({ top: 5, bottom: 5})
}
}
.onClick(()=>{
///会员检查
if(!MemberManager.shared.checkHideTransUsable(false)) {
return
}
this.isHideExampleTranslation = !this.isHideExampleTranslation
})
}
.width('100%')
.margin({ top: 5, left: 5, right: 5 })
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildExampleContentPanel AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 5 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { // 英文例句 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left WordClickableText ( AST#component_parameters#Left { AST#component_parameter#Left text : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . word AST#member_expression#Right AST#expression#Right . exampleEn1 AST#member_expression#Right AST#expression#Right || AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left highlightWords : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getHilightTexts AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onWordClick : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left word : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onClickedText AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left word AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Stack ( ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isHideExampleTranslation AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.wordcard_txt_show_translation' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 18 AST#expression#Right ) AST#modifier_chain_expression#Left . minFontScale ( AST#expression#Left 0.1 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.color_list_item_subtitle' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left 5 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 5 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 5 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } else { // 日文例句 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . word AST#member_expression#Right AST#expression#Right . exampleCn1 AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.color_card_subtitle' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left 5 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 5 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 5 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { ///会员检查 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left MemberManager AST#expression#Right AST#unary_expression#Right AST#expression#Right . shared AST#member_expression#Right AST#expression#Right . checkHideTransUsable AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#object_literal#Left { AST#ERROR#Left return AST#ERROR#Right } AST#object_literal#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isHideExampleTranslation AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . isHideExampleTranslation AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 5 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 5 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 5 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
buildExampleContentPanel() {
Column({ space: 5 }) {
WordClickableText({
text:this.word.exampleEn1 || '',
highlightWords: this.getHilightTexts(),
onWordClick:(word: string)=>{
this.onClickedText(word)
}
})
Stack(){
if (this.isHideExampleTranslation){
Text($r('app.string.wordcard_txt_show_translation'))
.width('100%')
.fontSize(18)
.minFontScale(0.1)
.fontColor($r('app.color.color_list_item_subtitle'))
.textAlign(TextAlign.Center)
.padding(5)
.margin({ top: 5, bottom: 5})
.backgroundColor(Color.White)
}else{
Text(this.word.exampleCn1)
.width('100%')
.fontSize(20)
.fontColor($r('app.color.color_card_subtitle'))
.textAlign(TextAlign.Start)
.padding(5)
.margin({ top: 5, bottom: 5})
}
}
.onClick(()=>{
if(!MemberManager.shared.checkHideTransUsable(false)) {
return
}
this.isHideExampleTranslation = !this.isHideExampleTranslation
})
}
.width('100%')
.margin({ top: 5, left: 5, right: 5 })
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/views/card/wordcard/WordCardOne.ets#L310-L359
|
45c40a198ce5250dfdcf8cc180a110a5dd87081c
|
github
|
zqaini002/YaoYaoLingXian.git
|
5095b12cbeea524a87c42d0824b1702978843d39
|
YaoYaoLingXian/entry/src/main/ets/services/ApiService.ets
|
arkts
|
getUrl
|
获取当前环境的URL
|
getUrl(env: string): string {
switch (env) {
case 'ANDROID_EMULATOR':
return this.ANDROID_EMULATOR;
case 'DEVICE':
return this.DEVICE;
case 'LOCAL':
default:
return this.LOCAL;
}
|
AST#method_declaration#Left getUrl AST#parameter_list#Left ( AST#parameter#Left env : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left switch AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left ( AST#expression#Left env AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left 'ANDROID_EMULATOR' AST#expression#Right AST#expression_statement#Right : AST#ERROR#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . ANDROID_EMULATOR AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left 'DEVICE' AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left : AST#ERROR#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . DEVICE AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left 'LOCAL' AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left : default : AST#ERROR#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . LOCAL AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
getUrl(env: string): string {
switch (env) {
case 'ANDROID_EMULATOR':
return this.ANDROID_EMULATOR;
case 'DEVICE':
return this.DEVICE;
case 'LOCAL':
default:
return this.LOCAL;
}
|
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/services/ApiService.ets#L50-L59
|
f596c2e8140a66607357ff60feba7d998a925918
|
github
|
bigbear20240612/planner_build-.git
|
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
|
entry/src/main/ets/viewmodel/SimpleNotificationManager.ets
|
arkts
|
sendNotification
|
发送基础通知(简化版本)
|
async sendNotification(title: string, content: string): Promise<boolean> {
try {
// 简化版本:只记录日志,实际通知功能需要真实的设备支持
hilog.info(0x0000, 'SimpleNotificationManager', 'Notification sent: %{public}s, content: %{public}s', title, content);
return true;
} catch (error) {
hilog.error(0x0000, 'SimpleNotificationManager', 'Failed to send notification');
return false;
}
}
|
AST#method_declaration#Left async sendNotification AST#parameter_list#Left ( AST#parameter#Left title : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left content : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 简化版本:只记录日志,实际通知功能需要真实的设备支持 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'SimpleNotificationManager' AST#expression#Right , AST#expression#Left 'Notification sent: %{public}s, content: %{public}s' AST#expression#Right , AST#expression#Left title AST#expression#Right , AST#expression#Left content AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'SimpleNotificationManager' AST#expression#Right , AST#expression#Left 'Failed to send notification' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async sendNotification(title: string, content: string): Promise<boolean> {
try {
hilog.info(0x0000, 'SimpleNotificationManager', 'Notification sent: %{public}s, content: %{public}s', title, content);
return true;
} catch (error) {
hilog.error(0x0000, 'SimpleNotificationManager', 'Failed to send notification');
return false;
}
}
|
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/viewmodel/SimpleNotificationManager.ets#L75-L84
|
f52f1c331a7c93186f2dacf93eb57a5a299e4b02
|
github
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/models/managers/subscription/SubscriptionInfo.ets
|
arkts
|
fromArray
|
从数组构建 SubscriptionInfo 列表
@param arr JSON数组
@returns SubscriptionInfo 列表
|
static fromArray(arr: Object[] | null): SubscriptionInfo[] {
if (!arr) return [];
return arr.map(o => new SubscriptionInfo(o as Record<string, Object>));
}
|
AST#method_declaration#Left static fromArray AST#parameter_list#Left ( AST#parameter#Left arr : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#array_type#Left Object [ ] AST#array_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left SubscriptionInfo [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left arr AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left arr AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left o => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left SubscriptionInfo AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left o AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static fromArray(arr: Object[] | null): SubscriptionInfo[] {
if (!arr) return [];
return arr.map(o => new SubscriptionInfo(o as Record<string, Object>));
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/managers/subscription/SubscriptionInfo.ets#L30-L33
|
6dc514c14bae805dabe171e903735d11824ea987
|
github
|
openharmony/interface_sdk-js
|
c349adc73e2ec1f61f6fca489b5af059e3ed6999
|
api/@ohos.atomicservice.AtomicServiceWeb.d.ets
|
arkts
|
setCustomUserAgent
|
Set custom user agent.
@param { string } userAgent - User custom agent information.
@throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
<br>2. Incorrect parameter types.
@throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a
AtomicServiceWeb component.
@syscap SystemCapability.ArkUI.ArkUI.Full
@atomicservice
@since 12
|
setCustomUserAgent(userAgent: string): void;
|
AST#method_declaration#Left setCustomUserAgent AST#parameter_list#Left ( AST#parameter#Left userAgent : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right
|
setCustomUserAgent(userAgent: string): void;
|
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.atomicservice.AtomicServiceWeb.d.ets#L381-L381
|
e40f9eab685739373eb382720922c5400e12ed3e
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/pages/Index.ets
|
arkts
|
showTimePickerDialog
|
显示自定义时间选择器对话框
|
private showTimePickerDialog(): void {
this.showCustomTimeDialog = true;
}
|
AST#method_declaration#Left private showTimePickerDialog AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showCustomTimeDialog AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
private showTimePickerDialog(): void {
this.showCustomTimeDialog = true;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/Index.ets#L6281-L6283
|
e5450c575be78106fdd66ef198590b2c2db009de
|
github
|
open9527/OpenHarmony
|
fdea69ed722d426bf04e817ec05bff4002e81a4e
|
entry/src/main/ets/pages/example/lottie/LottieView.ets
|
arkts
|
goToAndStop
|
控制动画画面停止在某一帧或某个时刻
@param value 帧号(值>=0)或时刻(ms)
@param isFrame true按帧控制, false按时间控制, 缺省默认false
@since 8
@design
|
goToAndStop(value: number, isFrame?: boolean) {
this.animationItem?.goToAndStop(value, isFrame)
}
|
AST#method_declaration#Left goToAndStop AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left isFrame ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . animationItem AST#member_expression#Right AST#expression#Right ?. goToAndStop AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left value AST#expression#Right , AST#expression#Left isFrame AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
goToAndStop(value: number, isFrame?: boolean) {
this.animationItem?.goToAndStop(value, isFrame)
}
|
https://github.com/open9527/OpenHarmony/blob/fdea69ed722d426bf04e817ec05bff4002e81a4e/entry/src/main/ets/pages/example/lottie/LottieView.ets#L198-L200
|
5bd78818689c440baed6265bb8cb7a98917929fd
|
gitee
|
Joker-x-dev/CoolMallArkTS.git
|
9f3fabf89fb277692cb82daf734c220c7282919c
|
core/network/src/main/ets/datasource/feedback/FeedbackNetworkDataSource.ets
|
arkts
|
@file 意见反馈数据源接口
@author Joker.X
|
export interface FeedbackNetworkDataSource {
/**
* 提交意见反馈
* @param params 反馈提交请求参数
* @returns 提交结果响应
*/
submitFeedback(params: FeedbackSubmitRequest): Promise<NetworkResponse<boolean>>;
/**
* 分页查询意见反馈列表
* @param params 分页请求参数
* @returns 反馈分页数据响应
*/
getFeedbackPage(params: PageRequest): Promise<NetworkResponse<NetworkPageData<Feedback>>>;
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface FeedbackNetworkDataSource AST#object_type#Left { /**
* 提交意见反馈
* @param params 反馈提交请求参数
* @returns 提交结果响应
*/ AST#type_member#Left submitFeedback AST#parameter_list#Left ( AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left FeedbackSubmitRequest AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left NetworkResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /**
* 分页查询意见反馈列表
* @param params 分页请求参数
* @returns 反馈分页数据响应
*/ AST#type_member#Left getFeedbackPage AST#parameter_list#Left ( AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left PageRequest AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left NetworkResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left NetworkPageData AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Feedback AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
|
export interface FeedbackNetworkDataSource {
submitFeedback(params: FeedbackSubmitRequest): Promise<NetworkResponse<boolean>>;
getFeedbackPage(params: PageRequest): Promise<NetworkResponse<NetworkPageData<Feedback>>>;
}
|
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/network/src/main/ets/datasource/feedback/FeedbackNetworkDataSource.ets#L7-L21
|
8620ce7da345a3c55d57f26f4b897e60c848faf4
|
github
|
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/models/ContactModel.ets
|
arkts
|
generateId
|
静态方法:生成唯一ID
|
private static generateId(): string {
return `contact_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
}
|
AST#method_declaration#Left private static generateId AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#template_literal#Left ` contact_ AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Date AST#expression#Right . now AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right _ AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . random AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 36 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . substr AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 2 AST#expression#Right , AST#expression#Left 9 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private static generateId(): string {
return `contact_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/models/ContactModel.ets#L54-L56
|
6635782e705d044e542a8676479698a33c9f1818
|
github
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/lunar/LunarService.ets
|
arkts
|
clearCache
|
清除缓存
|
clearCache(): void {
this.onlineLunarService.clearCache();
}
|
AST#method_declaration#Left clearCache AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onlineLunarService AST#member_expression#Right AST#expression#Right . clearCache AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
clearCache(): void {
this.onlineLunarService.clearCache();
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/lunar/LunarService.ets#L486-L488
|
cc74ba2c84caa6209694f9b4307ef428754d0495
|
github
|
Joker-x-dev/HarmonyKit.git
|
f97197ce157df7f303244fba42e34918306dfb08
|
core/designsystem/src/main/ets/component/Column.ets
|
arkts
|
ColumnSpaceEvenly
|
纵向均分 + 水平居中
|
@ComponentV2
export struct ColumnSpaceEvenly {
/**
* Column 构造参数
*/
@Param
options: ColumnOptions | ColumnOptionsV2 = {};
/**
* 宽度
*/
@Param
widthValue: Length | undefined = undefined;
/**
* 高度
*/
@Param
heightValue: Length | undefined = undefined;
/**
* 尺寸(对应官方 size 属性)
*/
@Param
sizeValue: SizeOptions | undefined = undefined;
/**
* 内边距
*/
@Param
paddingValue: Padding | Length | LocalizedPadding | undefined = undefined;
/**
* 外边距
*/
@Param
marginValue: Margin | Length | LocalizedMargin | undefined = undefined;
/**
* 是否填充最大宽高
*/
@Param
fillMaxSize: boolean = false;
/**
* 背景颜色
*/
@Param
bgColor: ResourceColor | undefined = undefined;
/**
* 点击事件
*/
@Param
onTap: ((event: ClickEvent) => void) | undefined = undefined;
/**
* 内容构建函数
*/
@BuilderParam
content: CustomBuilder;
/**
* 渲染布局
* @returns {void} 无返回值
* @example
* ColumnSpaceEvenly() { Text("A"); Text("B"); Text("C"); }
*/
build(): void {
ColumnBase({
options: this.options,
justifyContent: FlexAlign.SpaceEvenly,
alignItems: HorizontalAlign.Center,
widthValue: this.widthValue,
heightValue: this.heightValue,
sizeValue: this.sizeValue,
paddingValue: this.paddingValue,
marginValue: this.marginValue,
fillMaxSize: this.fillMaxSize,
bgColor: this.bgColor,
onTap: this.onTap,
content: this.content
});
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ ComponentV2 AST#decorator#Right export struct ColumnSpaceEvenly AST#component_body#Left { /**
* Column 构造参数
*/ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right options : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ColumnOptions AST#primary_type#Right | AST#primary_type#Left ColumnOptionsV2 AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right ; AST#property_declaration#Right /**
* 宽度
*/ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right widthValue : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Length AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right /**
* 高度
*/ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right heightValue : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Length AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right /**
* 尺寸(对应官方 size 属性)
*/ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right sizeValue : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left SizeOptions AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right /**
* 内边距
*/ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right paddingValue : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Padding AST#primary_type#Right | AST#primary_type#Left Length AST#primary_type#Right | AST#primary_type#Left LocalizedPadding AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right /**
* 外边距
*/ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right marginValue : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Margin AST#primary_type#Right | AST#primary_type#Left Length AST#primary_type#Right | AST#primary_type#Left LocalizedMargin AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right /**
* 是否填充最大宽高
*/ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right fillMaxSize : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right /**
* 背景颜色
*/ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right bgColor : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ResourceColor AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right /**
* 点击事件
*/ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right onTap : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#parenthesized_type#Left ( AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left event : AST#type_annotation#Left AST#primary_type#Left ClickEvent AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right ) AST#parenthesized_type#Right AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right /**
* 内容构建函数
*/ AST#property_declaration#Left AST#decorator#Left @ BuilderParam AST#decorator#Right content : AST#type_annotation#Left AST#primary_type#Left CustomBuilder AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* 渲染布局
* @returns {void} 无返回值
* @example
* ColumnSpaceEvenly() { Text("A"); Text("B"); Text("C"); }
*/ AST#build_method#Left build ( ) : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#build_body#Left { AST#ui_custom_component_statement#Left ColumnBase ( AST#component_parameters#Left { AST#component_parameter#Left options : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left justifyContent : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceEvenly AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left alignItems : AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left widthValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . widthValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left heightValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . heightValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left sizeValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sizeValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left paddingValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . paddingValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left marginValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . marginValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left fillMaxSize : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . fillMaxSize AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left bgColor : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bgColor AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onTap : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onTap AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left content : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . content AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@ComponentV2
export struct ColumnSpaceEvenly {
@Param
options: ColumnOptions | ColumnOptionsV2 = {};
@Param
widthValue: Length | undefined = undefined;
@Param
heightValue: Length | undefined = undefined;
@Param
sizeValue: SizeOptions | undefined = undefined;
@Param
paddingValue: Padding | Length | LocalizedPadding | undefined = undefined;
@Param
marginValue: Margin | Length | LocalizedMargin | undefined = undefined;
@Param
fillMaxSize: boolean = false;
@Param
bgColor: ResourceColor | undefined = undefined;
@Param
onTap: ((event: ClickEvent) => void) | undefined = undefined;
@BuilderParam
content: CustomBuilder;
build(): void {
ColumnBase({
options: this.options,
justifyContent: FlexAlign.SpaceEvenly,
alignItems: HorizontalAlign.Center,
widthValue: this.widthValue,
heightValue: this.heightValue,
sizeValue: this.sizeValue,
paddingValue: this.paddingValue,
marginValue: this.marginValue,
fillMaxSize: this.fillMaxSize,
bgColor: this.bgColor,
onTap: this.onTap,
content: this.content
});
}
}
|
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/designsystem/src/main/ets/component/Column.ets#L545-L620
|
03e6e0d81dc941ae638ca49adc6fa2f7f4343268
|
github
|
Active-hue/ArkTS-Accounting.git
|
c432916d305b407557f08e35017c3fd70668e441
|
entry/src/main/ets/pages/Main.ets
|
arkts
|
DateGroupComponent
|
日期分组组件(一个大模块)
|
@Builder
DateGroupComponent(date: string, bills: BillItem[]) {
Column() {
// 日期标题行
Row() {
Text(this.formatDateDisplay(date))
.fontSize(13)
.fontColor('#999999')
Blank()
Text(`支: ${this.calculateDayStats(bills).expense}`)
.fontSize(12)
.fontColor('#666666')
.margin({ left: 16 })
Text(`收: ${this.calculateDayStats(bills).income}`)
.fontSize(12)
.fontColor('#666666')
.margin({ left: 16 })
}
.width('100%')
.padding({ left: 16, right: 16, top: 12, bottom: 12 })
// 该日期下的所有账单
Column() {
ForEach(bills, (bill: BillItem, index: number) => {
Column() {
// 账单项
Row() {
// 图标
Image($r(`app.media.category_${bill.categoryIcon}`))
.width(40)
.height(40)
.fillColor('#5B7FFF')
.margin({ right: 12 })
// 分类和备注
Column() {
Text(bill.category)
.fontSize(15)
.fontColor('#333333')
.margin({ bottom: 4 })
if (bill.remark) {
Text(bill.remark)
.fontSize(12)
.fontColor('#999999')
}
}
.alignItems(HorizontalAlign.Start)
Blank()
// 金额
Text((bill.type === 0 ? '-' : '+') + bill.amount)
.fontSize(16)
.fontColor(bill.type === 0 ? '#333333' : '#FF6B6B')
.fontWeight(FontWeight.Medium)
}
.width('100%')
.padding({ left: 16, right: 16, top: 12, bottom: 12 })
// 分隔线(不是最后一项时显示)
if (index < bills.length - 1) {
Divider()
.color('#F0F0F0')
.strokeWidth(1)
.margin({ left: 68, right: 16 })
}
}
}, (bill: BillItem) => bill.id)
}
}
.width('100%')
.backgroundColor('#FFFFFF')
.borderRadius(12)
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right DateGroupComponent AST#parameter_list#Left ( AST#parameter#Left date : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left bills : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left BillItem [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { // 日期标题行 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . formatDateDisplay AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left date AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 13 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#999999' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Blank ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#template_literal#Left ` 支: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . calculateDayStats AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left bills AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . expense AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#666666' AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#template_literal#Left ` 收: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . calculateDayStats AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left bills AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . income AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#666666' AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 该日期下的所有账单 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#for_each_statement#Left ForEach ( AST#expression#Left bills AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left bill : AST#type_annotation#Left AST#primary_type#Left BillItem AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { // 账单项 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { // 图标 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left AST#template_literal#Left ` app.media.category_ AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left bill AST#expression#Right . categoryIcon AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Left . fillColor ( AST#expression#Left '#5B7FFF' AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 分类和备注 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left bill AST#expression#Right . category AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 15 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#333333' AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 4 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left bill AST#expression#Right . remark AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left bill AST#expression#Right . remark AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#999999' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Blank ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 金额 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left bill AST#expression#Right . type AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left '-' AST#expression#Right : AST#expression#Left '+' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right + AST#expression#Left bill AST#expression#Right AST#binary_expression#Right AST#expression#Right . amount AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left bill AST#expression#Right . type AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left '#333333' AST#expression#Right : AST#expression#Left '#FF6B6B' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 分隔线(不是最后一项时显示) AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right < AST#expression#Left bills AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Divider ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . color ( AST#expression#Left '#F0F0F0' AST#expression#Right ) AST#modifier_chain_expression#Left . strokeWidth ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 68 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left bill : AST#type_annotation#Left AST#primary_type#Left BillItem AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#member_expression#Left AST#expression#Left bill AST#expression#Right . id AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#FFFFFF' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
DateGroupComponent(date: string, bills: BillItem[]) {
Column() {
Row() {
Text(this.formatDateDisplay(date))
.fontSize(13)
.fontColor('#999999')
Blank()
Text(`支: ${this.calculateDayStats(bills).expense}`)
.fontSize(12)
.fontColor('#666666')
.margin({ left: 16 })
Text(`收: ${this.calculateDayStats(bills).income}`)
.fontSize(12)
.fontColor('#666666')
.margin({ left: 16 })
}
.width('100%')
.padding({ left: 16, right: 16, top: 12, bottom: 12 })
Column() {
ForEach(bills, (bill: BillItem, index: number) => {
Column() {
Row() {
Image($r(`app.media.category_${bill.categoryIcon}`))
.width(40)
.height(40)
.fillColor('#5B7FFF')
.margin({ right: 12 })
Column() {
Text(bill.category)
.fontSize(15)
.fontColor('#333333')
.margin({ bottom: 4 })
if (bill.remark) {
Text(bill.remark)
.fontSize(12)
.fontColor('#999999')
}
}
.alignItems(HorizontalAlign.Start)
Blank()
Text((bill.type === 0 ? '-' : '+') + bill.amount)
.fontSize(16)
.fontColor(bill.type === 0 ? '#333333' : '#FF6B6B')
.fontWeight(FontWeight.Medium)
}
.width('100%')
.padding({ left: 16, right: 16, top: 12, bottom: 12 })
if (index < bills.length - 1) {
Divider()
.color('#F0F0F0')
.strokeWidth(1)
.margin({ left: 68, right: 16 })
}
}
}, (bill: BillItem) => bill.id)
}
}
.width('100%')
.backgroundColor('#FFFFFF')
.borderRadius(12)
}
|
https://github.com/Active-hue/ArkTS-Accounting.git/blob/c432916d305b407557f08e35017c3fd70668e441/entry/src/main/ets/pages/Main.ets#L781-L854
|
dfad3f46e9d05c9f038bdfff1d357cf178e27d16
|
github
|
zhuanyongtester/Cpay_arkts.git
|
4402a8a06963d0757952513d3cbf7d5919ceb74f
|
entry/src/main/ets/pages/SettingPage.ets
|
arkts
|
featureItem
|
功能组件。
@param icon 图标
@param text 标签
@param prompt 点击后的提示语
|
@Builder featureItem(icon: ResourceStr, text: ResourceStr, fieldName: keyof PersonModel) {
Row() {
Text(icon)
.fontSize($r("sys.float.ohos_id_text_size_body1"))
.fontWeight(FontWeight.Bold)
.margin($r("app.integer.listitem_overflow_default_margin"))
Text(text)
.fontSize($r("sys.float.ohos_id_text_size_body1"))
.margin($r("app.integer.listitem_overflow_default_margin"))
.fontColor($r("app.color.title_text_color"))
ObjectLinkChild({getPersonModel:this.getPersonModel,fieldName:fieldName})
}
.width("100%")
.toastOnClick(text)
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right featureItem AST#parameter_list#Left ( AST#parameter#Left icon : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left text : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left fieldName : AST#type_annotation#Left AST#primary_type#Left keyof AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right AST#ERROR#Left PersonModel AST#ERROR#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left icon AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "sys.float.ohos_id_text_size_body1" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.listitem_overflow_default_margin" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left text AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "sys.float.ohos_id_text_size_body1" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.listitem_overflow_default_margin" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.color.title_text_color" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ObjectLinkChild ( AST#component_parameters#Left { AST#component_parameter#Left getPersonModel : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getPersonModel AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left fieldName : AST#expression#Left fieldName AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left "100%" AST#expression#Right ) AST#modifier_chain_expression#Left . toastOnClick ( AST#expression#Left text AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder featureItem(icon: ResourceStr, text: ResourceStr, fieldName: keyof PersonModel) {
Row() {
Text(icon)
.fontSize($r("sys.float.ohos_id_text_size_body1"))
.fontWeight(FontWeight.Bold)
.margin($r("app.integer.listitem_overflow_default_margin"))
Text(text)
.fontSize($r("sys.float.ohos_id_text_size_body1"))
.margin($r("app.integer.listitem_overflow_default_margin"))
.fontColor($r("app.color.title_text_color"))
ObjectLinkChild({getPersonModel:this.getPersonModel,fieldName:fieldName})
}
.width("100%")
.toastOnClick(text)
}
|
https://github.com/zhuanyongtester/Cpay_arkts.git/blob/4402a8a06963d0757952513d3cbf7d5919ceb74f/entry/src/main/ets/pages/SettingPage.ets#L208-L223
|
7e7107f899fd2367572839bd420365bf382ad453
|
github
|
iotjin/JhHarmonyDemo.git
|
819e6c3b1db9984c042a181967784550e171b2e8
|
JhCommon/src/main/ets/JhCommon/components/JhPickerTool.ets
|
arkts
|
showBottomSheet
|
底部弹框
@param options
|
public static showBottomSheet(options: JhBottomSheetOptions) {
if ((options.data ?? []).length == 0) {
return
}
DialogHelper.showBottomSheetDialog({
title: options.title ?? '',
titleFontColor: _titleColor,
cancelValue: _cancelText,
sheets: options.data ?? [],
cornerRadius: _kHeaderRadius,
backgroundColor: _bgColor,
autoCancel: true, // 点击遮障层时,是否关闭弹窗,true表示关闭弹窗。默认关闭
backCancel: false, // 点击返回键或手势返回时,是否关闭弹窗;实现onWillDismiss函数时,该参数不起作用。默认不关闭
actionCancel: true, // 点击操作按钮时,是否关闭弹窗。false表示不关闭弹窗。
onAction: (index) => {
const isStringArray = JhPickerTool.isOneStringArray(options.data)
const selectedText: string = isStringArray ? options.data![index] : options.data![index]['value']
options.clickCallback?.(index, selectedText)
}
})
}
|
AST#method_declaration#Left public static showBottomSheet AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left JhBottomSheetOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . data AST#member_expression#Right AST#expression#Right ?? AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right == AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#ERROR#Left return AST#ERROR#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DialogHelper AST#expression#Right . showBottomSheetDialog AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . title AST#member_expression#Right AST#expression#Right ?? AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left titleFontColor AST#property_name#Right : AST#expression#Left _titleColor AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left cancelValue AST#property_name#Right : AST#expression#Left _cancelText AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left sheets AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . data AST#member_expression#Right AST#expression#Right ?? AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left cornerRadius AST#property_name#Right : AST#expression#Left _kHeaderRadius AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left backgroundColor AST#property_name#Right : AST#expression#Left _bgColor AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left autoCancel AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , // 点击遮障层时,是否关闭弹窗,true表示关闭弹窗。默认关闭 AST#property_assignment#Left AST#property_name#Left backCancel AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , // 点击返回键或手势返回时,是否关闭弹窗;实现onWillDismiss函数时,该参数不起作用。默认不关闭 AST#property_assignment#Left AST#property_name#Left actionCancel AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , // 点击操作按钮时,是否关闭弹窗。false表示不关闭弹窗。 AST#property_assignment#Left AST#property_name#Left onAction AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left index AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left isStringArray = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JhPickerTool AST#expression#Right . isOneStringArray AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . data AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left selectedText : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left isStringArray AST#expression#Right ? AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . data AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right : AST#expression#Left options AST#expression#Right AST#conditional_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right [ AST#expression#Left 'value' AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left options AST#ERROR#Right . clickCallback AST#member_expression#Right AST#expression#Right ?. AST#argument_list#Left ( AST#expression#Left index AST#expression#Right , AST#expression#Left selectedText AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
public static showBottomSheet(options: JhBottomSheetOptions) {
if ((options.data ?? []).length == 0) {
return
}
DialogHelper.showBottomSheetDialog({
title: options.title ?? '',
titleFontColor: _titleColor,
cancelValue: _cancelText,
sheets: options.data ?? [],
cornerRadius: _kHeaderRadius,
backgroundColor: _bgColor,
autoCancel: true,
backCancel: false,
actionCancel: true,
onAction: (index) => {
const isStringArray = JhPickerTool.isOneStringArray(options.data)
const selectedText: string = isStringArray ? options.data![index] : options.data![index]['value']
options.clickCallback?.(index, selectedText)
}
})
}
|
https://github.com/iotjin/JhHarmonyDemo.git/blob/819e6c3b1db9984c042a181967784550e171b2e8/JhCommon/src/main/ets/JhCommon/components/JhPickerTool.ets#L56-L76
|
783bff7aae4ef28c8f83f84a1e32ca37bae7cb7d
|
github
|
openharmony-tpc-incubate/photo-deal-demo
|
01382ce30b1785f8fc8bc14f6b94f0a670a5b50b
|
library/src/main/ets/controller/EditController.ets
|
arkts
|
removeRecord
|
移除一条记录
@param record 操作记录
|
removeRecord(record: OperateRecord): void {
if (this.operateRecords.length > 0) {
let idx = this.operateRecords.indexOf(record);
if (idx >= 0) {
this.operateRecords.splice(idx, 1);
}
this.onRecordsChanged();
}
}
|
AST#method_declaration#Left removeRecord AST#parameter_list#Left ( AST#parameter#Left record : AST#type_annotation#Left AST#primary_type#Left OperateRecord AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . operateRecords AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left idx = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . operateRecords AST#member_expression#Right AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left record AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left idx AST#expression#Right >= AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . operateRecords AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left idx AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onRecordsChanged AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
removeRecord(record: OperateRecord): void {
if (this.operateRecords.length > 0) {
let idx = this.operateRecords.indexOf(record);
if (idx >= 0) {
this.operateRecords.splice(idx, 1);
}
this.onRecordsChanged();
}
}
|
https://github.com/openharmony-tpc-incubate/photo-deal-demo/blob/01382ce30b1785f8fc8bc14f6b94f0a670a5b50b/library/src/main/ets/controller/EditController.ets#L153-L161
|
af693e602b2f457f2e02fdcebd94daf3ff491fa1
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/common/data/FestivalData2025.ets
|
arkts
|
getNextFestival
|
获取下一个节日
|
public static getNextFestival(currentDate: Date): FestivalInfo | null {
const currentYear = currentDate.getFullYear();
const currentMonth = currentDate.getMonth() + 1;
const currentDay = currentDate.getDate();
// 简化实现:只检查公历节日
const solarFestivals = SOLAR_FESTIVALS.filter(festival => {
if (festival.month > currentMonth ||
(festival.month === currentMonth && festival.day > currentDay)) {
return true;
}
return false;
});
if (solarFestivals.length > 0) {
// 按日期排序,返回最近的节日
solarFestivals.sort((a, b) => {
if (a.month !== b.month) return a.month - b.month;
return a.day - b.day;
});
return solarFestivals[0];
}
// 如果当年没有更多节日,返回下年第一个节日
const nextYearFestivals = SOLAR_FESTIVALS.sort((a, b) => {
if (a.month !== b.month) return a.month - b.month;
return a.day - b.day;
});
return nextYearFestivals[0] || null;
}
|
AST#method_declaration#Left public static getNextFestival AST#parameter_list#Left ( AST#parameter#Left currentDate : AST#type_annotation#Left AST#primary_type#Left Date AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left FestivalInfo AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left currentYear = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentDate AST#expression#Right . getFullYear AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left currentMonth = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentDate AST#expression#Right . getMonth AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left currentDay = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentDate AST#expression#Right . getDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 简化实现:只检查公历节日 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left solarFestivals = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left SOLAR_FESTIVALS AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left festival => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left festival AST#expression#Right . month AST#member_expression#Right AST#expression#Right > AST#expression#Left currentMonth AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left festival AST#expression#Right . month AST#member_expression#Right AST#expression#Right === AST#expression#Left currentMonth AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left festival AST#expression#Right AST#binary_expression#Right AST#expression#Right . day AST#member_expression#Right AST#expression#Right > AST#expression#Left currentDay AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left solarFestivals AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // 按日期排序,返回最近的节日 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left solarFestivals AST#expression#Right . sort AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left a AST#parameter#Right , AST#parameter#Left b AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left a AST#expression#Right . month AST#member_expression#Right AST#expression#Right !== AST#expression#Left b AST#expression#Right AST#binary_expression#Right AST#expression#Right . month AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left a AST#expression#Right . month AST#member_expression#Right AST#expression#Right - AST#expression#Left b AST#expression#Right AST#binary_expression#Right AST#expression#Right . month AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left a AST#expression#Right . day AST#member_expression#Right AST#expression#Right - AST#expression#Left b AST#expression#Right AST#binary_expression#Right AST#expression#Right . day AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#subscript_expression#Left AST#expression#Left solarFestivals AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 如果当年没有更多节日,返回下年第一个节日 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left nextYearFestivals = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left SOLAR_FESTIVALS AST#expression#Right . sort AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left a AST#parameter#Right , AST#parameter#Left b AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left a AST#expression#Right . month AST#member_expression#Right AST#expression#Right !== AST#expression#Left b AST#expression#Right AST#binary_expression#Right AST#expression#Right . month AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left a AST#expression#Right . month AST#member_expression#Right AST#expression#Right - AST#expression#Left b AST#expression#Right AST#binary_expression#Right AST#expression#Right . month AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left a AST#expression#Right . day AST#member_expression#Right AST#expression#Right - AST#expression#Left b AST#expression#Right AST#binary_expression#Right AST#expression#Right . day AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left nextYearFestivals AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right || AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public static getNextFestival(currentDate: Date): FestivalInfo | null {
const currentYear = currentDate.getFullYear();
const currentMonth = currentDate.getMonth() + 1;
const currentDay = currentDate.getDate();
const solarFestivals = SOLAR_FESTIVALS.filter(festival => {
if (festival.month > currentMonth ||
(festival.month === currentMonth && festival.day > currentDay)) {
return true;
}
return false;
});
if (solarFestivals.length > 0) {
solarFestivals.sort((a, b) => {
if (a.month !== b.month) return a.month - b.month;
return a.day - b.day;
});
return solarFestivals[0];
}
const nextYearFestivals = SOLAR_FESTIVALS.sort((a, b) => {
if (a.month !== b.month) return a.month - b.month;
return a.day - b.day;
});
return nextYearFestivals[0] || null;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/data/FestivalData2025.ets#L339-L369
|
982f735775000a437bdd3bf523e2d259234b284a
|
github
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/dealstridesolution/src/main/ets/model/CameraService.ets
|
arkts
|
getSupportedCamerasFn
|
获取支持指定的摄像机设备对象
|
getSupportedCamerasFn(cameraManager: camera.CameraManager): Array<camera.CameraDevice> {
let supportedCameras: Array<camera.CameraDevice> = [];
try {
supportedCameras = cameraManager.getSupportedCameras();
logger.info(TAG, `getSupportedCameras success: ${this.cameras}, length: ${this.cameras?.length}`);
} catch (error) {
logger.error(TAG, `getSupportedCameras failed: ${JSON.stringify(error)}`);
}
return supportedCameras;
}
|
AST#method_declaration#Left getSupportedCamerasFn AST#parameter_list#Left ( AST#parameter#Left cameraManager : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left camera . CameraManager AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left camera . CameraDevice AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left supportedCameras : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left camera . CameraDevice AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left supportedCameras = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cameraManager AST#expression#Right . getSupportedCameras AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` getSupportedCameras success: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cameras AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , length: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cameras AST#member_expression#Right AST#expression#Right ?. length AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` getSupportedCameras failed: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left supportedCameras AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
getSupportedCamerasFn(cameraManager: camera.CameraManager): Array<camera.CameraDevice> {
let supportedCameras: Array<camera.CameraDevice> = [];
try {
supportedCameras = cameraManager.getSupportedCameras();
logger.info(TAG, `getSupportedCameras success: ${this.cameras}, length: ${this.cameras?.length}`);
} catch (error) {
logger.error(TAG, `getSupportedCameras failed: ${JSON.stringify(error)}`);
}
return supportedCameras;
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/dealstridesolution/src/main/ets/model/CameraService.ets#L161-L170
|
fc9556fe1d64d45db10383bb132ba5ec91d10a24
|
gitee
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/webpagesnapshot/src/main/ets/components/mainpage/ScrollableComponentPage.ets
|
arkts
|
afterSnapshot
|
截图之后的操作。
- 恢复滚动组件页面到截图之前的位置
- 取消遮罩层
|
async afterSnapshot() {
this.scroller.scrollTo({ xOffset: this.xOffsetBefore, yOffset: this.yOffsetBefore });
await sleep(Constants.SCROLL_DURATION);
this.componentMaskImageZIndex = -1;
this.componentMaskImage = undefined;
}
|
AST#method_declaration#Left async afterSnapshot AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scroller AST#member_expression#Right AST#expression#Right . scrollTo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left xOffset AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . xOffsetBefore AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left yOffset AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . yOffsetBefore AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left sleep AST#expression#Right AST#await_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . SCROLL_DURATION AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . componentMaskImageZIndex AST#member_expression#Right = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . componentMaskImage AST#member_expression#Right = AST#expression#Left undefined AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
async afterSnapshot() {
this.scroller.scrollTo({ xOffset: this.xOffsetBefore, yOffset: this.yOffsetBefore });
await sleep(Constants.SCROLL_DURATION);
this.componentMaskImageZIndex = -1;
this.componentMaskImage = undefined;
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/webpagesnapshot/src/main/ets/components/mainpage/ScrollableComponentPage.ets#L427-L432
|
c7db8c538146c88aedd206310af39a918343dead
|
gitee
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/SystemFeature/DeviceManagement/DeviceManagementCollection/feature/capabilities/src/main/ets/util/DeviceUtil.ets
|
arkts
|
displayVersion
|
产品版本
|
static displayVersion(): string {
return deviceInfo.displayVersion
}
|
AST#method_declaration#Left static displayVersion AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left deviceInfo AST#expression#Right . displayVersion AST#member_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static displayVersion(): string {
return deviceInfo.displayVersion
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/DeviceManagement/DeviceManagementCollection/feature/capabilities/src/main/ets/util/DeviceUtil.ets#L113-L115
|
e632ea50e4ab41e8e4c72f0071b0fcd9eef1319d
|
gitee
|
Wayne-007/iMusic.git
|
ab55f2e57ffe1c6e0a26589047b0187842dc9eb3
|
entry/src/main/ets/pages/Play.ets
|
arkts
|
number2time
|
把毫秒转成分秒
|
number2time(number: number) {
// 毫秒 → 秒 → 分+秒; 先判断是否大于1分钟
if (number > 60 * 1000) {
const s = Math.floor(number / 1000 % 60)
const m = Math.floor(number / 1000 / 60)
const second = s.toString().padStart(2, '0')
const minute = m.toString().padStart(2, '0')
return minute + ':' + second
} else {
const s = Math.floor(number / 1000 % 60)
const second = s.toString().padStart(2, '0')
return '00:' + second
}
}
|
AST#method_declaration#Left number2time AST#parameter_list#Left ( AST#parameter#Left number : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { // 毫秒 → 秒 → 分+秒; 先判断是否大于1分钟 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left number AST#expression#Right > AST#expression#Left AST#binary_expression#Left AST#expression#Left 60 AST#expression#Right * AST#expression#Left 1000 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left s = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left number AST#expression#Right / AST#expression#Left 1000 AST#expression#Right AST#binary_expression#Right AST#expression#Right % AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left m = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left number AST#expression#Right / AST#expression#Left 1000 AST#expression#Right AST#binary_expression#Right AST#expression#Right / AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left second = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left s AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . padStart AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 2 AST#expression#Right , AST#expression#Left '0' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left minute = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left m AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . padStart AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 2 AST#expression#Right , AST#expression#Left '0' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left minute AST#expression#Right + AST#expression#Left ':' AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left second AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left s = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left number AST#expression#Right / AST#expression#Left 1000 AST#expression#Right AST#binary_expression#Right AST#expression#Right % AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left second = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left s AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . padStart AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 2 AST#expression#Right , AST#expression#Left '0' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left '00:' AST#expression#Right + AST#expression#Left second AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
number2time(number: number) {
if (number > 60 * 1000) {
const s = Math.floor(number / 1000 % 60)
const m = Math.floor(number / 1000 / 60)
const second = s.toString().padStart(2, '0')
const minute = m.toString().padStart(2, '0')
return minute + ':' + second
} else {
const s = Math.floor(number / 1000 % 60)
const second = s.toString().padStart(2, '0')
return '00:' + second
}
}
|
https://github.com/Wayne-007/iMusic.git/blob/ab55f2e57ffe1c6e0a26589047b0187842dc9eb3/entry/src/main/ets/pages/Play.ets#L154-L167
|
7ab3cb8c24ff049eec0a4f74a2a0032357cecf6f
|
github
|
openharmony-tpc/lottieArkTS
|
82cac19eaeb236c38fc72466a268c1d0d8a481ce
|
sharedLibrary/Index.ets
|
arkts
|
add
|
Copyright (c) 2023 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
export { add } from "./src/main/ets/utils/Calc"
|
AST#export_declaration#Left export { add } from "./src/main/ets/utils/Calc" AST#export_declaration#Right
|
export { add } from "./src/main/ets/utils/Calc"
|
https://github.com/openharmony-tpc/lottieArkTS/blob/82cac19eaeb236c38fc72466a268c1d0d8a481ce/sharedLibrary/Index.ets#L15-L15
|
d7db7ebafc932610efc2275545ea5a047555128d
|
gitee
|
RedRackham-R/WanAndroidHarmoney.git
|
0bb2a7c8d7b49194a96e42a380d43b7e106cdb22
|
entry/src/main/ets/event/WanEvents.ets
|
arkts
|
取消收藏文章事件
|
export class UncollectEvent {
isSuccess: boolean
id: number
errMsg?: string
constructor
|
AST#export_declaration#Left export AST#ERROR#Left class UncollectEvent { isSuccess : AST#ERROR#Left boolean id : number errMsg ? : AST#ERROR#Right string AST#ERROR#Right AST#variable_declaration#Left const AST#variable_declarator#Left ructor AST#variable_declarator#Right AST#variable_declaration#Right AST#export_declaration#Right
|
export class UncollectEvent {
isSuccess: boolean
id: number
errMsg?: string
constructor
|
https://github.com/RedRackham-R/WanAndroidHarmoney.git/blob/0bb2a7c8d7b49194a96e42a380d43b7e106cdb22/entry/src/main/ets/event/WanEvents.ets#L63-L68
|
cebf9257b9cb38dd99927c54f268e84c6ad16ab5
|
github
|
|
ThePivotPoint/ArkTS-LSP-Server-Plugin.git
|
6231773905435f000d00d94b26504433082ba40b
|
packages/declarations/ets/api/@ohos.atomicservice.AtomicServiceWeb.d.ets
|
arkts
|
AtomicServiceWeb
|
Declare Component AtomicServiceWeb.
@syscap SystemCapability.ArkUI.ArkUI.Full
@atomicservice
@since 12
|
@Component
export declare struct AtomicServiceWeb {
/**
* The address of the web page to be displayed.
*
* @type { ResourceStr }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
src: ResourceStr;
/**
* Sets the controller of the AtomicServiceWeb.
*
* @type { AtomicServiceWebController }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
@ObjectLink
controller: AtomicServiceWebController;
/**
* Sets how to load HTTP and HTTPS content.
*
* @type { ?MixedMode }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
@Prop
mixedMode?: MixedMode;
/**
* Sets the dark mode of Web.
*
* @type { ?WebDarkMode }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
@Prop
darkMode?: WebDarkMode;
/**
* Sets whether to enable forced dark algorithm when the web is in dark mode.
*
* @type { ?boolean }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
@Prop
forceDarkAccess?: boolean;
/**
* The navPathStack to control page route in Navigation and NavDestination.
*
* @type { ?NavPathStack }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
navPathStack?: NavPathStack;
/**
* The callback method to invoke after page is back or destroyed if postMessage() is called in H5 page.
*
* @type { ?Callback<OnMessageEvent> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
onMessage?: Callback<OnMessageEvent>;
/**
* Triggered when the web page receives a web resource loading error.
*
* @type { ?Callback<OnErrorReceiveEvent> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
onErrorReceive?: Callback<OnErrorReceiveEvent>;
/**
* Triggered when the web page receives a web resource loading HTTP error.
*
* @type { ?Callback<OnHttpErrorReceiveEvent> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
onHttpErrorReceive?: Callback<OnHttpErrorReceiveEvent>;
/**
* Triggered at the begin of web page loading.
*
* @type { ?Callback<OnPageBeginEvent> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
onPageBegin?: Callback<OnPageBeginEvent>;
/**
* Triggered at the end of web page loading.
*
* @type { ?Callback<OnPageEndEvent> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
onPageEnd?: Callback<OnPageEndEvent>;
/**
* Triggered when The controller is bound to the web component, this controller must be a WebviewController.
* This callback can not use the interface about manipulating web pages.
*
* @type { ?Callback<void> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
onControllerAttached?: Callback<void>;
/**
* Triggered when the resources loading is intercepted.
*
* @type { ?OnLoadInterceptCallback }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
onLoadIntercept?: OnLoadInterceptCallback;
/**
* Triggered when the page loading progress changes.
*
* @type { ?Callback<OnProgressChangeEvent> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
onProgressChange?: Callback<OnProgressChangeEvent>;
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export AST#ERROR#Left declare AST#ERROR#Right struct AtomicServiceWeb AST#component_body#Left { /**
* The address of the web page to be displayed.
*
* @type { ResourceStr }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left src : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Sets the controller of the AtomicServiceWeb.
*
* @type { AtomicServiceWebController }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left AST#decorator#Left @ ObjectLink AST#decorator#Right controller : AST#type_annotation#Left AST#primary_type#Left AtomicServiceWebController AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Sets how to load HTTP and HTTPS content.
*
* @type { ?MixedMode }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right mixedMode ? : AST#type_annotation#Left AST#primary_type#Left MixedMode AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Sets the dark mode of Web.
*
* @type { ?WebDarkMode }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right darkMode ? : AST#type_annotation#Left AST#primary_type#Left WebDarkMode AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Sets whether to enable forced dark algorithm when the web is in dark mode.
*
* @type { ?boolean }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right forceDarkAccess ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* The navPathStack to control page route in Navigation and NavDestination.
*
* @type { ?NavPathStack }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left navPathStack ? : AST#type_annotation#Left AST#primary_type#Left NavPathStack AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* The callback method to invoke after page is back or destroyed if postMessage() is called in H5 page.
*
* @type { ?Callback<OnMessageEvent> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left onMessage ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left OnMessageEvent AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Triggered when the web page receives a web resource loading error.
*
* @type { ?Callback<OnErrorReceiveEvent> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left onErrorReceive ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left OnErrorReceiveEvent AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Triggered when the web page receives a web resource loading HTTP error.
*
* @type { ?Callback<OnHttpErrorReceiveEvent> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left onHttpErrorReceive ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left OnHttpErrorReceiveEvent AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Triggered at the begin of web page loading.
*
* @type { ?Callback<OnPageBeginEvent> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left onPageBegin ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left OnPageBeginEvent AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Triggered at the end of web page loading.
*
* @type { ?Callback<OnPageEndEvent> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left onPageEnd ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left OnPageEndEvent AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Triggered when The controller is bound to the web component, this controller must be a WebviewController.
* This callback can not use the interface about manipulating web pages.
*
* @type { ?Callback<void> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left onControllerAttached ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Triggered when the resources loading is intercepted.
*
* @type { ?OnLoadInterceptCallback }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left onLoadIntercept ? : AST#type_annotation#Left AST#primary_type#Left OnLoadInterceptCallback AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Triggered when the page loading progress changes.
*
* @type { ?Callback<OnProgressChangeEvent> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left onProgressChange ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left OnProgressChangeEvent AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export declare struct AtomicServiceWeb {
src: ResourceStr;
@ObjectLink
controller: AtomicServiceWebController;
@Prop
mixedMode?: MixedMode;
@Prop
darkMode?: WebDarkMode;
@Prop
forceDarkAccess?: boolean;
navPathStack?: NavPathStack;
onMessage?: Callback<OnMessageEvent>;
onErrorReceive?: Callback<OnErrorReceiveEvent>;
onHttpErrorReceive?: Callback<OnHttpErrorReceiveEvent>;
onPageBegin?: Callback<OnPageBeginEvent>;
onPageEnd?: Callback<OnPageEndEvent>;
onControllerAttached?: Callback<void>;
onLoadIntercept?: OnLoadInterceptCallback;
onProgressChange?: Callback<OnProgressChangeEvent>;
}
|
https://github.com/ThePivotPoint/ArkTS-LSP-Server-Plugin.git/blob/6231773905435f000d00d94b26504433082ba40b/packages/declarations/ets/api/@ohos.atomicservice.AtomicServiceWeb.d.ets#L27-L160
|
d22744a70263e7043164d82cfaf8b760594a1b61
|
github
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
ef_crypto/src/main/ets/crypto/encryption/AES.ets
|
arkts
|
decodeECB128
|
解密-ECB模式-128位
@param str 加密的字符串
@param aesKey AES密钥-128位
@returns
|
static async decodeECB128(str: string, aesKey: string): Promise<string> {
return CryptoUtil.decodeECB(str, aesKey, 'AES128', 'AES128|ECB|PKCS7', 128);
}
|
AST#method_declaration#Left static async decodeECB128 AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left aesKey : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CryptoUtil AST#expression#Right . decodeECB AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left aesKey AST#expression#Right , AST#expression#Left 'AES128' AST#expression#Right , AST#expression#Left 'AES128|ECB|PKCS7' AST#expression#Right , AST#expression#Left 128 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static async decodeECB128(str: string, aesKey: string): Promise<string> {
return CryptoUtil.decodeECB(str, aesKey, 'AES128', 'AES128|ECB|PKCS7', 128);
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto/src/main/ets/crypto/encryption/AES.ets#L211-L213
|
0f4c2863d09ddab9d3302ea2ca4efb2cd2ed27e3
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/pages/contacts/ContactImportPage.ets
|
arkts
|
buildCsvInstructions
|
构建CSV说明和模板
|
@Builder
buildCsvInstructions() {
Column({ space: 12 }) {
Text('CSV格式导入说明')
.fontSize(18)
.fontWeight(FontWeight.Bold)
.fontColor('#333333')
.alignSelf(ItemAlign.Start)
Text('1. CSV文件需要包含表头行\n2. 必需字段:姓名\n3. 可选字段:关系、性别、电话、邮箱、生日等\n4. 支持中英文字段名')
.fontSize(14)
.fontColor('#666666')
.lineHeight(20)
.alignSelf(ItemAlign.Start)
Row({ space: 12 }) {
Button('下载CSV模板')
.type(ButtonType.Normal)
.fontSize(14)
.fontColor('#4ECDC4')
.backgroundColor('#f0fffe')
.border({ width: 1, color: '#4ECDC4' })
.borderRadius(8)
.onClick(() => {
this.downloadCsvTemplate();
})
Button('清空内容')
.type(ButtonType.Normal)
.fontSize(14)
.fontColor('#ff6b6b')
.backgroundColor('#fff0f0')
.border({ width: 1, color: '#ff6b6b' })
.borderRadius(8)
.onClick(() => {
this.csvContent = '';
this.csvParseResult = null;
this.showCsvPreview = false;
})
}
.alignSelf(ItemAlign.Start)
}
.width('100%')
.padding(16)
.backgroundColor('#ffffff')
.borderRadius(12)
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildCsvInstructions AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 12 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left 'CSV格式导入说明' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 18 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#333333' AST#expression#Right ) AST#modifier_chain_expression#Left . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '1. CSV文件需要包含表头行\n2. 必需字段:姓名\n3. 可选字段:关系、性别、电话、邮箱、生日等\n4. 支持中英文字段名' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#666666' AST#expression#Right ) AST#modifier_chain_expression#Left . lineHeight ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 12 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left '下载CSV模板' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . type ( AST#expression#Left AST#member_expression#Left AST#expression#Left ButtonType AST#expression#Right . Normal AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#4ECDC4' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#f0fffe' AST#expression#Right ) AST#modifier_chain_expression#Left . border ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left 1 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left '#4ECDC4' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 8 AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadCsvTemplate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left '清空内容' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . type ( AST#expression#Left AST#member_expression#Left AST#expression#Left ButtonType AST#expression#Right . Normal AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#ff6b6b' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#fff0f0' AST#expression#Right ) AST#modifier_chain_expression#Left . border ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left 1 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left '#ff6b6b' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 8 AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . csvContent AST#member_expression#Right = AST#expression#Left '' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . csvParseResult AST#member_expression#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showCsvPreview AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#ffffff' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
buildCsvInstructions() {
Column({ space: 12 }) {
Text('CSV格式导入说明')
.fontSize(18)
.fontWeight(FontWeight.Bold)
.fontColor('#333333')
.alignSelf(ItemAlign.Start)
Text('1. CSV文件需要包含表头行\n2. 必需字段:姓名\n3. 可选字段:关系、性别、电话、邮箱、生日等\n4. 支持中英文字段名')
.fontSize(14)
.fontColor('#666666')
.lineHeight(20)
.alignSelf(ItemAlign.Start)
Row({ space: 12 }) {
Button('下载CSV模板')
.type(ButtonType.Normal)
.fontSize(14)
.fontColor('#4ECDC4')
.backgroundColor('#f0fffe')
.border({ width: 1, color: '#4ECDC4' })
.borderRadius(8)
.onClick(() => {
this.downloadCsvTemplate();
})
Button('清空内容')
.type(ButtonType.Normal)
.fontSize(14)
.fontColor('#ff6b6b')
.backgroundColor('#fff0f0')
.border({ width: 1, color: '#ff6b6b' })
.borderRadius(8)
.onClick(() => {
this.csvContent = '';
this.csvParseResult = null;
this.showCsvPreview = false;
})
}
.alignSelf(ItemAlign.Start)
}
.width('100%')
.padding(16)
.backgroundColor('#ffffff')
.borderRadius(12)
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/contacts/ContactImportPage.ets#L179-L225
|
ba35df3c5ba331d75ba2d7bc41fd18303ec1cbae
|
github
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/FileUtil.ets
|
arkts
|
accessSync
|
检查文件是否存在,以同步方法。
@param path 文件应用沙箱路径。
@returns
|
static accessSync(path: string): boolean {
return fs.accessSync(path);
}
|
AST#method_declaration#Left static accessSync AST#parameter_list#Left ( AST#parameter#Left path : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fs AST#expression#Right . accessSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left path AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static accessSync(path: string): boolean {
return fs.accessSync(path);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/FileUtil.ets#L390-L392
|
cdc8b9b9bdc205af5a8f913ba0fd9cf58693396b
|
gitee
|
openharmony/interface_sdk-js
|
c349adc73e2ec1f61f6fca489b5af059e3ed6999
|
api/@ohos.arkui.advanced.Chip.d.ets
|
arkts
|
Defines the prefix icon option.
@interface PrefixIconOptions
@extends IconCommonOptions
@syscap SystemCapability.ArkUI.ArkUI.Full
@crossplatform
@since 11
Defines the prefix icon option.
@interface PrefixIconOptions
@extends IconCommonOptions
@syscap SystemCapability.ArkUI.ArkUI.Full
@crossplatform
@atomicservice
@since 12
|
export interface PrefixIconOptions extends IconCommonOptions {}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface PrefixIconOptions AST#extends_clause#Left extends IconCommonOptions AST#extends_clause#Right AST#object_type#Left { } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
|
export interface PrefixIconOptions extends IconCommonOptions {}
|
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.arkui.advanced.Chip.d.ets#L304-L304
|
8ec932acbf9580e9021649ba23c682137d6d3917
|
gitee
|
|
L1rics06/arkTS-.git
|
991fd131bfdb11e2933152133c97453d86092ac0
|
entry/src/main/ets/pages/AppState.ets
|
arkts
|
getInstance
|
获取单例
|
public static getInstance(): AppState {
if (!AppState.instance) {
AppState.instance = new AppState();
}
return AppState.instance;
}
|
AST#method_declaration#Left public static getInstance AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AppState AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left AppState AST#expression#Right AST#unary_expression#Right AST#expression#Right . instance AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AppState AST#expression#Right . instance AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left AppState AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppState AST#expression#Right . instance AST#member_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
public static getInstance(): AppState {
if (!AppState.instance) {
AppState.instance = new AppState();
}
return AppState.instance;
}
|
https://github.com/L1rics06/arkTS-.git/blob/991fd131bfdb11e2933152133c97453d86092ac0/entry/src/main/ets/pages/AppState.ets#L70-L75
|
d5f476542399eefc3604d97dd43198a31834db5a
|
github
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Media/ImageEdit/entry/src/main/ets/utils/DrawingUtils.ets
|
arkts
|
drawCropButton
|
Draw crop thick line.
@param ctx
@param crop
|
static drawCropButton(ctx: CanvasRenderingContext2D, crop: RectF) {
let vp3 = CommonConstants.DEFAULT_BUTTON_WIDTH;
let padding = CommonConstants.DEFAULT_BUTTON_PADDING;
ctx.lineWidth = vp3;
ctx.strokeStyle = CommonConstants.DEFAULT_BUTTON_COLOR;
let cornerLength = CommonConstants.DEFAULT_BUTTON_LENGTH;
DrawingUtils.drawCornerButton(ctx, crop, vp3, padding, cornerLength);
DrawingUtils.drawLineButton(ctx, crop, vp3, padding, cornerLength);
}
|
AST#method_declaration#Left static drawCropButton AST#parameter_list#Left ( AST#parameter#Left ctx : AST#type_annotation#Left AST#primary_type#Left CanvasRenderingContext2D AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left crop : AST#type_annotation#Left AST#primary_type#Left RectF AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left vp3 = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DEFAULT_BUTTON_WIDTH AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left padding = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DEFAULT_BUTTON_PADDING AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left ctx AST#expression#Right . lineWidth AST#member_expression#Right = AST#expression#Left vp3 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left ctx AST#expression#Right . strokeStyle AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DEFAULT_BUTTON_COLOR AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left cornerLength = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DEFAULT_BUTTON_LENGTH AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DrawingUtils AST#expression#Right . drawCornerButton AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left ctx AST#expression#Right , AST#expression#Left crop AST#expression#Right , AST#expression#Left vp3 AST#expression#Right , AST#expression#Left padding AST#expression#Right , AST#expression#Left cornerLength AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DrawingUtils AST#expression#Right . drawLineButton AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left ctx AST#expression#Right , AST#expression#Left crop AST#expression#Right , AST#expression#Left vp3 AST#expression#Right , AST#expression#Left padding AST#expression#Right , AST#expression#Left cornerLength AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static drawCropButton(ctx: CanvasRenderingContext2D, crop: RectF) {
let vp3 = CommonConstants.DEFAULT_BUTTON_WIDTH;
let padding = CommonConstants.DEFAULT_BUTTON_PADDING;
ctx.lineWidth = vp3;
ctx.strokeStyle = CommonConstants.DEFAULT_BUTTON_COLOR;
let cornerLength = CommonConstants.DEFAULT_BUTTON_LENGTH;
DrawingUtils.drawCornerButton(ctx, crop, vp3, padding, cornerLength);
DrawingUtils.drawLineButton(ctx, crop, vp3, padding, cornerLength);
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Media/ImageEdit/entry/src/main/ets/utils/DrawingUtils.ets#L46-L54
|
1df57e6d8e64fa9585cff828513d1f4e4158bb4d
|
gitee
|
yycy134679/FoodieHarmony.git
|
e6971f0a8f7574ae278d02eb5c057e57e667dab5
|
entry/src/main/ets/view/home/HomeTabContent.ets
|
arkts
|
handleLoadMore
|
加载更多处理
|
private async handleLoadMore() {
if (this.isLoadingMore || !this.hasMore) {
return;
}
try {
hilog.info(DOMAIN, TAG, 'Loading more data');
this.isLoadingMore = true;
// 加载下一页数据
await this.loadMerchantList(this.currentPage + 1, true);
hilog.info(DOMAIN, TAG, 'More data loaded successfully');
} catch (err) {
hilog.error(DOMAIN, TAG, 'Failed to load more data: %{public}s', JSON.stringify(err));
promptAction.showToast({
message: '加载失败,请稍后重试',
duration: 2000
});
} finally {
this.isLoadingMore = false;
}
}
|
AST#method_declaration#Left private async handleLoadMore AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLoadingMore AST#member_expression#Right AST#expression#Right || AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . hasMore AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left TAG AST#expression#Right , AST#expression#Left 'Loading more data' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLoadingMore AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 加载下一页数据 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . loadMerchantList AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentPage AST#member_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left TAG AST#expression#Right , AST#expression#Left 'More data loaded successfully' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left TAG AST#expression#Right , AST#expression#Left 'Failed to load more data: %{public}s' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left '加载失败,请稍后重试' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left 2000 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#finally_clause#Left finally AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLoadingMore AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#finally_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private async handleLoadMore() {
if (this.isLoadingMore || !this.hasMore) {
return;
}
try {
hilog.info(DOMAIN, TAG, 'Loading more data');
this.isLoadingMore = true;
await this.loadMerchantList(this.currentPage + 1, true);
hilog.info(DOMAIN, TAG, 'More data loaded successfully');
} catch (err) {
hilog.error(DOMAIN, TAG, 'Failed to load more data: %{public}s', JSON.stringify(err));
promptAction.showToast({
message: '加载失败,请稍后重试',
duration: 2000
});
} finally {
this.isLoadingMore = false;
}
}
|
https://github.com/yycy134679/FoodieHarmony.git/blob/e6971f0a8f7574ae278d02eb5c057e57e667dab5/entry/src/main/ets/view/home/HomeTabContent.ets#L175-L197
|
733a205f94fdf6b4f1fe6fa564908902b4d29fd6
|
github
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/pages/settings/ThemeCustomizationPage.ets
|
arkts
|
onThemeTypeChange
|
切换主题类型
|
async onThemeTypeChange(type: ThemeType) {
try {
this.selectedThemeType = type;
await this.themeManager.setThemeType(type);
this.currentTheme = this.themeManager.getCurrentTheme();
} catch (error) {
console.error('Failed to change theme type:', error);
}
}
|
AST#method_declaration#Left async onThemeTypeChange AST#parameter_list#Left ( AST#parameter#Left type : AST#type_annotation#Left AST#primary_type#Left ThemeType AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedThemeType AST#member_expression#Right = AST#expression#Left type AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . themeManager AST#member_expression#Right AST#expression#Right . setThemeType AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left type AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentTheme AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . themeManager AST#member_expression#Right AST#expression#Right . getCurrentTheme AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Failed to change theme type:' AST#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async onThemeTypeChange(type: ThemeType) {
try {
this.selectedThemeType = type;
await this.themeManager.setThemeType(type);
this.currentTheme = this.themeManager.getCurrentTheme();
} catch (error) {
console.error('Failed to change theme type:', error);
}
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/settings/ThemeCustomizationPage.ets#L88-L96
|
2f99f33527da4a07f502a5a9a5fa6117e06a6a56
|
github
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Media/ImageEdit/entry/src/main/ets/utils/MathUtils.ets
|
arkts
|
rotatePoints
|
Rotate by point.
@param inputs
@param angle
@param origin
@returns
|
static rotatePoints(inputs: Array<Point>, angle: number, origin: Point): Array<Point> {
let alpha = MathUtils.formulaAngle(-angle);
let outputs: Array<Point> = [];
for (let input of inputs) {
let dx = input.x - origin.x;
let dy = input.y - origin.y;
let output = new Point(origin.x, origin.y);
output.x += Math.cos(alpha) * dx + Math.sin(alpha) * dy;
output.y += -Math.sin(alpha) * dx + Math.cos(alpha) * dy;
outputs.push(output);
}
return outputs;
}
|
AST#method_declaration#Left static rotatePoints AST#parameter_list#Left ( AST#parameter#Left inputs : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Point AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left angle : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left origin : AST#type_annotation#Left AST#primary_type#Left Point AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Point AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left alpha = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left MathUtils AST#expression#Right . formulaAngle AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#unary_expression#Left - AST#expression#Left angle AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left outputs : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Point AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( let input of AST#expression#Left inputs AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left dx = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left input AST#expression#Right . x AST#member_expression#Right AST#expression#Right - AST#expression#Left origin AST#expression#Right AST#binary_expression#Right AST#expression#Right . x AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left dy = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left input AST#expression#Right . y AST#member_expression#Right AST#expression#Right - AST#expression#Left origin AST#expression#Right AST#binary_expression#Right AST#expression#Right . y AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left output = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Point AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left origin AST#expression#Right . x AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left origin AST#expression#Right . y AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left output AST#expression#Right . x AST#member_expression#Right += AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . cos AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left alpha AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right * AST#expression#Left dx AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left Math AST#expression#Right AST#binary_expression#Right AST#expression#Right . sin AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left alpha AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right * AST#expression#Left dy AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left output AST#expression#Right . y AST#member_expression#Right += AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left - AST#expression#Left Math AST#expression#Right AST#unary_expression#Right AST#expression#Right . sin AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left alpha AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right * AST#expression#Left dx AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left Math AST#expression#Right AST#binary_expression#Right AST#expression#Right . cos AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left alpha AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right * AST#expression#Left dy AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left outputs AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left output AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left outputs AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static rotatePoints(inputs: Array<Point>, angle: number, origin: Point): Array<Point> {
let alpha = MathUtils.formulaAngle(-angle);
let outputs: Array<Point> = [];
for (let input of inputs) {
let dx = input.x - origin.x;
let dy = input.y - origin.y;
let output = new Point(origin.x, origin.y);
output.x += Math.cos(alpha) * dx + Math.sin(alpha) * dy;
output.y += -Math.sin(alpha) * dx + Math.cos(alpha) * dy;
outputs.push(output);
}
return outputs;
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Media/ImageEdit/entry/src/main/ets/utils/MathUtils.ets#L93-L105
|
9b07341f0c7a9731f7098c5424dd1fc44af61dc5
|
gitee
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.