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/calendar/LunarSolarMappingService.ets
|
arkts
|
getSolarToLunar
|
获取公历日期对应的农历日期
|
async getSolarToLunar(year: number, solarMonth: number, solarDay: number): Promise<LunarDate | null> {
await this.ensureYearMapping(year);
const yearData = this.mappingCache.get(year);
if (!yearData) return null;
const solarKey = `${solarMonth}-${solarDay}`;
const mapping = yearData.solarToLunar.get(solarKey);
if (mapping) {
return {
year: mapping.lunarYear,
month: mapping.lunarMonth,
day: mapping.lunarDay,
isLeapMonth: mapping.isLeapMonth,
monthName: this.getLunarMonthName(mapping.lunarMonth, mapping.isLeapMonth),
dayName: this.getLunarDayName(mapping.lunarDay),
zodiac: '',
ganZhi: '',
yearCn: mapping.lunarYear.toString(),
monthCn: this.getLunarMonthName(mapping.lunarMonth, mapping.isLeapMonth),
dayCn: this.getLunarDayName(mapping.lunarDay),
gzYear: ''
};
}
return null;
}
|
AST#method_declaration#Left async getSolarToLunar AST#parameter_list#Left ( AST#parameter#Left year : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left solarMonth : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left solarDay : 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#union_type#Left AST#primary_type#Left LunarDate AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_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 AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . ensureYearMapping AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left year 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 yearData = 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 . mappingCache AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left year 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#unary_expression#Left ! AST#expression#Left yearData AST#expression#Right AST#unary_expression#Right AST#expression#Right ) 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#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left solarKey = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left solarMonth AST#expression#Right } AST#template_substitution#Right - AST#template_substitution#Left $ { AST#expression#Left solarDay 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#variable_declaration#Left const AST#variable_declarator#Left mapping = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left yearData AST#expression#Right . solarToLunar AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left solarKey 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 mapping AST#expression#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 year AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left mapping AST#expression#Right . lunarYear 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 mapping AST#expression#Right . lunarMonth 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 mapping AST#expression#Right . lunarDay 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 mapping AST#expression#Right . isLeapMonth AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left monthName 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 . getLunarMonthName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left mapping AST#expression#Right . lunarMonth AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left mapping AST#expression#Right . isLeapMonth AST#member_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 dayName 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 . getLunarDayName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left mapping AST#expression#Right . lunarDay AST#member_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 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#property_assignment#Left AST#property_name#Left yearCn AST#property_name#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 mapping AST#expression#Right . lunarYear 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#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left monthCn 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 . getLunarMonthName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left mapping AST#expression#Right . lunarMonth AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left mapping AST#expression#Right . isLeapMonth AST#member_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 dayCn 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 . getLunarDayName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left mapping AST#expression#Right . lunarDay AST#member_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 gzYear AST#property_name#Right : AST#expression#Left '' 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#if_statement#Right AST#statement#Right 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#method_declaration#Right
|
async getSolarToLunar(year: number, solarMonth: number, solarDay: number): Promise<LunarDate | null> {
await this.ensureYearMapping(year);
const yearData = this.mappingCache.get(year);
if (!yearData) return null;
const solarKey = `${solarMonth}-${solarDay}`;
const mapping = yearData.solarToLunar.get(solarKey);
if (mapping) {
return {
year: mapping.lunarYear,
month: mapping.lunarMonth,
day: mapping.lunarDay,
isLeapMonth: mapping.isLeapMonth,
monthName: this.getLunarMonthName(mapping.lunarMonth, mapping.isLeapMonth),
dayName: this.getLunarDayName(mapping.lunarDay),
zodiac: '',
ganZhi: '',
yearCn: mapping.lunarYear.toString(),
monthCn: this.getLunarMonthName(mapping.lunarMonth, mapping.isLeapMonth),
dayCn: this.getLunarDayName(mapping.lunarDay),
gzYear: ''
};
}
return null;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/calendar/LunarSolarMappingService.ets#L180-L207
|
722a42978ef3daa668ae3e722e06addd8c916ebb
|
github
|
openharmony/interface_sdk-js
|
c349adc73e2ec1f61f6fca489b5af059e3ed6999
|
api/arkui/component/repeat.d.ets
|
arkts
|
Define a builder template option parameter.
@interface TemplateOptions
@syscap SystemCapability.ArkUI.ArkUI.Full
@since 20
|
export interface TemplateOptions {
/**
* The cached number of each template.
*
* @type { ?number }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 20
*/
cachedCount?: number;
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface TemplateOptions AST#object_type#Left { /**
* The cached number of each template.
*
* @type { ?number }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 20
*/ AST#type_member#Left cachedCount ? : 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 TemplateOptions {
cachedCount?: number;
}
|
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/arkui/component/repeat.d.ets#L172-L181
|
3be8fb39eab65bc373ae08046df5e354d381aaef
|
gitee
|
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/BasicFeature/DeviceManagement/ScreenDetector/entry/src/main/ets/pages/ScreenInfo.ets
|
arkts
|
In low-code mode, do not add anything to the build function, as it will be
overwritten by the content generated by the .visual file in the build phase.
|
build() {
Column() {
Row() {
Text($r('app.string.entry_ScreenInfo'))
.fontSize(20)
.fontColor(Color.White)
.textAlign(TextAlign.Center)
}
.height('6%')
.width('100%')
.padding({ left: 15 })
.backgroundColor('#0D9FFB')
.constraintSize({ minHeight: 50 })
ShowInfo({
infoDetail: scrInfo
})
}
.width('100%')
.height('100%')
.backgroundColor('#F1F1F1')
}
|
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 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#resource_expression#Left $r ( AST#expression#Left 'app.string.entry_ScreenInfo' AST#expression#Right ) AST#resource_expression#Right 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 . fontColor ( 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 . 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#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 '6%' AST#expression#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 15 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#0D9FFB' AST#expression#Right ) AST#modifier_chain_expression#Left . constraintSize ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left minHeight AST#property_name#Right : AST#expression#Left 50 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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ShowInfo ( AST#component_parameters#Left { AST#component_parameter#Left infoDetail : AST#expression#Left scrInfo 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 . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#F1F1F1' 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#build_body#Right AST#build_method#Right
|
build() {
Column() {
Row() {
Text($r('app.string.entry_ScreenInfo'))
.fontSize(20)
.fontColor(Color.White)
.textAlign(TextAlign.Center)
}
.height('6%')
.width('100%')
.padding({ left: 15 })
.backgroundColor('#0D9FFB')
.constraintSize({ minHeight: 50 })
ShowInfo({
infoDetail: scrInfo
})
}
.width('100%')
.height('100%')
.backgroundColor('#F1F1F1')
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/BasicFeature/DeviceManagement/ScreenDetector/entry/src/main/ets/pages/ScreenInfo.ets#L34-L55
|
cf4df7e699815b5a90fc33a1d5103cfd3261466e
|
gitee
|
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/pages/Index.ets
|
arkts
|
testVibrationPattern
|
测试震动功能
|
private async testVibrationPattern(pattern: string): Promise<void> {
try {
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Testing vibration pattern: ${pattern}`);
// 这里应该调用HarmonyOS的震动API
// 实际实现中可以使用@kit.SensorServiceKit的vibrator模块
// import { vibrator } from '@kit.SensorServiceKit';
let vibrationTime = 500; // 默认震动时间
switch (pattern) {
case '短震':
vibrationTime = 100;
break;
case '长震':
vibrationTime = 1000;
|
AST#method_declaration#Left private async testVibrationPattern AST#parameter_list#Left ( 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#ERROR#Left : 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 { try { 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 ` Testing vibration pattern: AST#template_substitution#Left $ { AST#expression#Left pattern 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 // 这里应该调用HarmonyOS的震动API // 实际实现中可以使用@kit.SensorServiceKit的vibrator模块 // import { vibrator } from '@kit.SensorServiceKit'; AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left vibrationTime = AST#expression#Left 500 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 switch 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#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#object_literal#Left { AST#ERROR#Left AST#property_name#Left case AST#property_name#Right AST#ERROR#Right AST#property_assignment#Left AST#property_name#Left '短震' AST#property_name#Right : AST#expression#Left AST#assignment_expression#Left vibrationTime = AST#expression#Left 100 AST#expression#Right AST#assignment_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#break_statement#Left break ; AST#break_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 '长震' AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left vibrationTime AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left = 1000 AST#ERROR#Right ; AST#method_declaration#Right
|
private async testVibrationPattern(pattern: string): Promise<void> {
try {
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Testing vibration pattern: ${pattern}`);
let vibrationTime = 500;
switch (pattern) {
case '短震':
vibrationTime = 100;
break;
case '长震':
vibrationTime = 1000;
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/Index.ets#L6316-L6330
|
9b501ca887d0bc88b10cc61c4ff17c92b709da53
|
github
|
open9527/OpenHarmony
|
fdea69ed722d426bf04e817ec05bff4002e81a4e
|
libs/core/src/main/ets/utils/RegexUtils.ets
|
arkts
|
isValidCard
|
验证身份证号码的有效性
@param id
@returns
|
static isValidCard(id: string): boolean {
if (id.length === 18) {
const factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
const lastLetter = ["1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"];
id = id.toUpperCase();
const lastChar = id.charAt(17).toUpperCase();
let sum = 0;
id.substring(0, 17).split('').forEach((value, index) => {
sum += factor[index] * parseInt(value, 10);
});
const mod = sum % lastLetter.length;
return lastLetter[mod] === lastChar;
} else if (id.length === 15) {
const regex15 = "^[1-9]\\d{5}\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}$";
return RegexUtils.isMatch(id, regex15);
}
return false;
}
|
AST#method_declaration#Left static isValidCard 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left id AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 18 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 factor = AST#expression#Left AST#array_literal#Left [ AST#expression#Left 7 AST#expression#Right , AST#expression#Left 9 AST#expression#Right , AST#expression#Left 10 AST#expression#Right , AST#expression#Left 5 AST#expression#Right , AST#expression#Left 8 AST#expression#Right , AST#expression#Left 4 AST#expression#Right , AST#expression#Left 2 AST#expression#Right , AST#expression#Left 1 AST#expression#Right , AST#expression#Left 6 AST#expression#Right , AST#expression#Left 3 AST#expression#Right , AST#expression#Left 7 AST#expression#Right , AST#expression#Left 9 AST#expression#Right , AST#expression#Left 10 AST#expression#Right , AST#expression#Left 5 AST#expression#Right , AST#expression#Left 8 AST#expression#Right , AST#expression#Left 4 AST#expression#Right , AST#expression#Left 2 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#variable_declaration#Left const AST#variable_declarator#Left lastLetter = AST#expression#Left AST#array_literal#Left [ AST#expression#Left "1" AST#expression#Right , AST#expression#Left "0" AST#expression#Right , AST#expression#Left "X" AST#expression#Right , AST#expression#Left "9" AST#expression#Right , AST#expression#Left "8" AST#expression#Right , AST#expression#Left "7" AST#expression#Right , AST#expression#Left "6" AST#expression#Right , AST#expression#Left "5" AST#expression#Right , AST#expression#Left "4" AST#expression#Right , AST#expression#Left "3" AST#expression#Right , AST#expression#Left "2" 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 id = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left id AST#expression#Right . toUpperCase 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 lastChar = 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 id AST#expression#Right . charAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 17 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . toUpperCase 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 sum = 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#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 id 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 17 AST#expression#Right ) AST#argument_list#Right AST#call_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 . 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 value AST#parameter#Right , 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 sum += AST#expression#Left AST#call_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left factor AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right * AST#expression#Left parseInt AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left value AST#expression#Right , AST#expression#Left 10 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#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#variable_declaration#Left const AST#variable_declarator#Left mod = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left sum AST#expression#Right % AST#expression#Left lastLetter AST#expression#Right AST#binary_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#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left lastLetter AST#expression#Right [ AST#expression#Left mod AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right === AST#expression#Left lastChar AST#expression#Right AST#binary_expression#Right 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 id AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 15 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 regex15 = AST#expression#Left "^[1-9]\\d{5}\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}$" 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left RegexUtils AST#expression#Right . isMatch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left id AST#expression#Right , AST#expression#Left regex15 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#if_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#method_declaration#Right
|
static isValidCard(id: string): boolean {
if (id.length === 18) {
const factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
const lastLetter = ["1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"];
id = id.toUpperCase();
const lastChar = id.charAt(17).toUpperCase();
let sum = 0;
id.substring(0, 17).split('').forEach((value, index) => {
sum += factor[index] * parseInt(value, 10);
});
const mod = sum % lastLetter.length;
return lastLetter[mod] === lastChar;
} else if (id.length === 15) {
const regex15 = "^[1-9]\\d{5}\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}$";
return RegexUtils.isMatch(id, regex15);
}
return false;
}
|
https://github.com/open9527/OpenHarmony/blob/fdea69ed722d426bf04e817ec05bff4002e81a4e/libs/core/src/main/ets/utils/RegexUtils.ets#L242-L259
|
6d5a6cce63ba854da379d5e67692cc374514da04
|
gitee
|
harmonyos/samples
|
f5d967efaa7666550ee3252d118c3c73a77686f5
|
ETSUI/AboutSample/entry/src/main/ets/common/bean/ListItemData.ets
|
arkts
|
Basic list item data bean.
|
export class ListItemData {
/**
* Indicates unique id for list item.
*/
id: number;
/**
* Indicates list item title.
*/
title: Resource;
/**
* Indicates list item icon.
*/
icon: Resource;
/**
* Indicates list item summary.
*/
summary: Resource;
}
|
AST#export_declaration#Left export AST#class_declaration#Left class ListItemData AST#class_body#Left { /**
* Indicates unique id for list item.
*/ AST#property_declaration#Left id : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Indicates list item title.
*/ AST#property_declaration#Left title : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Indicates list item icon.
*/ AST#property_declaration#Left icon : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Indicates list item summary.
*/ AST#property_declaration#Left summary : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class ListItemData {
id: number;
title: Resource;
icon: Resource;
summary: Resource;
}
|
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/ETSUI/AboutSample/entry/src/main/ets/common/bean/ListItemData.ets#L4-L23
|
98792934113fe956a72d138ade38013435f4b867
|
gitee
|
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/DocsSample/NetWork_Kit/NetWorkKit_Datatransmission/Socket/entry/src/main/ets/connect/UdpClient_Server.ets
|
arkts
|
startServer
|
启动服务器
|
startServer() {
if (!this.serverIp || !this.serverPort) {
this.msgHistory += 'Some required fields are missing.\n';
Logger.error('Some required fields are missing.');
return;
}
let tcpMessage: TcpMessage = {
type: 'startServer',
serverIp: this.serverIp,
serverPort: this.serverPort,
};
workerPort.postMessage(tcpMessage);
workerPort.onmessage = (e: MessageEvents) => {
const response: TcpMessage = e.data;
if (response.type === 'listen success') {
this.msgHistory += 'Server listening success.\n';
}
if (response.type === 'received message--') {
this.msgHistory += `Received message: ${response.message}\n`;
} else if (response.type === 'listen fail') {
this.msgHistory += 'Listen fail.\n';
}
}
}
|
AST#method_declaration#Left startServer 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 AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . serverIp 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 . serverPort AST#member_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 . msgHistory AST#member_expression#Right += AST#expression#Left 'Some required fields are missing.\n' 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 . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Some required fields are missing.' 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 tcpMessage : AST#type_annotation#Left AST#primary_type#Left TcpMessage AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left 'startServer' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left serverIp AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . serverIp AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left serverPort AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . serverPort AST#member_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 workerPort AST#expression#Right . postMessage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tcpMessage 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 workerPort AST#expression#Right . onmessage AST#member_expression#Right = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left e : AST#type_annotation#Left AST#primary_type#Left MessageEvents 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 const AST#variable_declarator#Left response : AST#type_annotation#Left AST#primary_type#Left TcpMessage AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left e AST#expression#Right . data 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#member_expression#Left AST#expression#Left response AST#expression#Right . type AST#member_expression#Right AST#expression#Right === AST#expression#Left 'listen success' 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 . msgHistory AST#member_expression#Right += AST#expression#Left 'Server listening success.\n' 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#member_expression#Left AST#expression#Left response AST#expression#Right . type AST#member_expression#Right AST#expression#Right === AST#expression#Left 'received message--' 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 . msgHistory AST#member_expression#Right += AST#expression#Left AST#template_literal#Left ` Received message: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right \n ` 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 else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . type AST#member_expression#Right AST#expression#Right === AST#expression#Left 'listen fail' 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 . msgHistory AST#member_expression#Right += AST#expression#Left 'Listen fail.\n' 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#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#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
startServer() {
if (!this.serverIp || !this.serverPort) {
this.msgHistory += 'Some required fields are missing.\n';
Logger.error('Some required fields are missing.');
return;
}
let tcpMessage: TcpMessage = {
type: 'startServer',
serverIp: this.serverIp,
serverPort: this.serverPort,
};
workerPort.postMessage(tcpMessage);
workerPort.onmessage = (e: MessageEvents) => {
const response: TcpMessage = e.data;
if (response.type === 'listen success') {
this.msgHistory += 'Server listening success.\n';
}
if (response.type === 'received message--') {
this.msgHistory += `Received message: ${response.message}\n`;
} else if (response.type === 'listen fail') {
this.msgHistory += 'Listen fail.\n';
}
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/NetWork_Kit/NetWorkKit_Datatransmission/Socket/entry/src/main/ets/connect/UdpClient_Server.ets#L209-L236
|
6f69e56c572f2f82f0cd834b50035be261f0c246
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/pages/Index.ets
|
arkts
|
buildInfoItem
|
信息项
|
@Builder
buildInfoItem(label: string, value: string) {
Row() {
Text(label)
.fontSize(16)
.fontColor(this.COLORS.textSecondary)
.layoutWeight(1)
Text(value)
.fontSize(16)
.fontWeight(FontWeight.Medium)
.fontColor(this.COLORS.textPrimary)
}
.width('100%')
.padding(12)
.backgroundColor(this.COLORS.gray50)
.borderRadius(8)
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildInfoItem AST#parameter_list#Left ( AST#parameter#Left label : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left value : 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 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 label 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#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . COLORS AST#member_expression#Right AST#expression#Right . textSecondary AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 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 value 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#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . COLORS AST#member_expression#Right AST#expression#Right . textPrimary 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 12 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . COLORS AST#member_expression#Right AST#expression#Right . gray50 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 8 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
buildInfoItem(label: string, value: string) {
Row() {
Text(label)
.fontSize(16)
.fontColor(this.COLORS.textSecondary)
.layoutWeight(1)
Text(value)
.fontSize(16)
.fontWeight(FontWeight.Medium)
.fontColor(this.COLORS.textPrimary)
}
.width('100%')
.padding(12)
.backgroundColor(this.COLORS.gray50)
.borderRadius(8)
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/Index.ets#L3893-L3910
|
d230b051c9f3f9919ce5a79b95c7fad8c9e27a51
|
github
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/crypto/RSA.ets
|
arkts
|
decrypt
|
解密,异步
@param data 加密或者解密的数据。data不能为null。
@param priKey 指定解密私钥。
@param transformation 待生成Cipher的算法名称(含密钥长度)、加密模式以及填充方法的组合(RSA1024|PKCS1、RSA2048|PKCS1、等)。
|
static async decrypt(data: cryptoFramework.DataBlob, priKey: cryptoFramework.PriKey,
transformation: crypto.RSA_TRAN = 'RSA1024|PKCS1'): Promise<cryptoFramework.DataBlob> {
return CryptoUtil.decrypt(data, priKey, null, transformation);
}
|
AST#method_declaration#Left static async decrypt AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left priKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . PriKey AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left transformation : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left crypto . RSA_TRAN AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'RSA1024|PKCS1' AST#expression#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#qualified_type#Left cryptoFramework . DataBlob 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#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 . decrypt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right , AST#expression#Left priKey AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right , AST#expression#Left transformation 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 decrypt(data: cryptoFramework.DataBlob, priKey: cryptoFramework.PriKey,
transformation: crypto.RSA_TRAN = 'RSA1024|PKCS1'): Promise<cryptoFramework.DataBlob> {
return CryptoUtil.decrypt(data, priKey, null, transformation);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/crypto/RSA.ets#L58-L61
|
9a70cb939b0c7936b0036415a89ea2bf3cb2f1db
|
gitee
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/common/utils/DbFileUtility.ets
|
arkts
|
getFileExtension
|
获取文件扩展名(不带点)
@param filename 文件名
@returns 文件扩展名(小写)
|
private static getFileExtension(filename: string): string {
const dotIndex = filename.lastIndexOf('.');
return dotIndex === -1 ? '' : filename.substring(dotIndex + 1).toLowerCase();
}
|
AST#method_declaration#Left private static getFileExtension AST#parameter_list#Left ( AST#parameter#Left filename : 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#variable_declaration#Left const AST#variable_declarator#Left dotIndex = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left filename AST#expression#Right . lastIndexOf 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#return_statement#Left return 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#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left dotIndex AST#expression#Right === AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left '' AST#expression#Right : AST#expression#Left filename AST#expression#Right AST#conditional_expression#Right AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left dotIndex AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . toLowerCase 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
|
private static getFileExtension(filename: string): string {
const dotIndex = filename.lastIndexOf('.');
return dotIndex === -1 ? '' : filename.substring(dotIndex + 1).toLowerCase();
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/utils/DbFileUtility.ets#L186-L189
|
affee97cbff01f593a162e6e529be6541f3d3e19
|
github
|
openharmony/developtools_profiler
|
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
|
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/components/AxisBase.ets
|
arkts
|
default constructor
|
constructor() {
super();
this.mTextSize = 10;
this.mXOffset = Utils.convertDpToPixel(5);
this.mYOffset = Utils.convertDpToPixel(5);
this.mLimitLines = new JArrayList<LimitLine>();
}
|
AST#constructor_declaration#Left constructor 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 super 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 . mTextSize AST#member_expression#Right = AST#expression#Left 10 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 . mXOffset 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 . convertDpToPixel AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 5 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mYOffset 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 . convertDpToPixel AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 5 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mLimitLines AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left JArrayList AST#expression#Right AST#new_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left LimitLine AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#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#constructor_declaration#Right
|
constructor() {
super();
this.mTextSize = 10;
this.mXOffset = Utils.convertDpToPixel(5);
this.mYOffset = Utils.convertDpToPixel(5);
this.mLimitLines = new JArrayList<LimitLine>();
}
|
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/components/AxisBase.ets#L193-L199
|
b0cd1e00e2332b1bca31629dfb86c769c0018c79
|
gitee
|
|
azhuge233/ASFShortcut-HN.git
|
d1669c920c56317611b5b0375aa5315c1b91211b
|
entry/src/main/ets/asfcommandwidget/entryformability/EntryFormAbility.ets
|
arkts
|
onRemoveForm
|
Tips 卡片变换大小时会调用,删除被变换的 Form
|
async onRemoveForm(formId: string) {
// Called to notify the form provider that a specified form has been destroyed.
Logger.debug(this.LOG_TAG, `onRemoveForm() formID: ${formId}`);
this.init();
await this.unbindForm(formId);
}
|
AST#method_declaration#Left async onRemoveForm AST#parameter_list#Left ( AST#parameter#Left formId : 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 { // Called to notify the form provider that a specified form has been destroyed. 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 . debug 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 . LOG_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` onRemoveForm() formID: AST#template_substitution#Left $ { AST#expression#Left formId 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this 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#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 . unbindForm AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left formId 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
|
async onRemoveForm(formId: string) {
Logger.debug(this.LOG_TAG, `onRemoveForm() formID: ${formId}`);
this.init();
await this.unbindForm(formId);
}
|
https://github.com/azhuge233/ASFShortcut-HN.git/blob/d1669c920c56317611b5b0375aa5315c1b91211b/entry/src/main/ets/asfcommandwidget/entryformability/EntryFormAbility.ets#L31-L38
|
674cdd4a705ae0eb6adf48db4705839c9217ec09
|
github
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/calendarswitch/src/main/ets/customcalendar/model/CalendarModel.ets
|
arkts
|
一天的信息。包含农历
|
export interface Day {
dayNum: number, // 日期
lunarDay: string, // 农历中文日期
dayInfo: DayInfo, // 一天的年月日信息
isShowSchedulePoint: boolean // 是否显示日程点
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface Day AST#object_type#Left { AST#type_member#Left dayNum : 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 lunarDay : 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 dayInfo : AST#type_annotation#Left AST#primary_type#Left DayInfo AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right , // 一天的年月日信息 AST#type_member#Left isShowSchedulePoint : AST#type_annotation#Left AST#primary_type#Left boolean 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 Day {
dayNum: number,
lunarDay: string,
dayInfo: DayInfo,
isShowSchedulePoint: boolean
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/calendarswitch/src/main/ets/customcalendar/model/CalendarModel.ets#L32-L37
|
f2dcc7bc5542f8111f3389c6ab00a2848112cf4a
|
gitee
|
|
Joker-x-dev/HarmonyKit.git
|
f97197ce157df7f303244fba42e34918306dfb08
|
core/util/src/main/ets/toast/ToastUtils.ets
|
arkts
|
showError
|
显示失败提示
@param {string | ResourceStr} message - 提示内容
@returns {void} 无返回值
|
static showError(message: string | ResourceStr): void {
IBestToast.show({
type: "fail",
message: message
});
}
|
AST#method_declaration#Left static showError 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 type AST#property_name#Right : AST#expression#Left "fail" 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 showError(message: string | ResourceStr): void {
IBestToast.show({
type: "fail",
message: message
});
}
|
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/util/src/main/ets/toast/ToastUtils.ets#L34-L39
|
e997486cc7c4cd1d4dc5899c79bac0d1fb0df217
|
github
|
awa_Liny/LinysBrowser_NEXT
|
a5cd96a9aa8114cae4972937f94a8967e55d4a10
|
home/src/main/ets/blocks/modules/meowMoreOptions.ets
|
arkts
|
can_save_zone
|
Enabled
|
can_save_zone() {
return this.is_zone || !this.zones.includes(this.my_window_alias);
}
|
AST#method_declaration#Left can_save_zone AST#parameter_list#Left ( ) AST#parameter_list#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 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 . is_zone 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 . zones AST#member_expression#Right AST#expression#Right . includes 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 . my_window_alias 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 } AST#block_statement#Right AST#method_declaration#Right
|
can_save_zone() {
return this.is_zone || !this.zones.includes(this.my_window_alias);
}
|
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/blocks/modules/meowMoreOptions.ets#L396-L398
|
a7a1ef07a9e58abb13f1c5faf7527653dcf40baf
|
gitee
|
RedRackham-R/WanAndroidHarmoney.git
|
0bb2a7c8d7b49194a96e42a380d43b7e106cdb22
|
entry/src/main/ets/ui/layout/BannerItemLayout.ets
|
arkts
|
BannerItemLayout
|
bannerUI页面
|
@Component
export struct BannerItemLayout {
@State private banners: Array<IBanner> = []
private swiperController: SwiperController = new SwiperController()
onItemClick: (item: IBanner) => void
build() {
Swiper(this.swiperController) {
ForEach(this.banners, (value: IBanner) => {
this.bannerContentComponent(value)
})
}
.indicatorStyle({
bottom: 0,
right: 0,
})
.cachedCount(this.banners.length)
.index(0)
.autoPlay(true)
.interval(4000)
.indicator(true)
.loop(true)
.duration(1000)
.itemSpace(0)
.curve(Curve.Linear)
.onChange((index: number) => {
console.info(index.toString())
})
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct BannerItemLayout AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right private banners : 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 IBanner 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 AST#property_declaration#Left private swiperController : AST#type_annotation#Left AST#primary_type#Left SwiperController 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#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 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 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 AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left SwiperController 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#ERROR#Left onItemClick : AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left IBanner AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ) AST#ERROR#Right => AST#ERROR#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#unary_expression#Left void AST#expression#Left build AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Right { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left Swiper AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . swiperController 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#property_name#Left ForEach AST#property_name#Right ( this AST#ERROR#Right . banners AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left IBanner 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 . bannerContentComponent 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#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#ERROR#Left } AST#ERROR#Right . indicatorStyle 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 bottom AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right 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 . cachedCount 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 . banners AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . index AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . autoPlay AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( 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 . interval AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 4000 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . indicator AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( 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 . loop AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( 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 . duration AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1000 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . itemSpace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . curve AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Curve AST#expression#Right . Linear AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . onChange 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 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#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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left index 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#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#property_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct BannerItemLayout {
@State private banners: Array<IBanner> = []
private swiperController: SwiperController = new SwiperController()
onItemClick: (item: IBanner) => void
build() {
Swiper(this.swiperController) {
ForEach(this.banners, (value: IBanner) => {
this.bannerContentComponent(value)
})
}
.indicatorStyle({
bottom: 0,
right: 0,
})
.cachedCount(this.banners.length)
.index(0)
.autoPlay(true)
.interval(4000)
.indicator(true)
.loop(true)
.duration(1000)
.itemSpace(0)
.curve(Curve.Linear)
.onChange((index: number) => {
console.info(index.toString())
})
}
|
https://github.com/RedRackham-R/WanAndroidHarmoney.git/blob/0bb2a7c8d7b49194a96e42a380d43b7e106cdb22/entry/src/main/ets/ui/layout/BannerItemLayout.ets#L6-L34
|
1f8cf4169126ebb8edaa06a321a8054c53325755
|
github
|
openharmony/arkui_ace_engine
|
30c7d1ee12fbedf0fabece54291d75897e2ad44f
|
frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/Storage.ets
|
arkts
|
setAndProp
|
Called when dynamic properties are set.
@since 10
|
static setAndProp<T>(propName: string, defaultValue: T): SubscribedAbstractProperty<T> {
return StorageMap.shared.setAndProp(propName, defaultValue)
}
|
AST#method_declaration#Left static setAndProp AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left propName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left defaultValue : 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 AST#generic_type#Left SubscribedAbstractProperty 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#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 AST#member_expression#Left AST#expression#Left StorageMap AST#expression#Right . shared AST#member_expression#Right AST#expression#Right . setAndProp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left propName AST#expression#Right , AST#expression#Left defaultValue 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 setAndProp<T>(propName: string, defaultValue: T): SubscribedAbstractProperty<T> {
return StorageMap.shared.setAndProp(propName, defaultValue)
}
|
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/Storage.ets#L108-L110
|
b85fac2196ee7e66965741ad5e35003b53c861cc
|
gitee
|
charon2pluto/MoodDiary-HarmonyOS.git
|
0ec7ee6861e150bc9b4571062dbf302d1b106b8c
|
entry/src/main/ets/utils/MoodDB.ets
|
arkts
|
loginUser
|
登录:成功后记录 UserID
|
static async loginUser(username: string, password: string): Promise<boolean> {
if (!MoodDB.rdbStore) return Promise.reject('DB Error');
let predicates = new relationalStore.RdbPredicates('USER_TABLE');
predicates.equalTo('username', username);
predicates.equalTo('password', password);
let resultSet = await MoodDB.rdbStore.query(predicates);
if (resultSet.goToFirstRow()) {
// ★ 登录成功,把 ID 记下来!
MoodDB.currentUserId = resultSet.getLong(resultSet.getColumnIndex('id'));
resultSet.close();
return true;
}
resultSet.close();
return false;
}
|
AST#method_declaration#Left static async loginUser AST#parameter_list#Left ( AST#parameter#Left username : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left password : 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#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left MoodDB AST#expression#Right AST#unary_expression#Right AST#expression#Right . rdbStore AST#member_expression#Right AST#expression#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 Promise AST#expression#Right . reject AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'DB Error' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left predicates = 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 relationalStore AST#expression#Right AST#new_expression#Right AST#expression#Right . RdbPredicates AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'USER_TABLE' 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 predicates AST#expression#Right . equalTo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'username' AST#expression#Right , AST#expression#Left username 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 predicates AST#expression#Right . equalTo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'password' AST#expression#Right , AST#expression#Left password 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 resultSet = 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 MoodDB AST#expression#Right AST#await_expression#Right AST#expression#Right . rdbStore AST#member_expression#Right AST#expression#Right . query AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left predicates 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . goToFirstRow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { // ★ 登录成功,把 ID 记下来! AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left MoodDB AST#expression#Right . currentUserId AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getLong 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 resultSet AST#expression#Right . getColumnIndex 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#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 resultSet AST#expression#Right . close 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#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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . close 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#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
|
static async loginUser(username: string, password: string): Promise<boolean> {
if (!MoodDB.rdbStore) return Promise.reject('DB Error');
let predicates = new relationalStore.RdbPredicates('USER_TABLE');
predicates.equalTo('username', username);
predicates.equalTo('password', password);
let resultSet = await MoodDB.rdbStore.query(predicates);
if (resultSet.goToFirstRow()) {
MoodDB.currentUserId = resultSet.getLong(resultSet.getColumnIndex('id'));
resultSet.close();
return true;
}
resultSet.close();
return false;
}
|
https://github.com/charon2pluto/MoodDiary-HarmonyOS.git/blob/0ec7ee6861e150bc9b4571062dbf302d1b106b8c/entry/src/main/ets/utils/MoodDB.ets#L57-L73
|
67dcfd2b2855d673468101a58173211e153e4045
|
github
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
ArkUI/UI_Component_Performance_Optimization/entry/src/main/ets/segment/segment8.ets
|
arkts
|
UserCardBuilder
|
[Start Case6] 1. Customizing @Builder Function Components
|
@Builder
function UserCardBuilder(name: string, age?: number, avatarImage?: ResourceStr) {
Row() {
Row() {
Image(avatarImage)
.size({ width: 50, height: 50 })
.borderRadius(25)
.margin(8)
Text(name)
.fontSize(30)
}
Text(`age:${age?.toString()}`)
.fontSize(20)
}
.backgroundColor(Color.Blue)
.justifyContent(FlexAlign.SpaceBetween)
.borderRadius(8)
.padding(8)
.height(66)
.width('80%')
}
|
AST#decorated_function_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right function UserCardBuilder AST#parameter_list#Left ( AST#parameter#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left age ? : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left avatarImage ? : AST#type_annotation#Left AST#primary_type#Left ResourceStr 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 Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left avatarImage AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . size ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left 50 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left 50 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left 8 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 name AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 30 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#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 ` age: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left age 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#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 20 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 . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Blue AST#member_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 . SpaceBetween AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 8 AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left 8 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 66 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '80%' 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#builder_function_body#Right AST#decorated_function_declaration#Right
|
@Builder
function UserCardBuilder(name: string, age?: number, avatarImage?: ResourceStr) {
Row() {
Row() {
Image(avatarImage)
.size({ width: 50, height: 50 })
.borderRadius(25)
.margin(8)
Text(name)
.fontSize(30)
}
Text(`age:${age?.toString()}`)
.fontSize(20)
}
.backgroundColor(Color.Blue)
.justifyContent(FlexAlign.SpaceBetween)
.borderRadius(8)
.padding(8)
.height(66)
.width('80%')
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ArkUI/UI_Component_Performance_Optimization/entry/src/main/ets/segment/segment8.ets#L29-L49
|
634202dbcbbb345b62732e816ac13f876759fcec
|
gitee
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/common/utils/TEUtility.ets
|
arkts
|
clipString
|
② 全角分号(;) ---------- 对外方法:clipString(srcString) ----------
|
static clipString(srcString: string | undefined | null): string {
if (srcString) {
return TEUtility.clipStringWithLength(srcString, 10);
}
return ''
}
|
AST#method_declaration#Left static clipString AST#parameter_list#Left ( AST#parameter#Left srcString : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left undefined 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 string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left srcString AST#expression#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 TEUtility AST#expression#Right . clipStringWithLength AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcString AST#expression#Right , AST#expression#Left 10 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#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left '' AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static clipString(srcString: string | undefined | null): string {
if (srcString) {
return TEUtility.clipStringWithLength(srcString, 10);
}
return ''
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/utils/TEUtility.ets#L179-L184
|
656752551c4bd096c9212736f260ea81364846ac
|
github
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/tabcontentoverflow/src/main/ets/common/Constants.ets
|
arkts
|
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.
|
export const CONFIGURATION: Record<string, number> = {
'TABCONTENT_OVERFLOW_TOAST_DURATION': 300,
'TABCONTENT_OVERFLOW_INTERVAL_NUMBER': 30,
'TABCONTENT_OVERFLOW_ZINDEX': 2,
'TABCONTENT_OVERFLOW_TABS_DURATION': 100,
'TABCONTENT_OVERFLOW_OPACITY': 0.5,
'TABCONTENT_OVERFLOW_TEXT_OPACITY': 0.7,
'TABCONTENT_OVERFLOW_TEXT_TRANSLATE': 0,
'TABCONTENT_OVERFLOW_TEXT_TOUCH_TRANSLATE': -15,
'TABCONTENT_OVERFLOW_TEXT_THREE_MARGIN_TOP': -7.5,
'TABCONTENT_OVERFLOW_TEXT_THREE_MARGIN_LEFT': -10,
'TABCONTENT_OVERFLOW_ZERO': 0,
'TABCONTENT_OVERFLOW_ONE': 1,
'TABCONTENT_OVERFLOW_TWO': 2,
'TABCONTENT_OVERFLOW_TEN': 10,
'TABCONTENT_OVERFLOW_DURATION': 200,
'TABCONTENT_OVERFLOW_HEADIMAGE_BORDER_RADIUS': 22.5,
'TABCONTENT_OVERFLOW_HEADIMAGE_MARGIN_LEFT': 7.5,
'TABCONTENT_OVERFLOW_MAXLINE': 2,
}
|
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left CONFIGURATION : 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 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left 'TABCONTENT_OVERFLOW_TOAST_DURATION' AST#property_name#Right : AST#expression#Left 300 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TABCONTENT_OVERFLOW_INTERVAL_NUMBER' AST#property_name#Right : AST#expression#Left 30 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TABCONTENT_OVERFLOW_ZINDEX' AST#property_name#Right : AST#expression#Left 2 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TABCONTENT_OVERFLOW_TABS_DURATION' AST#property_name#Right : AST#expression#Left 100 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TABCONTENT_OVERFLOW_OPACITY' AST#property_name#Right : AST#expression#Left 0.5 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TABCONTENT_OVERFLOW_TEXT_OPACITY' AST#property_name#Right : AST#expression#Left 0.7 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TABCONTENT_OVERFLOW_TEXT_TRANSLATE' AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TABCONTENT_OVERFLOW_TEXT_TOUCH_TRANSLATE' AST#property_name#Right : AST#expression#Left AST#unary_expression#Left - AST#expression#Left 15 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TABCONTENT_OVERFLOW_TEXT_THREE_MARGIN_TOP' AST#property_name#Right : AST#expression#Left AST#unary_expression#Left - AST#expression#Left 7.5 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TABCONTENT_OVERFLOW_TEXT_THREE_MARGIN_LEFT' AST#property_name#Right : AST#expression#Left AST#unary_expression#Left - AST#expression#Left 10 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TABCONTENT_OVERFLOW_ZERO' AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TABCONTENT_OVERFLOW_ONE' AST#property_name#Right : AST#expression#Left 1 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TABCONTENT_OVERFLOW_TWO' AST#property_name#Right : AST#expression#Left 2 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TABCONTENT_OVERFLOW_TEN' AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TABCONTENT_OVERFLOW_DURATION' AST#property_name#Right : AST#expression#Left 200 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TABCONTENT_OVERFLOW_HEADIMAGE_BORDER_RADIUS' AST#property_name#Right : AST#expression#Left 22.5 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TABCONTENT_OVERFLOW_HEADIMAGE_MARGIN_LEFT' AST#property_name#Right : AST#expression#Left 7.5 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'TABCONTENT_OVERFLOW_MAXLINE' AST#property_name#Right : AST#expression#Left 2 AST#expression#Right AST#property_assignment#Right , } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#export_declaration#Right
|
export const CONFIGURATION: Record<string, number> = {
'TABCONTENT_OVERFLOW_TOAST_DURATION': 300,
'TABCONTENT_OVERFLOW_INTERVAL_NUMBER': 30,
'TABCONTENT_OVERFLOW_ZINDEX': 2,
'TABCONTENT_OVERFLOW_TABS_DURATION': 100,
'TABCONTENT_OVERFLOW_OPACITY': 0.5,
'TABCONTENT_OVERFLOW_TEXT_OPACITY': 0.7,
'TABCONTENT_OVERFLOW_TEXT_TRANSLATE': 0,
'TABCONTENT_OVERFLOW_TEXT_TOUCH_TRANSLATE': -15,
'TABCONTENT_OVERFLOW_TEXT_THREE_MARGIN_TOP': -7.5,
'TABCONTENT_OVERFLOW_TEXT_THREE_MARGIN_LEFT': -10,
'TABCONTENT_OVERFLOW_ZERO': 0,
'TABCONTENT_OVERFLOW_ONE': 1,
'TABCONTENT_OVERFLOW_TWO': 2,
'TABCONTENT_OVERFLOW_TEN': 10,
'TABCONTENT_OVERFLOW_DURATION': 200,
'TABCONTENT_OVERFLOW_HEADIMAGE_BORDER_RADIUS': 22.5,
'TABCONTENT_OVERFLOW_HEADIMAGE_MARGIN_LEFT': 7.5,
'TABCONTENT_OVERFLOW_MAXLINE': 2,
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/tabcontentoverflow/src/main/ets/common/Constants.ets#L16-L35
|
fcf13c6fb15337a17c770c8f630e19dbbe32ff72
|
gitee
|
|
xinkai-hu/MyDay.git
|
dcbc82036cf47b8561b0f2a7783ff0078a7fe61d
|
entry/src/main/ets/common/constants/ApiKey.ets
|
arkts
|
网络请求时使用的 API 密钥。
|
export default class ApiKey {
/**
* 高德地图网络请求密钥。
*/
public static readonly key: string = '1cfc033b636eb37ab3b8eba82bf2cabd';
}
|
AST#export_declaration#Left export default AST#class_declaration#Left class ApiKey AST#class_body#Left { /**
* 高德地图网络请求密钥。
*/ AST#property_declaration#Left public static readonly key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '1cfc033b636eb37ab3b8eba82bf2cabd' AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export default class ApiKey {
public static readonly key: string = '1cfc033b636eb37ab3b8eba82bf2cabd';
}
|
https://github.com/xinkai-hu/MyDay.git/blob/dcbc82036cf47b8561b0f2a7783ff0078a7fe61d/entry/src/main/ets/common/constants/ApiKey.ets#L4-L9
|
bd5d4b159c8085487a0365cebefe184323897c9f
|
github
|
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/UI/ExpandTitle/entry/src/main/ets/pages/MemoItem.ets
|
arkts
|
MemoItem
|
笔记内容视图
|
@Component
export default struct MemoItem {
@State memoItem: MemoInfo = MEMO_DATA[0];
build() {
Row() {
Column({ space: Constants.MEMO_COL_SPACE }) {
Text(this.memoItem.title)
.fontSize($r('app.float.expanded_title_font_size_normal'))
.memoTextExpand()
.fontColor($r('app.color.expanded_title_font_color_light_dark'))
Text(this.memoItem.content)
.fontSize($r('app.float.expanded_title_font_size_smaller'))
.memoTextExpand()
.margin({ top: $r('app.string.expanded_title_layout_10'), bottom: $r('app.string.expanded_title_layout_10') })
.fontColor($r('app.color.expanded_title_font_color_light_dark'))
Text(this.memoItem.time)
.fontSize($r('app.float.expanded_title_font_size_smaller'))
.memoTextExpand()
.fontColor(Color.Grey)
}
.alignItems(HorizontalAlign.Start)
.width($r('app.string.expanded_title_layout_70_percent'))
Image($r(this.memoItem.imageSrc))
.width($r('app.string.expanded_title_layout_90'))
.aspectRatio(Constants.MEMO_IMAGE_ASPECT_RATIO)
.borderRadius($r('app.string.expanded_title_layout_10'))
}
.height($r('app.string.expanded_title_layout_110'))
.backgroundColor($r('app.color.expanded_title_list_item_normal_color'))
.width($r('app.string.expanded_title_layout_100_percent'))
.justifyContent(FlexAlign.SpaceBetween)
.borderRadius($r('app.float.expanded_title_list_item_border_radius'))
.padding({ left: $r('app.float.expanded_title_list_item_padding'), right: $r('app.float.expanded_title_list_item_padding') })
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export default struct MemoItem AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right memoItem : AST#type_annotation#Left AST#primary_type#Left MemoInfo AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left MEMO_DATA AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ; AST#property_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 Row ( ) AST#container_content_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 AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . MEMO_COL_SPACE AST#member_expression#Right 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 AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . memoItem AST#member_expression#Right AST#expression#Right . title AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.expanded_title_font_size_normal' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . memoTextExpand ( ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.expanded_title_font_color_light_dark' 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 AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . memoItem AST#member_expression#Right AST#expression#Right . content AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.expanded_title_font_size_smaller' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . memoTextExpand ( ) 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.string.expanded_title_layout_10' 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 AST#resource_expression#Left $r ( AST#expression#Left 'app.string.expanded_title_layout_10' 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 . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.expanded_title_font_color_light_dark' 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#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 . memoItem AST#member_expression#Right AST#expression#Right . time AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.expanded_title_font_size_smaller' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . memoTextExpand ( ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Grey 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 . 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#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.expanded_title_layout_70_percent' 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#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#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . memoItem AST#member_expression#Right AST#expression#Right . imageSrc AST#member_expression#Right AST#expression#Right ) AST#resource_expression#Right 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.string.expanded_title_layout_90' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . aspectRatio ( AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . MEMO_IMAGE_ASPECT_RATIO AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.expanded_title_layout_10' 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#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.expanded_title_layout_110' 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.expanded_title_list_item_normal_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.expanded_title_layout_100_percent' 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 . SpaceBetween AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.expanded_title_list_item_border_radius' AST#expression#Right ) AST#resource_expression#Right 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 AST#resource_expression#Left $r ( AST#expression#Left 'app.float.expanded_title_list_item_padding' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.expanded_title_list_item_padding' 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#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 default struct MemoItem {
@State memoItem: MemoInfo = MEMO_DATA[0];
build() {
Row() {
Column({ space: Constants.MEMO_COL_SPACE }) {
Text(this.memoItem.title)
.fontSize($r('app.float.expanded_title_font_size_normal'))
.memoTextExpand()
.fontColor($r('app.color.expanded_title_font_color_light_dark'))
Text(this.memoItem.content)
.fontSize($r('app.float.expanded_title_font_size_smaller'))
.memoTextExpand()
.margin({ top: $r('app.string.expanded_title_layout_10'), bottom: $r('app.string.expanded_title_layout_10') })
.fontColor($r('app.color.expanded_title_font_color_light_dark'))
Text(this.memoItem.time)
.fontSize($r('app.float.expanded_title_font_size_smaller'))
.memoTextExpand()
.fontColor(Color.Grey)
}
.alignItems(HorizontalAlign.Start)
.width($r('app.string.expanded_title_layout_70_percent'))
Image($r(this.memoItem.imageSrc))
.width($r('app.string.expanded_title_layout_90'))
.aspectRatio(Constants.MEMO_IMAGE_ASPECT_RATIO)
.borderRadius($r('app.string.expanded_title_layout_10'))
}
.height($r('app.string.expanded_title_layout_110'))
.backgroundColor($r('app.color.expanded_title_list_item_normal_color'))
.width($r('app.string.expanded_title_layout_100_percent'))
.justifyContent(FlexAlign.SpaceBetween)
.borderRadius($r('app.float.expanded_title_list_item_border_radius'))
.padding({ left: $r('app.float.expanded_title_list_item_padding'), right: $r('app.float.expanded_title_list_item_padding') })
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/UI/ExpandTitle/entry/src/main/ets/pages/MemoItem.ets#L23-L60
|
1176d06f45a662d6e1b164542f922aa3e371b831
|
gitee
|
harmonyos/samples
|
f5d967efaa7666550ee3252d118c3c73a77686f5
|
HarmonyOS_NEXT/Media/VideoPlay/entry/src/main/ets/pages/Index.ets
|
arkts
|
setTimer
|
视频索引
|
setTimer(): void {
let that = this;
this.timeout = setTimeout(() => {
that.isClickScreen = false; // 隐藏操作面板
}, SET_TIME_OUT); // 8秒后隐藏
}
|
AST#method_declaration#Left setTimer AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left that = AST#expression#Left this 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 . timeout AST#member_expression#Right = 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . isClickScreen 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#expression#Left SET_TIME_OUT 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 // 8秒后隐藏 } AST#block_statement#Right AST#method_declaration#Right
|
setTimer(): void {
let that = this;
this.timeout = setTimeout(() => {
that.isClickScreen = false;
}, SET_TIME_OUT);
}
|
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/HarmonyOS_NEXT/Media/VideoPlay/entry/src/main/ets/pages/Index.ets#L77-L82
|
f72f8eca4a262480d5ed6558abb5d525f5af86ba
|
gitee
|
sithvothykiv/dialog_hub.git
|
b676c102ef2d05f8994d170abe48dcc40cd39005
|
custom_dialog/src/main/ets/model/DialogConfig.ets
|
arkts
|
弹窗配置(初始化默认值)
|
export class DialogConfig implements IDialogStyle {
//------------------------------------公共参数---promptAction.BaseDialogOptions----------------------------------------
/**
* 设置 UIAbilityContext(用于吐司类弹窗 需要)
* 其他类型弹窗为 NavDestination.mode(NavDestinationMode.DIALOG) 无需设置
*/
uiAbilityContext?: common.UIAbilityContext;
/**
* 点击遮障层时,是否关闭弹窗,true表示关闭弹窗。false表示不关闭弹窗。默认值:true
*/
autoCancel: boolean = true;
/**
* 弹窗的对齐方式。
*/
alignment: DialogAlignment = DialogAlignment.Default;
/**
* 弹窗层级模式。
* @default 默认值:LevelMode.EMBEDDED页面级(即弹窗内跳新页面弹窗会隐藏,OVERLAY模式不隐藏)
*/
levelMode: LevelMode = LevelMode.EMBEDDED;
/**
* 自定义蒙层颜色。默认值 0x33000000
*/
maskColor: ResourceColor = '#B3000000';
/**
* 交互式关闭回调函数。
*/
onWillDismiss?: Callback<DismissDialogAction>;
/**
* 弹窗消失时的事件回调。
*/
onDidDisappear?: VoidCallback;
//-----------------------------------公共参数---promptAction.BaseDialogOptions-----------------------------------------
//---------------------------------------弹框Dialog--------------------------------------------------------------------
/**
* 通用分割线颜色 TODO 放入actionSheet里
* @default 浅色模式 默认 #E8E8E8 (后续支持 深色模式切换后,默认值:#282828)
*/
commonDividerColor: ResourceColor = $r('app.color.harmony_dialog_divider_color')
/**
* 弹框标题
* @default 默认:'温馨提示'
* @description 弹窗默认都有标题,可init时,统一设置空字符串
*/
title: ResourceStr = '温馨提示';
/**
* 弹框左侧按钮。
*/
primaryButton: ResourceStr = '取消';
/**
* 弹框右侧按钮。
*/
secondaryButton: CustomButtonOptions = {
fontColor: '#FF0A59F7',
value: '确定',
fontWeight: FontWeight.Medium
};
/**
* 点击操作按钮时,是否关闭弹窗。false表示不关闭弹窗。默认值:true。
*/
actionCancel: boolean = true;
/**
* 设置弹窗的宽度,弹窗宽度默认值:'calc(100% - 32vp)'、100%。
*/
width: Dimension | Length = 'calc(100% - 90vp)';
/**
* 弹窗宽度默认最大值:360vp/400vp。
* 仅生效:居中弹窗(如文本输入 、确认弹窗)、底部滑出菜单ActionSheet(仅分离弹窗)
*/
maxWidth?: Length = 360;
/**
* 设置背板的圆角半径。可分别设置4个圆角的半径。
*/
borderRadius: Length | BorderRadiuses = {
topLeft: '16vp',
topRight: '16vp',
bottomLeft: '16vp',
bottomRight: '16vp'
};
/**
* 边框样式(可选)
* @default 默认无边框
*/
border?: BorderOptions
/**
* 弹窗背板颜色
* @默认:Color.White
*/
backgroundColor: ResourceColor = Color.White;
/**
* 弹窗背板模糊材质。默认值:无,
*/
backgroundBlurStyle?: BlurStyle ;
/**
* 弹窗背板背景图片。(弹窗时设置将优先)
* @description 注意⚠️:(仅支持自定义内容弹窗CustomDialog、文本输入TextInput、多行文本输入TextArea)
*
*/
backgroundImage?: ResourceStr
/**
* 弹窗背板背景图片铺展模式
* @default 默认ImageSize.FILL
*/
backgroundImageSize: ImageSize = ImageSize.FILL
/**
* 自定义内容弹窗内padding(可选)
* @default 为空时,系统默认 { top:24vp, bottom:24vp, right:24vp, left:24vp }
* @description 影响 自定义内容弹窗、TextInput弹窗、TextArea弹窗
*/
customContentPadding?: LocalizedPadding;
/**
* 预设自定义按钮样式(可选)
* 用于一次性初始化,后续弹窗可指定按钮 ID
*/
customStyles?: (ICustomButtonStyle | ITextStyle)[]
/**
* 弹窗挂件(可选) 为自定义挂件设置
* @description1 可自定义挂件,继承IPresetAttachImage接口即可
*/
attaches?: Map<string, IPresetAttachImage>
/**
* 【底部菜单弹窗】 特殊配置选项(如是否分离)
*/
bottomActionSheetSpecifyOptions: BottomActionSheetSpecifyOptions = new BottomActionSheetSpecifyOptions();
/**
* 【loading弹窗】 特殊配置选项
*/
loadingSpecifyOptions: LoadingSpecifyOptions = new LoadingSpecifyOptions();
/**
* 【选择器弹窗】 特殊配置选项
*/
pickerSpecifyOptions: PickerSpecifyOptions = new PickerSpecifyOptions();
/**
* 【吐司弹窗】 特殊配置选项
*/
toastSpecifyOptions: ToastSpecifyOptions = new ToastSpecifyOptions();
}
|
AST#export_declaration#Left export AST#class_declaration#Left class DialogConfig AST#implements_clause#Left implements IDialogStyle AST#implements_clause#Right AST#class_body#Left { //------------------------------------公共参数---promptAction.BaseDialogOptions---------------------------------------- /**
* 设置 UIAbilityContext(用于吐司类弹窗 需要)
* 其他类型弹窗为 NavDestination.mode(NavDestinationMode.DIALOG) 无需设置
*/ AST#property_declaration#Left uiAbilityContext ? : 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#property_declaration#Right /**
* 点击遮障层时,是否关闭弹窗,true表示关闭弹窗。false表示不关闭弹窗。默认值:true
*/ AST#property_declaration#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#property_declaration#Right /**
* 弹窗的对齐方式。
*/ AST#property_declaration#Left alignment : AST#type_annotation#Left AST#primary_type#Left DialogAlignment AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left DialogAlignment AST#expression#Right . Default AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right /**
* 弹窗层级模式。
* @default 默认值:LevelMode.EMBEDDED页面级(即弹窗内跳新页面弹窗会隐藏,OVERLAY模式不隐藏)
*/ AST#property_declaration#Left levelMode : AST#type_annotation#Left AST#primary_type#Left LevelMode AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left LevelMode AST#expression#Right . EMBEDDED AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right /**
* 自定义蒙层颜色。默认值 0x33000000
*/ AST#property_declaration#Left maskColor : AST#type_annotation#Left AST#primary_type#Left ResourceColor AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '#B3000000' AST#expression#Right ; AST#property_declaration#Right /**
* 交互式关闭回调函数。
*/ AST#property_declaration#Left onWillDismiss ? : 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 DismissDialogAction 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#property_declaration#Left onDidDisappear ? : AST#type_annotation#Left AST#primary_type#Left VoidCallback AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right //-----------------------------------公共参数---promptAction.BaseDialogOptions----------------------------------------- //---------------------------------------弹框Dialog-------------------------------------------------------------------- /**
* 通用分割线颜色 TODO 放入actionSheet里
* @default 浅色模式 默认 #E8E8E8 (后续支持 深色模式切换后,默认值:#282828)
*/ AST#property_declaration#Left commonDividerColor AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left ResourceColor AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.harmony_dialog_divider_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right /**
* 弹框标题
* @default 默认:'温馨提示'
* @description 弹窗默认都有标题,可init时,统一设置空字符串
*/ title AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '温馨提示' AST#expression#Right ; AST#property_declaration#Right /**
* 弹框左侧按钮。
*/ AST#property_declaration#Left primaryButton : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '取消' AST#expression#Right ; AST#property_declaration#Right /**
* 弹框右侧按钮。
*/ AST#property_declaration#Left secondaryButton : AST#type_annotation#Left AST#primary_type#Left CustomButtonOptions AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left fontColor AST#property_name#Right : AST#expression#Left '#FF0A59F7' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left '确定' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left fontWeight AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#property_declaration#Right /**
* 点击操作按钮时,是否关闭弹窗。false表示不关闭弹窗。默认值:true。
*/ AST#property_declaration#Left actionCancel : 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#property_declaration#Right /**
* 设置弹窗的宽度,弹窗宽度默认值:'calc(100% - 32vp)'、100%。
*/ AST#property_declaration#Left width : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Dimension AST#primary_type#Right | AST#primary_type#Left Length AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left 'calc(100% - 90vp)' AST#expression#Right ; AST#property_declaration#Right /**
* 弹窗宽度默认最大值:360vp/400vp。
* 仅生效:居中弹窗(如文本输入 、确认弹窗)、底部滑出菜单ActionSheet(仅分离弹窗)
*/ AST#property_declaration#Left maxWidth ? : AST#type_annotation#Left AST#primary_type#Left Length AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 360 AST#expression#Right ; AST#property_declaration#Right /**
* 设置背板的圆角半径。可分别设置4个圆角的半径。
*/ AST#property_declaration#Left borderRadius : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Length AST#primary_type#Right | AST#primary_type#Left BorderRadiuses AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left topLeft AST#property_name#Right : AST#expression#Left '16vp' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left topRight AST#property_name#Right : AST#expression#Left '16vp' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottomLeft AST#property_name#Right : AST#expression#Left '16vp' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottomRight AST#property_name#Right : AST#expression#Left '16vp' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#property_declaration#Right /**
* 边框样式(可选)
* @default 默认无边框
*/ AST#property_declaration#Left border ? : AST#type_annotation#Left AST#primary_type#Left BorderOptions AST#primary_type#Right AST#type_annotation#Right /**
* 弹窗背板颜色
* @默认:Color.White
*/ AST#ERROR#Left backgroundColor : ResourceColor AST#ERROR#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right /**
* 弹窗背板模糊材质。默认值:无,
*/ AST#property_declaration#Left backgroundBlurStyle ? : AST#type_annotation#Left AST#primary_type#Left BlurStyle AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* 弹窗背板背景图片。(弹窗时设置将优先)
* @description 注意⚠️:(仅支持自定义内容弹窗CustomDialog、文本输入TextInput、多行文本输入TextArea)
*
*/ AST#property_declaration#Left backgroundImage ? AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right /**
* 弹窗背板背景图片铺展模式
* @default 默认ImageSize.FILL
*/ AST#ERROR#Left background Image Size AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left ImageSize AST#primary_type#Right AST#type_annotation#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 ImageSize AST#expression#Right . FILL AST#member_expression#Right AST#expression#Right /**
* 自定义内容弹窗内padding(可选)
* @default 为空时,系统默认 { top:24vp, bottom:24vp, right:24vp, left:24vp }
* @description 影响 自定义内容弹窗、TextInput弹窗、TextArea弹窗
*/ AST#ERROR#Left customContentPadd AST#ERROR#Right in AST#expression#Left g AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#expression#Right : AST#expression#Left LocalizedPadding AST#expression#Right AST#conditional_expression#Right AST#expression#Right ; AST#property_declaration#Right /**
* 预设自定义按钮样式(可选)
* 用于一次性初始化,后续弹窗可指定按钮 ID
*/ AST#property_declaration#Left customStyles AST#ERROR#Left ? : AST#ERROR#Left AST#primary_type#Left AST#parenthesized_type#Left ( AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ICustomButtonStyle AST#primary_type#Right | AST#primary_type#Left ITextStyle AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ) AST#parenthesized_type#Right AST#primary_type#Right AST#ERROR#Right AST#primary_type#Left AST#tuple_type#Left [ ] AST#tuple_type#Right AST#primary_type#Right /**
* 弹窗挂件(可选) 为自定义挂件设置
* @description1 可自定义挂件,继承IPresetAttachImage接口即可
*/ attaches ? : Map AST#type_parameters#Left < AST#type_parameter#Left string AST#type_parameter#Right , AST#type_parameter#Left IPresetAttachImage AST#type_parameter#Right > AST#type_parameters#Right /**
* 【底部菜单弹窗】 特殊配置选项(如是否分离)
*/ bottomActionSheetSpec if yOptions AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left BottomActionSheetSpecifyOptions 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 BottomActionSheetSpecifyOptions 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 /**
* 【loading弹窗】 特殊配置选项
*/ AST#property_declaration#Left loadingSpecifyOptions : AST#type_annotation#Left AST#primary_type#Left LoadingSpecifyOptions 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 LoadingSpecifyOptions 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 pickerSpecifyOptions : AST#type_annotation#Left AST#primary_type#Left PickerSpecifyOptions 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 PickerSpecifyOptions 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 toastSpecifyOptions : AST#type_annotation#Left AST#primary_type#Left ToastSpecifyOptions 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 ToastSpecifyOptions 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#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class DialogConfig implements IDialogStyle {
uiAbilityContext?: common.UIAbilityContext;
autoCancel: boolean = true;
alignment: DialogAlignment = DialogAlignment.Default;
levelMode: LevelMode = LevelMode.EMBEDDED;
maskColor: ResourceColor = '#B3000000';
onWillDismiss?: Callback<DismissDialogAction>;
onDidDisappear?: VoidCallback;
commonDividerColor: ResourceColor = $r('app.color.harmony_dialog_divider_color')
title: ResourceStr = '温馨提示';
primaryButton: ResourceStr = '取消';
secondaryButton: CustomButtonOptions = {
fontColor: '#FF0A59F7',
value: '确定',
fontWeight: FontWeight.Medium
};
actionCancel: boolean = true;
width: Dimension | Length = 'calc(100% - 90vp)';
maxWidth?: Length = 360;
borderRadius: Length | BorderRadiuses = {
topLeft: '16vp',
topRight: '16vp',
bottomLeft: '16vp',
bottomRight: '16vp'
};
border?: BorderOptions
backgroundColor: ResourceColor = Color.White;
backgroundBlurStyle?: BlurStyle ;
backgroundImage?: ResourceStr
backgroundImageSize: ImageSize = ImageSize.FILL
customContentPadding?: LocalizedPadding;
customStyles?: (ICustomButtonStyle | ITextStyle)[]
attaches?: Map<string, IPresetAttachImage>
bottomActionSheetSpecifyOptions: BottomActionSheetSpecifyOptions = new BottomActionSheetSpecifyOptions();
loadingSpecifyOptions: LoadingSpecifyOptions = new LoadingSpecifyOptions();
pickerSpecifyOptions: PickerSpecifyOptions = new PickerSpecifyOptions();
toastSpecifyOptions: ToastSpecifyOptions = new ToastSpecifyOptions();
}
|
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/model/DialogConfig.ets#L16-L155
|
37daa0b56ef6d01e6e032c7b5edc2365ce80709b
|
github
|
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_speech/src/main/ets/SpeechRecognizerHelper.ets
|
arkts
|
writeAudio
|
写音频流,最大音频长度为60000ms。为了确保收到识别结果,请优先调用setListener和startListening。
@param sessionId 会话ID。
@param audio 待识别的音频数据,当前仅支持音频数据长度为640字节或1280字节。建议每次发送音频调用间隔为20ms(传输音频长度为640字节)或40ms(传输音频长度为1280字节)。
|
static writeAudio(sessionId: string, audio: Uint8Array): void {
SpeechRecognizerHelper.recognitionEngine?.writeAudio(sessionId, audio);
}
|
AST#method_declaration#Left static writeAudio AST#parameter_list#Left ( AST#parameter#Left sessionId : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left audio : AST#type_annotation#Left AST#primary_type#Left Uint8Array 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left SpeechRecognizerHelper AST#expression#Right . recognitionEngine AST#member_expression#Right AST#expression#Right ?. writeAudio AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sessionId AST#expression#Right , AST#expression#Left audio 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 writeAudio(sessionId: string, audio: Uint8Array): void {
SpeechRecognizerHelper.recognitionEngine?.writeAudio(sessionId, audio);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_speech/src/main/ets/SpeechRecognizerHelper.ets#L86-L88
|
bc6c29462ac9e4b49c10aa31815af546347ef613
|
gitee
|
wenfujing/honms-super-market.git
|
0858abecd8be5db7b8dcf88dcd77b7c66d37517a
|
common/src/main/ets/constants/GridConstants.ets
|
arkts
|
Constants for Grid components.
|
export class GridConstants {
/**
* Current component width: 4 grids.
*/
static readonly COLUMN_FOUR: number = 4;
/**
* Current component width: 8 grids.
*/
static readonly COLUMN_EIGHT: number = 8;
/**
* Current component width: 12 grids.
*/
static readonly COLUMN_TWELVE: number = 12;
/**
* Current component width: 1 grids.
*/
static readonly SPAN_ONE: number = 1;
/**
* Current component width: 2 grids.
*/
static readonly SPAN_TWO: number = 2;
/**
* Current component width: 3 grids.
*/
static readonly SPAN_THREE: number = 3;
/**
* Current component width: 4 grids.
*/
static readonly SPAN_FOUR: number = 4;
/**
* Current component width: 8 grids.
*/
static readonly SPAN_EIGHT: number = 8;
/**
* Current component width: 12 grids.
*/
static readonly SPAN_TWELVE: number = 12;
/**
* Current component offset 2 grids.
*/
static readonly OFFSET_TWO: number = 2;
/**
* Current component offset 3 grids.
*/
static readonly OFFSET_THREE: number = 3;
/**
* Current component offset 6 grids.
*/
static readonly OFFSET_SIX: number = 6;
/**
* Current component offset 8 grids.
*/
static readonly OFFSET_EIGHT: number = 8;
/**
* Current component gutter 12.
*/
static readonly GUTTER_TWELVE: number = 12;
}
|
AST#export_declaration#Left export AST#class_declaration#Left class GridConstants AST#class_body#Left { /**
* Current component width: 4 grids.
*/ AST#property_declaration#Left static readonly COLUMN_FOUR : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 4 AST#expression#Right ; AST#property_declaration#Right /**
* Current component width: 8 grids.
*/ AST#property_declaration#Left static readonly COLUMN_EIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 8 AST#expression#Right ; AST#property_declaration#Right /**
* Current component width: 12 grids.
*/ AST#property_declaration#Left static readonly COLUMN_TWELVE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 12 AST#expression#Right ; AST#property_declaration#Right /**
* Current component width: 1 grids.
*/ AST#property_declaration#Left static readonly SPAN_ONE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1 AST#expression#Right ; AST#property_declaration#Right /**
* Current component width: 2 grids.
*/ AST#property_declaration#Left static readonly SPAN_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 /**
* Current component width: 3 grids.
*/ AST#property_declaration#Left static readonly SPAN_THREE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 3 AST#expression#Right ; AST#property_declaration#Right /**
* Current component width: 4 grids.
*/ AST#property_declaration#Left static readonly SPAN_FOUR : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 4 AST#expression#Right ; AST#property_declaration#Right /**
* Current component width: 8 grids.
*/ AST#property_declaration#Left static readonly SPAN_EIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 8 AST#expression#Right ; AST#property_declaration#Right /**
* Current component width: 12 grids.
*/ AST#property_declaration#Left static readonly SPAN_TWELVE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 12 AST#expression#Right ; AST#property_declaration#Right /**
* Current component offset 2 grids.
*/ AST#property_declaration#Left static readonly OFFSET_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 /**
* Current component offset 3 grids.
*/ AST#property_declaration#Left static readonly OFFSET_THREE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 3 AST#expression#Right ; AST#property_declaration#Right /**
* Current component offset 6 grids.
*/ AST#property_declaration#Left static readonly OFFSET_SIX : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 6 AST#expression#Right ; AST#property_declaration#Right /**
* Current component offset 8 grids.
*/ AST#property_declaration#Left static readonly OFFSET_EIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 8 AST#expression#Right ; AST#property_declaration#Right /**
* Current component gutter 12.
*/ AST#property_declaration#Left static readonly GUTTER_TWELVE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 12 AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class GridConstants {
static readonly COLUMN_FOUR: number = 4;
static readonly COLUMN_EIGHT: number = 8;
static readonly COLUMN_TWELVE: number = 12;
static readonly SPAN_ONE: number = 1;
static readonly SPAN_TWO: number = 2;
static readonly SPAN_THREE: number = 3;
static readonly SPAN_FOUR: number = 4;
static readonly SPAN_EIGHT: number = 8;
static readonly SPAN_TWELVE: number = 12;
static readonly OFFSET_TWO: number = 2;
static readonly OFFSET_THREE: number = 3;
static readonly OFFSET_SIX: number = 6;
static readonly OFFSET_EIGHT: number = 8;
static readonly GUTTER_TWELVE: number = 12;
}
|
https://github.com/wenfujing/honms-super-market.git/blob/0858abecd8be5db7b8dcf88dcd77b7c66d37517a/common/src/main/ets/constants/GridConstants.ets#L19-L89
|
e11a5b5c9cf2c35f6b34f43a9a62d2847f7a356d
|
github
|
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/secondarylinkage/src/main/ets/pages/DataType.ets
|
arkts
|
addData
|
改变单个数据。
@param {number} index - 索引值。
@param {CustomDataType} data - 修改后的值。
|
public addData(index: number, data: CustomDataType): void {
this.dataArray.splice(index, 0, data);
this.notifyDataAdd(index);
}
|
AST#method_declaration#Left public addData 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#Left data : AST#type_annotation#Left AST#primary_type#Left CustomDataType 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right , AST#expression#Left 0 AST#expression#Right , AST#expression#Left data 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#member_expression#Left AST#expression#Left this AST#expression#Right . notifyDataAdd 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#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
public addData(index: number, data: CustomDataType): void {
this.dataArray.splice(index, 0, data);
this.notifyDataAdd(index);
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/secondarylinkage/src/main/ets/pages/DataType.ets#L163-L166
|
5f96f5d9039532bce60ea4f49adb138e8fe627d4
|
gitee
|
azhuge233/ASFShortcut-HN.git
|
d1669c920c56317611b5b0375aa5315c1b91211b
|
entry/src/main/ets/common/utils/ASF.ets
|
arkts
|
send
|
发送正常指令
|
async send(command: string): Promise<http.HttpResponse> {
try {
const result = await this.sendRequest(this.address, this.asfPassword, command);
return result;
} catch (err) {
Logger.error(this.LOG_TAG, `send() 错误, ${JSON.stringify(err)}`);
throw err as Error;
}
}
|
AST#method_declaration#Left async send AST#parameter_list#Left ( AST#parameter#Left command : 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 AST#qualified_type#Left http . HttpResponse 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#try_statement#Left try 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#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . sendRequest 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 . address AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . asfPassword AST#member_expression#Right AST#expression#Right , AST#expression#Left command 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 result 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 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 this AST#expression#Right . LOG_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` send() 错误, 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 err 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#throw_statement#Left throw AST#expression#Left AST#as_expression#Left AST#expression#Left err AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ; AST#throw_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 send(command: string): Promise<http.HttpResponse> {
try {
const result = await this.sendRequest(this.address, this.asfPassword, command);
return result;
} catch (err) {
Logger.error(this.LOG_TAG, `send() 错误, ${JSON.stringify(err)}`);
throw err as Error;
}
}
|
https://github.com/azhuge233/ASFShortcut-HN.git/blob/d1669c920c56317611b5b0375aa5315c1b91211b/entry/src/main/ets/common/utils/ASF.ets#L30-L38
|
15cabb936d030bcddc15a27e98ca00bd8334d5b5
|
github
|
tomorrowKreswell/Ledger.git
|
1f2783ae70b8540d677af8a27f29db1b4089ea69
|
ledger/entry/src/main/ets/common/database/Rdb.ets
|
arkts
|
query
|
查询数据
@param predicates - 查询数据的条件
@param callback - 查询成功后的回调函数
|
query(predicates: relationalStore.RdbPredicates, callback: Function = () => {
}): void {
// 如果回调函数未提供,记录警告信息
if (!callback || typeof callback === 'undefined' || callback === undefined) {
Logger.info(CommonConstants.RDB_TAG, 'query() has no callback!');
return;
}
// 如果 rdbStore 存在,使用关系型存储库的 API 进行查询
if (this.rdbStore) {
this.rdbStore.query(predicates, this.columns, (err, resultSet) => {
if (err) {
Logger.error(CommonConstants.RDB_TAG, `query() failed, err: ${err}`);
return;
}
Logger.info(CommonConstants.RDB_TAG, 'query() finished.');
// 调用回调函数,并关闭结果集
callback(resultSet);
resultSet.close();
});
}
}
|
AST#method_declaration#Left query AST#parameter_list#Left ( AST#parameter#Left predicates : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left relationalStore . RdbPredicates AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left callback : AST#type_annotation#Left AST#primary_type#Left Function AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#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#binary_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left callback AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left callback AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left 'undefined' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || 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#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 Logger 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 CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left 'query() has no callback!' 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 // 如果 rdbStore 存在,使用关系型存储库的 API 进行查询 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rdbStore 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . rdbStore AST#member_expression#Right AST#expression#Right . query AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left predicates AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . columns AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right , AST#parameter#Left resultSet AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left err 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 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 CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` query() failed, err: AST#template_substitution#Left $ { AST#expression#Left err 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#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#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#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left 'query() finished.' 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 resultSet 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 resultSet AST#expression#Right . close 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#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
|
query(predicates: relationalStore.RdbPredicates, callback: Function = () => {
}): void {
if (!callback || typeof callback === 'undefined' || callback === undefined) {
Logger.info(CommonConstants.RDB_TAG, 'query() has no callback!');
return;
}
if (this.rdbStore) {
this.rdbStore.query(predicates, this.columns, (err, resultSet) => {
if (err) {
Logger.error(CommonConstants.RDB_TAG, `query() failed, err: ${err}`);
return;
}
Logger.info(CommonConstants.RDB_TAG, 'query() finished.');
callback(resultSet);
resultSet.close();
});
}
}
|
https://github.com/tomorrowKreswell/Ledger.git/blob/1f2783ae70b8540d677af8a27f29db1b4089ea69/ledger/entry/src/main/ets/common/database/Rdb.ets#L175-L197
|
7d5144fd2992edc7b1686ad559e795cf71f59268
|
github
|
Piagari/arkts_example.git
|
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
|
hmos_app-main/hmos_app-main/MoneyTrack-master/components/bill_data_processing/src/main/ets/utils/accountingdb/AccountingDB.ets
|
arkts
|
deleteTransactions
|
删除交易记录
|
public async deleteTransactions(transactionId: number) {
const condition: TablePredicateParams = {
field: TransactionTableFields.TRANSACTION_ID,
value: transactionId,
operator: DBOperator.EQUAL,
};
try {
await this.delete(AccountingDBConstants.TRANSACTION_TABLE_NAME, [
condition,
]);
promptAction.showToast({ message: '删除成功~' });
Logger.info(TAG, 'delete transaction success.');
} catch (err) {
promptAction.showToast({ message: '交易记录删除失败,请稍后重试~' });
Logger.error(
TAG,
'delete transaction failed. error:' + JSON.stringify(err),
);
}
}
|
AST#method_declaration#Left public async deleteTransactions AST#parameter_list#Left ( AST#parameter#Left transactionId : 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 const AST#variable_declarator#Left condition : AST#type_annotation#Left AST#primary_type#Left TablePredicateParams AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left field AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left TransactionTableFields AST#expression#Right . TRANSACTION_ID 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 transactionId AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left operator AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left DBOperator AST#expression#Right . EQUAL AST#member_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#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 this AST#expression#Right AST#await_expression#Right AST#expression#Right . delete AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AccountingDBConstants AST#expression#Right . TRANSACTION_TABLE_NAME AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left condition 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#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#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 'delete transaction success.' 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 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#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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'delete transaction failed. error:' 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#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
|
public async deleteTransactions(transactionId: number) {
const condition: TablePredicateParams = {
field: TransactionTableFields.TRANSACTION_ID,
value: transactionId,
operator: DBOperator.EQUAL,
};
try {
await this.delete(AccountingDBConstants.TRANSACTION_TABLE_NAME, [
condition,
]);
promptAction.showToast({ message: '删除成功~' });
Logger.info(TAG, 'delete transaction success.');
} catch (err) {
promptAction.showToast({ message: '交易记录删除失败,请稍后重试~' });
Logger.error(
TAG,
'delete transaction failed. error:' + JSON.stringify(err),
);
}
}
|
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/MoneyTrack-master/components/bill_data_processing/src/main/ets/utils/accountingdb/AccountingDB.ets#L120-L139
|
959a6856cde336e68a0780e1a033b7eaea992538
|
github
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
ef_rcp/example/Index.ets
|
arkts
|
@Author csx
@DateTime 2025/7/7 21:54
@TODO Index
|
export class Index {
}
|
AST#export_declaration#Left export AST#class_declaration#Left class Index AST#class_body#Left { } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class Index {
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_rcp/example/Index.ets#L22-L23
|
787e218605e35e94a32d88ef09e4b96cb9cae3f0
|
gitee
|
|
xt1314520/IbestKnowTeach
|
61f0a7a3d328ad5a52de8fd699b9e1e94de0203b
|
entry/src/main/ets/api/TargetInfoApi.type.ets
|
arkts
|
删除目标
|
export interface TargetInfoDeleteParam {
/**
* 目标内容id
*/
id: number
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface TargetInfoDeleteParam AST#object_type#Left { /**
* 目标内容id
*/ AST#type_member#Left id : 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 TargetInfoDeleteParam {
id: number
}
|
https://github.com/xt1314520/IbestKnowTeach/blob/61f0a7a3d328ad5a52de8fd699b9e1e94de0203b/entry/src/main/ets/api/TargetInfoApi.type.ets#L59-L65
|
a77a369b391460d5121ee8907a2bef862dbb9301
|
gitee
|
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/BasicFeature/Media/AVCodec/entry/src/main/ets/recorder/Recorder.ets
|
arkts
|
isVideoStabilizationModeSupported
|
查询是否支持视频防抖。HDR录像需要支持视频防抖。
|
function isVideoStabilizationModeSupported(session: camera.VideoSession, mode: camera.VideoStabilizationMode): boolean {
let isSupported: boolean = false;
try {
isSupported = session.isVideoStabilizationModeSupported(mode);
} catch (error) {
// 失败返回错误码error.code并处理
let err = error as BusinessError;
Logger.error(`The isVideoStabilizationModeSupported call failed. error code: ${err.code}`);
}
return isSupported;
}
|
AST#function_declaration#Left function isVideoStabilizationModeSupported AST#parameter_list#Left ( AST#parameter#Left session : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left camera . VideoSession AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left mode : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left camera . VideoStabilizationMode 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 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 isSupported : 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#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 isSupported = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left session AST#expression#Right . isVideoStabilizationModeSupported AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left mode 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 { // 失败返回错误码error.code并处理 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left err = 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 AST#template_literal#Left ` The isVideoStabilizationModeSupported call failed. error code: 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 ` 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 isSupported AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
|
function isVideoStabilizationModeSupported(session: camera.VideoSession, mode: camera.VideoStabilizationMode): boolean {
let isSupported: boolean = false;
try {
isSupported = session.isVideoStabilizationModeSupported(mode);
} catch (error) {
let err = error as BusinessError;
Logger.error(`The isVideoStabilizationModeSupported call failed. error code: ${err.code}`);
}
return isSupported;
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/BasicFeature/Media/AVCodec/entry/src/main/ets/recorder/Recorder.ets#L74-L84
|
9b9c6ce28d8e9cf2d41fd348b9f69a9031952715
|
gitee
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Distributed/HandleGameApplication/GameEtsOpenHarmony/entry/src/main/ets/MainAbility/pages/index.ets
|
arkts
|
movePlaneByHandle
|
收到手柄指令后移动飞机
|
movePlaneByHandle() {
this.planePosX += Math.cos((this.angle + 90) * (Math.PI / 180)) * 10
this.planePosY -= Math.sin((this.angle + 90) * (Math.PI / 180)) * 10
if (this.planePosX < 0) {
this.planePosX = 0
}
if (this.planePosY < 0) {
this.planePosY = 0
}
if (this.planePosX > this.screenWidth - this.planeSize) {
this.planePosX = this.screenWidth - this.planeSize
}
if (this.planePosY > this.screenHeight - 170) {
this.planePosY = this.screenHeight - 170
}
this.bulletPosX = this.planePosX + (this.planeSize - this.bulletWith) / 2
this.bulletPosY = this.planePosY - this.bulletHeight
}
|
AST#method_declaration#Left movePlaneByHandle 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 . planePosX 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 Math AST#expression#Right . cos 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . angle AST#member_expression#Right AST#expression#Right + AST#expression#Left 90 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . PI AST#member_expression#Right AST#expression#Right / AST#expression#Left 180 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#expression#Left 10 AST#expression#Right AST#binary_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 . planePosY 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 Math AST#expression#Right . sin 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . angle AST#member_expression#Right AST#expression#Right + AST#expression#Left 90 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . PI AST#member_expression#Right AST#expression#Right / AST#expression#Left 180 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#expression#Left 10 AST#expression#Right AST#binary_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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . planePosX 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . planePosX AST#member_expression#Right = AST#expression#Left 0 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#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 this AST#expression#Right . planePosY 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . planePosY AST#member_expression#Right = AST#expression#Left 0 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#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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . planePosX AST#member_expression#Right AST#expression#Right > AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . screenWidth AST#member_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . planeSize 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 . planePosX 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 . screenWidth AST#member_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . planeSize AST#member_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#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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . planePosY AST#member_expression#Right AST#expression#Right > AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . screenHeight AST#member_expression#Right AST#expression#Right - AST#expression#Left 170 AST#expression#Right AST#binary_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 . planePosY AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . screenHeight AST#member_expression#Right AST#expression#Right - AST#expression#Left 170 AST#expression#Right AST#binary_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 AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bulletPosX AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . planePosX AST#member_expression#Right AST#expression#Right + 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#member_expression#Left AST#expression#Left this AST#expression#Right . planeSize AST#member_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . bulletWith AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_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 . bulletPosY 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 . planePosY AST#member_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . bulletHeight AST#member_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
|
movePlaneByHandle() {
this.planePosX += Math.cos((this.angle + 90) * (Math.PI / 180)) * 10
this.planePosY -= Math.sin((this.angle + 90) * (Math.PI / 180)) * 10
if (this.planePosX < 0) {
this.planePosX = 0
}
if (this.planePosY < 0) {
this.planePosY = 0
}
if (this.planePosX > this.screenWidth - this.planeSize) {
this.planePosX = this.screenWidth - this.planeSize
}
if (this.planePosY > this.screenHeight - 170) {
this.planePosY = this.screenHeight - 170
}
this.bulletPosX = this.planePosX + (this.planeSize - this.bulletWith) / 2
this.bulletPosY = this.planePosY - this.bulletHeight
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Distributed/HandleGameApplication/GameEtsOpenHarmony/entry/src/main/ets/MainAbility/pages/index.ets#L337-L357
|
e9c565ca0e63b48ebab8ed8b87c45bbc17566b7f
|
gitee
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/Solutions/Social/PublishMultimediaUpdate/publishmultimediaupdate/src/main/ets/components/OneMoment.ets
|
arkts
|
OneMoment
|
列表子组件
TODO: 性能知识点:@Reusable复用组件优化,详情请见:https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/quick-start/arkts-reusable.md
|
@Reusable
@Component
export struct OneMoment {
@Prop moment: FriendMoment;
controller: VideoController = new VideoController()
aboutToReuse(params: Record<string, Object>): void {
this.moment = params.moment as FriendMoment;
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Reusable AST#decorator#Right AST#decorator#Left @ Component AST#decorator#Right export struct OneMoment AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right moment : AST#type_annotation#Left AST#primary_type#Left FriendMoment AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left controller : AST#type_annotation#Left AST#primary_type#Left VideoController AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left VideoController 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#ERROR#Left aboutToReuse AST#ERROR#Right AST#argument_list#Left ( AST#ERROR#Left params : 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 ) : void 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 . moment AST#member_expression#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . moment AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left FriendMoment AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Reusable
@Component
export struct OneMoment {
@Prop moment: FriendMoment;
controller: VideoController = new VideoController()
aboutToReuse(params: Record<string, Object>): void {
this.moment = params.moment as FriendMoment;
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Solutions/Social/PublishMultimediaUpdate/publishmultimediaupdate/src/main/ets/components/OneMoment.ets#L25-L33
|
c88b802a0a0ea4ad7e606cdfc77cc658fbd493e6
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/common/types/SettingsTypes.ets
|
arkts
|
自动备份配置接口
|
export interface AutoBackupConfig {
enabled: boolean;
frequency: BackupFrequency;
location: BackupLocation;
maxBackups: number;
includeImages: boolean;
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface AutoBackupConfig AST#object_type#Left { AST#type_member#Left enabled : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left frequency : AST#type_annotation#Left AST#primary_type#Left BackupFrequency AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left location : AST#type_annotation#Left AST#primary_type#Left BackupLocation AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left maxBackups : 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 includeImages : AST#type_annotation#Left AST#primary_type#Left boolean 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 AutoBackupConfig {
enabled: boolean;
frequency: BackupFrequency;
location: BackupLocation;
maxBackups: number;
includeImages: boolean;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/SettingsTypes.ets#L90-L96
|
b77e735e0ac160933d3f76aa0990b1a919392593
|
github
|
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
WaterFlowSample/entry/src/main/ets/model/StickyWaterFlowDataSource.ets
|
arkts
|
unregisterDataChangeListener
|
Register a controller that changes data.
@param {DataChangeListener} listener Data change listener
|
unregisterDataChangeListener(listener: DataChangeListener): void {
let pos: number = this.listeners.indexOf(listener);
if (pos >= 0) {
this.listeners.splice(pos, 1);
}
}
|
AST#method_declaration#Left unregisterDataChangeListener AST#parameter_list#Left ( AST#parameter#Left listener : AST#type_annotation#Left AST#primary_type#Left DataChangeListener 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 pos : 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#member_expression#Left AST#expression#Left this AST#expression#Right . listeners AST#member_expression#Right AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left listener 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 pos 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 . listeners AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left pos 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#block_statement#Right AST#method_declaration#Right
|
unregisterDataChangeListener(listener: DataChangeListener): void {
let pos: number = this.listeners.indexOf(listener);
if (pos >= 0) {
this.listeners.splice(pos, 1);
}
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/WaterFlowSample/entry/src/main/ets/model/StickyWaterFlowDataSource.ets#L74-L79
|
293e2d73693f53d3c58776ad68c49a24bc7c4a7d
|
gitee
|
awa_Liny/LinysBrowser_NEXT
|
a5cd96a9aa8114cae4972937f94a8967e55d4a10
|
home/src/main/ets/processes/extension_actions.ets
|
arkts
|
Reads the locale JSON object of extension.
@param path The path of the extension root directory.
@param locale The locale code, like 'en'.
@returns The JSON object or undefined, if not found.
|
export function locale_messages_of_extension(path: string | undefined, locale: string) {
let messages: object | undefined;
if (!path) {
return undefined;
}
let locale_text = sandbox_read_text_sync(`${path}/_locales/${locale}/messages.json`);
if (locale_text == 'undefined') {
// Locale not found
return undefined;
}
messages = JSON.parse(locale_text);
return messages;
}
|
AST#export_declaration#Left export AST#function_declaration#Left function locale_messages_of_extension AST#parameter_list#Left ( AST#parameter#Left path : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left locale : 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 messages : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left object AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left path AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left undefined 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 locale_text = AST#expression#Left AST#call_expression#Left AST#expression#Left sandbox_read_text_sync AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left path AST#expression#Right } AST#template_substitution#Right /_locales/ AST#template_substitution#Left $ { AST#expression#Left locale AST#expression#Right } AST#template_substitution#Right /messages.json ` 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left locale_text AST#expression#Right == AST#expression#Left 'undefined' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // Locale not found AST#statement#Left AST#return_statement#Left return AST#expression#Left undefined 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left messages = 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 locale_text 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 messages AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export function locale_messages_of_extension(path: string | undefined, locale: string) {
let messages: object | undefined;
if (!path) {
return undefined;
}
let locale_text = sandbox_read_text_sync(`${path}/_locales/${locale}/messages.json`);
if (locale_text == 'undefined') {
return undefined;
}
messages = JSON.parse(locale_text);
return messages;
}
|
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/processes/extension_actions.ets#L271-L283
|
6598e31df9b13e58d81c93031e9bd89c9058702f
|
gitee
|
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/shortcut/ShortcutManager.ets
|
arkts
|
updateContactShortcut
|
更新特定联系人的快捷方式
|
async updateContactShortcut(contact: Contact): Promise<void> {
try {
// 如果今天是该联系人的生日,创建特定的快捷方式
if (this.isToday(contact.birthday.date)) {
const shortcut: ShortcutInfo = {
id: `greeting_${contact.id}`,
shortLabel: `祝福${contact.name}`,
longLabel: `为${contact.name}发送生日祝福`,
iconId: $r('app.media.ic_cake'),
wants: [{
bundleName: 'com.harmonyos.birthdayreminder',
abilityName: 'EntryAbility',
parameters: {
action: 'quickGreeting',
contactId: contact.id,
contactName: contact.name
}
}]
};
await shortcutManager.addShortcut(shortcut);
// 记录配置
const config: ShortcutConfig = {
id: shortcut.id,
type: ShortcutType.QUICK_GREETING,
label: shortcut.shortLabel || '',
description: shortcut.longLabel || '',
icon: 'ic_cake',
targetPage: '',
params: { contactId: contact.id },
isStatic: false,
priority: 1
};
this.shortcuts.set(shortcut.id, config);
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP,
`Updated shortcut for contact: ${contact.name}`);
}
} catch (error) {
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP,
`Failed to update contact shortcut: ${error}`);
}
}
|
AST#method_declaration#Left async updateContactShortcut 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 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#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isToday 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 contact AST#expression#Right . birthday AST#member_expression#Right AST#expression#Right . date AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left shortcut : AST#type_annotation#Left AST#primary_type#Left ShortcutInfo AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left id AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` greeting_ AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left contact AST#expression#Right . id 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 shortLabel 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 contact AST#expression#Right . name 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 longLabel 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 contact AST#expression#Right . name 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 iconId AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_cake' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left wants AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bundleName AST#property_name#Right : AST#expression#Left 'com.harmonyos.birthdayreminder' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left abilityName AST#property_name#Right : AST#expression#Left 'EntryAbility' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left parameters AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left action AST#property_name#Right : AST#expression#Left 'quickGreeting' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left contactId AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left contact AST#expression#Right . id AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left contactName AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left contact AST#expression#Right . name 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#array_literal#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 AST#await_expression#Left await AST#expression#Left shortcutManager AST#expression#Right AST#await_expression#Right AST#expression#Right . addShortcut AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left shortcut 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 config : AST#type_annotation#Left AST#primary_type#Left ShortcutConfig AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left id AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left shortcut AST#expression#Right . id AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left ShortcutType AST#expression#Right . QUICK_GREETING AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left label AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left shortcut AST#expression#Right . shortLabel 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 description AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left shortcut AST#expression#Right . longLabel 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 icon AST#property_name#Right : AST#expression#Left 'ic_cake' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left targetPage AST#property_name#Right : AST#expression#Left '' 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 contactId AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left contact AST#expression#Right . id AST#member_expression#Right 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 isStatic 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 priority AST#property_name#Right : AST#expression#Left 1 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . shortcuts AST#member_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left shortcut AST#expression#Right . id AST#member_expression#Right AST#expression#Right , AST#expression#Left config 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 ` Updated shortcut for contact: 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#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 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 update contact shortcut: 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
|
async updateContactShortcut(contact: Contact): Promise<void> {
try {
if (this.isToday(contact.birthday.date)) {
const shortcut: ShortcutInfo = {
id: `greeting_${contact.id}`,
shortLabel: `祝福${contact.name}`,
longLabel: `为${contact.name}发送生日祝福`,
iconId: $r('app.media.ic_cake'),
wants: [{
bundleName: 'com.harmonyos.birthdayreminder',
abilityName: 'EntryAbility',
parameters: {
action: 'quickGreeting',
contactId: contact.id,
contactName: contact.name
}
}]
};
await shortcutManager.addShortcut(shortcut);
const config: ShortcutConfig = {
id: shortcut.id,
type: ShortcutType.QUICK_GREETING,
label: shortcut.shortLabel || '',
description: shortcut.longLabel || '',
icon: 'ic_cake',
targetPage: '',
params: { contactId: contact.id },
isStatic: false,
priority: 1
};
this.shortcuts.set(shortcut.id, config);
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP,
`Updated shortcut for contact: ${contact.name}`);
}
} catch (error) {
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP,
`Failed to update contact shortcut: ${error}`);
}
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/shortcut/ShortcutManager.ets#L204-L247
|
19140a76a7c33e2d28c8784a18d60288cde38af7
|
github
|
azhuge233/Wake-HarmonyOS.git
|
68c4e961f9cf5fab8699af99313dd5854ea313a1
|
entry/src/main/ets/common/utils/CommonUtils.ets
|
arkts
|
returnFromSubPage
|
从 NavDestination 由 pop() 返回时 显示回调 popInfo
|
public returnFromSubPage(popInfo: PopInfo): void {
Logger.debug(this.LOG_TAG,
`从 [${popInfo.info.name}] 页面返回, 携带参数: ${JSON.stringify(popInfo.result)}`);
}
|
AST#method_declaration#Left public returnFromSubPage AST#parameter_list#Left ( AST#parameter#Left popInfo : AST#type_annotation#Left AST#primary_type#Left PopInfo 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . debug 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 . LOG_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` 从 [ AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left popInfo AST#expression#Right . info AST#member_expression#Right AST#expression#Right . name AST#member_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 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 popInfo AST#expression#Right . result 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#builder_function_body#Right AST#method_declaration#Right
|
public returnFromSubPage(popInfo: PopInfo): void {
Logger.debug(this.LOG_TAG,
`从 [${popInfo.info.name}] 页面返回, 携带参数: ${JSON.stringify(popInfo.result)}`);
}
|
https://github.com/azhuge233/Wake-HarmonyOS.git/blob/68c4e961f9cf5fab8699af99313dd5854ea313a1/entry/src/main/ets/common/utils/CommonUtils.ets#L45-L48
|
5e6ece03c5ee7be4c2dc84c528dc24b6290331c5
|
github
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/SystemFeature/ResourceAllocation/ApplicationThemeSwitch/entry/src/main/ets/models/HomeModel.ets
|
arkts
|
Copyright (c) 2022 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, 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 class TabTitleModel {
constructor(public id: number, public uri: Resource, public selectedUri: Resource, public title: Resource) {
this.id = id
this.uri = uri
this.selectedUri = selectedUri
this.title = title
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class TabTitleModel AST#class_body#Left { AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left public AST#ERROR#Left id AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left public AST#ERROR#Left uri AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left public AST#ERROR#Left selectedUri AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left public AST#ERROR#Left title AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left Resource 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 . id AST#member_expression#Right = AST#expression#Left id 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 . uri AST#member_expression#Right = AST#expression#Left uri 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 . selectedUri AST#member_expression#Right = AST#expression#Left selectedUri 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 . title AST#member_expression#Right = AST#expression#Left title AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class TabTitleModel {
constructor(public id: number, public uri: Resource, public selectedUri: Resource, public title: Resource) {
this.id = id
this.uri = uri
this.selectedUri = selectedUri
this.title = title
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/ResourceAllocation/ApplicationThemeSwitch/entry/src/main/ets/models/HomeModel.ets#L16-L23
|
0abb3113c2e12a43b5589a474c6a648f00bb6d69
|
gitee
|
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
VideoProcessBaseWeb/entry/src/main/ets/pages/Index.ets
|
arkts
|
aboutToAppear
|
[EndExclude index]
|
aboutToAppear(): void {
window.getLastWindow(this.context).then((windowClass) => this.windowClass = windowClass);
// [StartExclude index]
this.manager.registerController(Constants.INDEX_WEB_CONTROLLER, this.webController);
AppStorage.setOrCreate<ComponentContent<Object>>('contentNode', this.contentNode);
hilog.info(0x000, Constants.TAG, 'language: ' + this.language);
// [EndExclude index]
}
|
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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . getLastWindow 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 . context AST#member_expression#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 windowClass AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . windowClass AST#member_expression#Right = AST#expression#Left windowClass AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right // [StartExclude index] 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 . manager AST#member_expression#Right AST#expression#Right . registerController AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . INDEX_WEB_CONTROLLER AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . webController 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left ComponentContent AST#type_arguments#Left < 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#type_arguments#Right AST#argument_list#Left ( AST#expression#Left 'contentNode' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . contentNode 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#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 0x000 AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'language: ' AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . language AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right // [EndExclude index] } AST#builder_function_body#Right AST#method_declaration#Right
|
aboutToAppear(): void {
window.getLastWindow(this.context).then((windowClass) => this.windowClass = windowClass);
this.manager.registerController(Constants.INDEX_WEB_CONTROLLER, this.webController);
AppStorage.setOrCreate<ComponentContent<Object>>('contentNode', this.contentNode);
hilog.info(0x000, Constants.TAG, 'language: ' + this.language);
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/VideoProcessBaseWeb/entry/src/main/ets/pages/Index.ets#L107-L114
|
6c5d9717a1a7485c34467d4785e63b06625543d2
|
gitee
|
ali5669/ArkTSShopping.git
|
7065d61468d80c143788532337c499eb9eaa5ffd
|
entry/src/main/ets/viewmodel/ItemModel.ets
|
arkts
|
不同的样式
|
export class ItemStyle {
title: string = ''
price: number = 0
image?: ResourceStr = ''
}
|
AST#export_declaration#Left export AST#class_declaration#Left class ItemStyle AST#class_body#Left { AST#property_declaration#Left title : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#conditional_expression#Left AST#expression#Left '' AST#expression#Right AST#ERROR#Left price : number = 0 image AST#ERROR#Right ? AST#expression#Left AST#expression#Right : AST#expression#Left AST#assignment_expression#Left ResourceStr = AST#expression#Left '' AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class ItemStyle {
title: string = ''
price: number = 0
image?: ResourceStr = ''
}
|
https://github.com/ali5669/ArkTSShopping.git/blob/7065d61468d80c143788532337c499eb9eaa5ffd/entry/src/main/ets/viewmodel/ItemModel.ets#L2-L6
|
a9f528c7accfa1350174aea4c03c17dbd87c01c0
|
github
|
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Security/AccessPermission/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%';
/**
* X-axis coordinate of the dialog box.
*/
static readonly DIALOG_OFFSET_X: number = 0;
/**
* Y-axis coordinate of the dialog box.
*/
static readonly DIALOG_OFFSET_Y: number = -20;
/**
* Image height on the main page.
*/
static readonly HOME_IMAGE_HEIGHT: string = '34.5%';
/**
* Main Page Button Width.
*/
static readonly HOME_BUTTON_WIDTH: string = '86.7%';
/**
* Width of the text on the device list page.
*/
static readonly DEVICE_TEXT_WIDTH: string = '80%';
/**
* Width of the text on the device list page.
*/
static readonly DEVICE_IMAGE_WIDTH: string = '6.7%';
/**
* Radio Button Name.
*/
static readonly RADIO_NAME: string = 'radio';
/**
* Radio Button Group Name.
*/
static readonly RADIO_BUTTON_GROUP_NAME: string = 'radioGroup';
/**
* Left margin of the button.
*/
static readonly RADIO_LEFT: string = '5.3%';
/**
* Row width.
*/
static readonly COLUMN_WIDTH: string = '80%';
/**
* Radio Column width.
*/
static readonly RADIO_COLUMN_WIDTH: string = '20%';
/**
* Text Width.
*/
static readonly PERMISSION_TEXT_WIDTH: string = '80%';
/**
* Random parameter 1.
*/
static readonly RANDOM_ONE: number = 10000;
/**
* Random parameter 2.
*/
static readonly RANDOM_TWO: number = 1000;
/**
* High frequency.
*/
static readonly FREQ: number = 2;
/**
* Active mode.
*/
static readonly MODE: number = 0xAA;
/**
* Permissions.
*/
static readonly PERMISSION: Permissions = 'ohos.permission.DISTRIBUTED_DATASYNC';
/**
* Device discovery flag.
*/
static readonly DEVICE_FOUND: string = 'deviceFound';
/**
* Device ID length.
*/
static readonly DEVICE_ID_LENGTH: number = 16;
/**
* Device ID ellipsis.
*/
static readonly DEVICE_ID_ELLIPSIS: string = '...';
/**
* Minimum height of the device list.
*/
static readonly LIST_MIN_HEIGHT: string = '10%';
/**
* Maximum height of the device list.
*/
static readonly LIST_MAX_HEIGHT: string = '50%';
}
|
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 /**
* X-axis coordinate of the dialog box.
*/ AST#property_declaration#Left static readonly DIALOG_OFFSET_X : 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 /**
* Y-axis coordinate of the dialog box.
*/ AST#property_declaration#Left static readonly DIALOG_OFFSET_Y : 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 20 AST#expression#Right AST#unary_expression#Right AST#expression#Right ; AST#property_declaration#Right /**
* Image height on the main page.
*/ AST#property_declaration#Left static readonly HOME_IMAGE_HEIGHT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '34.5%' AST#expression#Right ; AST#property_declaration#Right /**
* Main Page Button Width.
*/ AST#property_declaration#Left static readonly HOME_BUTTON_WIDTH : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '86.7%' AST#expression#Right ; AST#property_declaration#Right /**
* Width of the text on the device list page.
*/ AST#property_declaration#Left static readonly DEVICE_TEXT_WIDTH : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '80%' AST#expression#Right ; AST#property_declaration#Right /**
* Width of the text on the device list page.
*/ AST#property_declaration#Left static readonly DEVICE_IMAGE_WIDTH : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '6.7%' AST#expression#Right ; AST#property_declaration#Right /**
* Radio Button Name.
*/ AST#property_declaration#Left static readonly RADIO_NAME : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'radio' AST#expression#Right ; AST#property_declaration#Right /**
* Radio Button Group Name.
*/ AST#property_declaration#Left static readonly RADIO_BUTTON_GROUP_NAME : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'radioGroup' AST#expression#Right ; AST#property_declaration#Right /**
* Left margin of the button.
*/ AST#property_declaration#Left static readonly RADIO_LEFT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '5.3%' AST#expression#Right ; AST#property_declaration#Right /**
* Row width.
*/ AST#property_declaration#Left static readonly COLUMN_WIDTH : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '80%' AST#expression#Right ; AST#property_declaration#Right /**
* Radio Column width.
*/ AST#property_declaration#Left static readonly RADIO_COLUMN_WIDTH : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '20%' AST#expression#Right ; AST#property_declaration#Right /**
* Text Width.
*/ AST#property_declaration#Left static readonly PERMISSION_TEXT_WIDTH : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '80%' AST#expression#Right ; AST#property_declaration#Right /**
* Random parameter 1.
*/ AST#property_declaration#Left static readonly RANDOM_ONE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 10000 AST#expression#Right ; AST#property_declaration#Right /**
* Random parameter 2.
*/ AST#property_declaration#Left static readonly RANDOM_TWO : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1000 AST#expression#Right ; AST#property_declaration#Right /**
* High frequency.
*/ AST#property_declaration#Left static readonly FREQ : 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 /**
* Active mode.
*/ AST#property_declaration#Left static readonly MODE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0xAA AST#expression#Right ; AST#property_declaration#Right /**
* Permissions.
*/ AST#property_declaration#Left static readonly PERMISSION : AST#type_annotation#Left AST#primary_type#Left Permissions AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'ohos.permission.DISTRIBUTED_DATASYNC' AST#expression#Right ; AST#property_declaration#Right /**
* Device discovery flag.
*/ AST#property_declaration#Left static readonly DEVICE_FOUND : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'deviceFound' AST#expression#Right ; AST#property_declaration#Right /**
* Device ID length.
*/ AST#property_declaration#Left static readonly DEVICE_ID_LENGTH : 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 /**
* Device ID ellipsis.
*/ AST#property_declaration#Left static readonly DEVICE_ID_ELLIPSIS : 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 /**
* Minimum height of the device list.
*/ AST#property_declaration#Left static readonly LIST_MIN_HEIGHT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '10%' AST#expression#Right ; AST#property_declaration#Right /**
* Maximum height of the device list.
*/ AST#property_declaration#Left static readonly LIST_MAX_HEIGHT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '50%' 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 DIALOG_OFFSET_X: number = 0;
static readonly DIALOG_OFFSET_Y: number = -20;
static readonly HOME_IMAGE_HEIGHT: string = '34.5%';
static readonly HOME_BUTTON_WIDTH: string = '86.7%';
static readonly DEVICE_TEXT_WIDTH: string = '80%';
static readonly DEVICE_IMAGE_WIDTH: string = '6.7%';
static readonly RADIO_NAME: string = 'radio';
static readonly RADIO_BUTTON_GROUP_NAME: string = 'radioGroup';
static readonly RADIO_LEFT: string = '5.3%';
static readonly COLUMN_WIDTH: string = '80%';
static readonly RADIO_COLUMN_WIDTH: string = '20%';
static readonly PERMISSION_TEXT_WIDTH: string = '80%';
static readonly RANDOM_ONE: number = 10000;
static readonly RANDOM_TWO: number = 1000;
static readonly FREQ: number = 2;
static readonly MODE: number = 0xAA;
static readonly PERMISSION: Permissions = 'ohos.permission.DISTRIBUTED_DATASYNC';
static readonly DEVICE_FOUND: string = 'deviceFound';
static readonly DEVICE_ID_LENGTH: number = 16;
static readonly DEVICE_ID_ELLIPSIS: string = '...';
static readonly LIST_MIN_HEIGHT: string = '10%';
static readonly LIST_MAX_HEIGHT: string = '50%';
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Security/AccessPermission/entry/src/main/ets/common/constants/CommonConstants.ets#L27-L143
|
b99ae778df15ab440892a2e1f5929cf584e08d11
|
gitee
|
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/encapsulationdialog/src/main/ets/example/dto/MockData.ets
|
arkts
|
Mock数据
|
export const MEMO_DATA: FileItem[] = [
new FileItem('test1.png'),
new FileItem('test2.ppt'),
new FileItem('test3.doc'),
new FileItem('test4.xls'),
new FileItem('test5.xls'),
new FileItem('test6.xls'),
new FileItem('test7.doc'),
new FileItem('test8.ppt'),
new FileItem('test9.doc'),
new FileItem('test5.png')
];
|
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left MEMO_DATA : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left FileItem [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left FileItem AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'test1.png' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left FileItem AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'test2.ppt' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left FileItem AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'test3.doc' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left FileItem AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'test4.xls' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left FileItem AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'test5.xls' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left FileItem AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'test6.xls' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left FileItem AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'test7.doc' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left FileItem AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'test8.ppt' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left FileItem AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'test9.doc' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left FileItem AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'test5.png' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
|
export const MEMO_DATA: FileItem[] = [
new FileItem('test1.png'),
new FileItem('test2.ppt'),
new FileItem('test3.doc'),
new FileItem('test4.xls'),
new FileItem('test5.xls'),
new FileItem('test6.xls'),
new FileItem('test7.doc'),
new FileItem('test8.ppt'),
new FileItem('test9.doc'),
new FileItem('test5.png')
];
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/encapsulationdialog/src/main/ets/example/dto/MockData.ets#L19-L30
|
95a226b5d73c2ecce9065b0c55eb43e414ee2b1c
|
gitee
|
|
openharmony/arkui_ace_engine
|
30c7d1ee12fbedf0fabece54291d75897e2ad44f
|
examples/Select/entry/src/main/ets/pages/components/slider/sliderNormal.ets
|
arkts
|
SliderNormalBuilder
|
Copyright (c) 2025 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.
|
@Builder
export function SliderNormalBuilder(name: string, param: Object) {
SliderNormalExample()
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function SliderNormalBuilder AST#parameter_list#Left ( AST#parameter#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left param : AST#type_annotation#Left AST#primary_type#Left Object 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 SliderNormalExample ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#decorated_export_declaration#Right
|
@Builder
export function SliderNormalBuilder(name: string, param: Object) {
SliderNormalExample()
}
|
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/examples/Select/entry/src/main/ets/pages/components/slider/sliderNormal.ets#L16-L19
|
61a388d67f540436744cf1043b354c320ed1be8f
|
gitee
|
Piagari/arkts_example.git
|
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
|
hmos_app-main/hmos_app-main/MusicHome-master/features/musicComment/src/main/ets/constants/CommonConstants.ets
|
arkts
|
Common constants for all features.
|
export class CommonConstants {
/**
* Spacing between list items.
*/
static readonly LIST_SPACE: string = '10vp';
/**
* A maximum of 4 reviews can be displayed under sm and md device types.
*/
static readonly LIST_COUNT: number = 4;
/**
* Prefix of the reply message.
*/
static readonly NICKNAME_PREV: string = '@';
/**
* Suffix of the reply message.
*/
static readonly NICKNAME_SUFFIX: string = ':';
}
|
AST#export_declaration#Left export AST#class_declaration#Left class CommonConstants AST#class_body#Left { /**
* Spacing between list items.
*/ AST#property_declaration#Left static readonly LIST_SPACE : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '10vp' AST#expression#Right ; AST#property_declaration#Right /**
* A maximum of 4 reviews can be displayed under sm and md device types.
*/ AST#property_declaration#Left static readonly LIST_COUNT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 4 AST#expression#Right ; AST#property_declaration#Right /**
* Prefix of the reply message.
*/ AST#property_declaration#Left static readonly NICKNAME_PREV : 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 /**
* Suffix of the reply message.
*/ AST#property_declaration#Left static readonly NICKNAME_SUFFIX : 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 CommonConstants {
static readonly LIST_SPACE: string = '10vp';
static readonly LIST_COUNT: number = 4;
static readonly NICKNAME_PREV: string = '@';
static readonly NICKNAME_SUFFIX: string = ':';
}
|
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/MusicHome-master/features/musicComment/src/main/ets/constants/CommonConstants.ets#L19-L39
|
dd9acc97d43b773733827b8ed84926fa52899b2e
|
github
|
|
openharmony/interface_sdk-js
|
c349adc73e2ec1f61f6fca489b5af059e3ed6999
|
api/@ohos.file.PhotoPickerComponent.d.ets
|
arkts
|
Enumerates the aspect ratios of the grid item display, including 1:1 and the original image's aspect ratio.
@enum { number } Grid item display aspect ratio.
@syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
@atomicservice
@since 20
|
export declare enum ItemDisplayRatio {
/**
* Square ratio item
*
* @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
* @atomicservice
* @since 20
*/
SQUARE_RATIO = 0,
/**
* original size ratio item
*
* @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
* @atomicservice
* @since 20
*/
ORIGINAL_SIZE_RATIO = 1
}
|
AST#export_declaration#Left export AST#ERROR#Left declare AST#ERROR#Right AST#enum_declaration#Left enum ItemDisplayRatio AST#enum_body#Left { /**
* Square ratio item
*
* @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
* @atomicservice
* @since 20
*/ AST#enum_member#Left SQUARE_RATIO = AST#expression#Left 0 AST#expression#Right AST#enum_member#Right , /**
* original size ratio item
*
* @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
* @atomicservice
* @since 20
*/ AST#enum_member#Left ORIGINAL_SIZE_RATIO = AST#expression#Left 1 AST#expression#Right AST#enum_member#Right } AST#enum_body#Right AST#enum_declaration#Right AST#export_declaration#Right
|
export declare enum ItemDisplayRatio {
SQUARE_RATIO = 0,
ORIGINAL_SIZE_RATIO = 1
}
|
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.file.PhotoPickerComponent.d.ets#L1270-L1288
|
5ee4d8292538ab67f7f909493a5f4dd5ebe62088
|
gitee
|
|
Glace-Dev/Harmony_Projects.git
|
845cef3c5fdf5d049c942fe62cbf083c2c78e84a
|
basis/entry/src/main/ets/views/task/TaskItem.ets
|
arkts
|
finishedTask
|
任务完成样式
|
@Extend(Text) function finishedTask(){
.decoration({type:TextDecorationType.LineThrough})
.fontColor('#B1B2B1')
}
|
AST#decorated_function_declaration#Left AST#decorator#Left @ Extend ( AST#expression#Left Text AST#expression#Right ) AST#decorator#Right function finishedTask AST#parameter_list#Left ( ) AST#parameter_list#Right AST#extend_function_body#Left { AST#modifier_chain_expression#Left . decoration ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left TextDecorationType AST#expression#Right . LineThrough AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#B1B2B1' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right } AST#extend_function_body#Right AST#decorated_function_declaration#Right
|
@Extend(Text) function finishedTask(){
.decoration({type:TextDecorationType.LineThrough})
.fontColor('#B1B2B1')
}
|
https://github.com/Glace-Dev/Harmony_Projects.git/blob/845cef3c5fdf5d049c942fe62cbf083c2c78e84a/basis/entry/src/main/ets/views/task/TaskItem.ets#L37-L40
|
fd4a53ac14d9f578fc47124a94357fa9e5cab290
|
github
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/ai/GreetingGenerationService.ets
|
arkts
|
simulateMultipleGeneration
|
模拟批量生成
|
private async simulateMultipleGeneration(
prompt: string,
params: GreetingGenerateParams,
count: number
): Promise<string[]> {
await this.delay(1500 + Math.random() * 1000);
const contact = params.contact;
const style = params.style;
const occasion = params.occasion;
const templates = this.getGreetingTemplates(style, occasion);
const results: string[] = [];
for (let i = 0; i < Math.min(count, templates.length); i++) {
results.push(this.personalizeTemplate(templates[i], contact));
}
return results;
}
|
AST#method_declaration#Left private async simulateMultipleGeneration AST#parameter_list#Left ( AST#parameter#Left prompt : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left GreetingGenerateParams AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left count : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#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#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 . delay 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 AST#binary_expression#Left AST#expression#Left 1500 AST#expression#Right + AST#expression#Left Math AST#expression#Right AST#binary_expression#Right 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 1000 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 const AST#variable_declarator#Left contact = AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . contact 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 style = AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . style 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 occasion = AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . occasion 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 templates = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getGreetingTemplates AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left style AST#expression#Right , AST#expression#Left occasion 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 results : 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#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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left Math AST#expression#Right AST#binary_expression#Right AST#expression#Right . min AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left count AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left templates AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_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 results AST#expression#Right . push 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 this AST#expression#Right . personalizeTemplate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left templates AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right , AST#expression#Left contact 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#return_statement#Left return AST#expression#Left results AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private async simulateMultipleGeneration(
prompt: string,
params: GreetingGenerateParams,
count: number
): Promise<string[]> {
await this.delay(1500 + Math.random() * 1000);
const contact = params.contact;
const style = params.style;
const occasion = params.occasion;
const templates = this.getGreetingTemplates(style, occasion);
const results: string[] = [];
for (let i = 0; i < Math.min(count, templates.length); i++) {
results.push(this.personalizeTemplate(templates[i], contact));
}
return results;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/ai/GreetingGenerationService.ets#L374-L392
|
dfe27efc864ba4bb8973f5a7505c917a70f360d8
|
github
|
BohanSu/LumosAgent-HarmonyOS.git
|
9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76
|
entry/src/main/ets/viewmodel/MainViewModel.ets
|
arkts
|
clearChat
|
Clear chat history
|
clearChat(): void {
this.chatMessages = [];
this.agentService.clearHistory();
this.addChatMessage('Chat cleared. How can I help you?', false);
}
|
AST#method_declaration#Left clearChat 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 . chatMessages AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#assignment_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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . agentService AST#member_expression#Right AST#expression#Right . clearHistory 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 . addChatMessage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Chat cleared. How can I help you?' 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#builder_function_body#Right AST#method_declaration#Right
|
clearChat(): void {
this.chatMessages = [];
this.agentService.clearHistory();
this.addChatMessage('Chat cleared. How can I help you?', false);
}
|
https://github.com/BohanSu/LumosAgent-HarmonyOS.git/blob/9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76/entry/src/main/ets/viewmodel/MainViewModel.ets#L520-L524
|
a486be83e6fc164111f1239898f739f1f28d9c8d
|
github
|
liuchao0739/arkTS_universal_starter.git
|
0ca845f5ae0e78db439dc09f712d100c0dd46ed3
|
entry/src/main/ets/utils/EncryptUtils.ets
|
arkts
|
generateRandomString
|
生成随机字符串
|
static generateRandomString(length: number = 32): string {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let result = '';
for (let i = 0; i < length; i++) {
result += chars.charAt(Math.floor(Math.random() * chars.length));
}
return result;
}
|
AST#method_declaration#Left static generateRandomString AST#parameter_list#Left ( AST#parameter#Left length : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 32 AST#expression#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 chars = AST#expression#Left 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' 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#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#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left length 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left result += AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left chars AST#expression#Right . charAt 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 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#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 chars AST#expression#Right AST#binary_expression#Right AST#expression#Right . length 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#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#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 generateRandomString(length: number = 32): string {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let result = '';
for (let i = 0; i < length; i++) {
result += chars.charAt(Math.floor(Math.random() * chars.length));
}
return result;
}
|
https://github.com/liuchao0739/arkTS_universal_starter.git/blob/0ca845f5ae0e78db439dc09f712d100c0dd46ed3/entry/src/main/ets/utils/EncryptUtils.ets#L57-L64
|
9e62e9381eb8898e01798d4847c5ecd7f90767fa
|
github
|
2763981847/Clock-Alarm.git
|
8949bedddb7d011021848196735f30ffe2bd1daf
|
entry/src/main/ets/pages/DetailPage.ets
|
arkts
|
DetailPage
|
DetailPage 页面组件。
|
@Entry
@Component
export default struct DetailPage {
// 监听 alarmItem 属性变化,提供给子组件使用
@Watch('onAlarmItemChange') @Provide(DetailConstants.DEFAULT_PROVIDER_KEY) alarmItem: AlarmItem = new AlarmItem();
// 存储重复设置的数据
@State repeatSettingArr: Array<AlarmSettingItem> = [];
// 存储闹钟设置的数据
@State alarmSettingInfoArr: Array<AlarmSettingItem> = [];
// 标记是否是新建闹钟
private isNew: boolean = true;
// 闹钟视图模型,用于处理闹钟相关逻辑
private viewModel: DetailModel = DetailModel.instant;
// 生命周期函数,在页面即将显示时触发
aboutToAppear() {
// 获取路由参数,判断是否为编辑已有闹钟
let params = router.getParams() as Record<string, Object | undefined>;
if (params !== undefined) {
let alarmItem: AlarmItem = params.alarmItem as AlarmItem;
if (alarmItem !== undefined) {
this.isNew = false;
this.alarmItem = alarmItem;
this.viewModel.setAlarmDefaultTime(this.alarmItem);
} else {
this.viewModel.setAlarmDefaultTime();
}
} else {
this.viewModel.setAlarmDefaultTime();
}
this.initData();
}
// 当 alarmItem 属性变化时触发,用于更新数据
onAlarmItemChange() {
this.initData();
}
// 初始化页面数据
initData() {
this.repeatSettingArr = [
new AlarmSettingItem(DetailConstants.DEFAULT_STRING_REPEAT,
this.alarmItem.repeatType,
AlarmSettingTypes.REPEAT)
];
this.alarmSettingInfoArr = [
new AlarmSettingItem(DetailConstants.DEFAULT_STRING_ALARM_NAME, this.alarmItem.name, AlarmSettingTypes.ALARM_NAME),
new AlarmSettingItem(DetailConstants.DEFAULT_STRING_DURATION,
this.alarmItem.duration + DetailConstants.DEFAULT_STRING_MINUTE, AlarmSettingTypes.RING_DURATION),
new AlarmSettingItem(DetailConstants.DEFAULT_STRING_INTERVAL, this.alarmItem.intervalMinute
+ DetailConstants.DEFAULT_STRING_MINUTE + CommonConstants.DEFAULT_STRING_COMMA
+ this.alarmItem.intervalTimes + DetailConstants.DEFAULT_STRING_TIMES, AlarmSettingTypes.INTERVAL)
];
}
// 定义页面进入和退出的过渡效果
pageTransition() {
// 页面进入效果
PageTransitionEnter({ type: RouteType.None, duration: CommonConstants.ANIMATION_SHORT_DURATION })
.slide(SlideEffect.Bottom);
// 页面退出效果
PageTransitionExit({ type: RouteType.None, duration: CommonConstants.ANIMATION_SHORT_DURATION })
.slide(SlideEffect.Bottom);
}
// 构建页面内容
build() {
Column() {
// 顶部容器,包括标题和取消/保存按钮
BackContainer({
header: this.isNew ? $r('app.string.new_alarm') : $r('app.string.update_alarm'),
backImgRes: $r('app.media.ic_cancel'),
}) {
// 保存按钮
Button() {
Image($r('app.media.ic_confirm')).objectFit(ImageFit.Fill)
}
.backgroundColor($r('app.color.trans_parent'))
.width(DimensionUtil.getVp($r('app.float.title_button_size')))
.height(DimensionUtil.getVp($r('app.float.title_button_size')))
.onClick(() => {
// 设置闹钟状态为开启,并保存设置
this.alarmItem.isOpen = true;
this.viewModel.setAlarmRemind(this.alarmItem);
// 获取下一个闹钟时间
let nextAlarmTime = findNearestAlarmTime([this.alarmItem]);
// 显示最近闹钟时间的提示信息
promptAction.showToast({
message: generateNearestAlarmTimeToast(nextAlarmTime)
});
// 返回上一页
router.back();
});
}
// 日期选择区域
DatePickArea()
// 设置项,包括重复设置和闹钟设置
SettingItem({
settingInfo: $repeatSettingArr
});
SettingItem({
settingInfo: $alarmSettingInfoArr
});
// 空白区域
Blank()
// 删除按钮
Button($r('app.string.delete'))
.visibility(this.isNew ? Visibility.None : Visibility.Visible)
.width(DimensionUtil.getVp($r('app.float.delete_button_width')))
.height(DimensionUtil.getVp($r('app.float.delete_button_height')))
.fontSize(DimensionUtil.getFp($r('app.float.delete_button_font_size')))
.fontColor($r('app.color.red_light'))
.backgroundColor($r('app.color.grey_with_opacity'))
.borderRadius(DimensionUtil.getVp($r('app.float.delete_button_radius')))
.margin({
bottom: DimensionUtil.getVp($r('app.float.delete_button_margin_bottom'))
})
.onClick(() => {
// 移除闹钟
this.viewModel.removeAlarmRemind(this.alarmItem.id);
// 返回上一页
router.back();
});
}
.backgroundColor($r('app.color.grey_light'))
.width(CommonConstants.FULL_LENGTH)
.height(CommonConstants.FULL_LENGTH);
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Entry AST#decorator#Right AST#decorator#Left @ Component AST#decorator#Right export default struct DetailPage AST#component_body#Left { // 监听 alarmItem 属性变化,提供给子组件使用 AST#property_declaration#Left AST#decorator#Left @ Watch ( AST#expression#Left 'onAlarmItemChange' AST#expression#Right ) AST#decorator#Right AST#decorator#Left @ Provide ( AST#expression#Left AST#member_expression#Left AST#expression#Left DetailConstants AST#expression#Right . DEFAULT_PROVIDER_KEY AST#member_expression#Right AST#expression#Right ) AST#decorator#Right alarmItem : AST#type_annotation#Left AST#primary_type#Left AlarmItem 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 AlarmItem 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 AST#decorator#Left @ State AST#decorator#Right repeatSettingArr : 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 AlarmSettingItem 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 // 存储闹钟设置的数据 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right alarmSettingInfoArr : 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 AlarmSettingItem 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 // 标记是否是新建闹钟 AST#property_declaration#Left private isNew : 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#property_declaration#Right // 闹钟视图模型,用于处理闹钟相关逻辑 AST#property_declaration#Left private viewModel : AST#type_annotation#Left AST#primary_type#Left DetailModel AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left DetailModel AST#expression#Right . instant AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right // 生命周期函数,在页面即将显示时触发 AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { // 获取路由参数,判断是否为编辑已有闹钟 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left params = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left router AST#expression#Right . getParams AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right 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#union_type#Left AST#primary_type#Left Object AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_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#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 params 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 alarmItem : AST#type_annotation#Left AST#primary_type#Left AlarmItem AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left params AST#expression#Right . alarmItem AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AlarmItem 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 alarmItem 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isNew 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . alarmItem AST#member_expression#Right = AST#expression#Left alarmItem 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 . viewModel AST#member_expression#Right AST#expression#Right . setAlarmDefaultTime 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 . alarmItem 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 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 this AST#expression#Right . viewModel AST#member_expression#Right AST#expression#Right . setAlarmDefaultTime 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 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 this AST#expression#Right . viewModel AST#member_expression#Right AST#expression#Right . setAlarmDefaultTime 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#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 . initData 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 // 当 alarmItem 属性变化时触发,用于更新数据 AST#method_declaration#Left onAlarmItemChange 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 this AST#expression#Right . initData 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 // 初始化页面数据 AST#method_declaration#Left initData 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 . repeatSettingArr AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left AlarmSettingItem AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left DetailConstants AST#expression#Right . DEFAULT_STRING_REPEAT AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . alarmItem AST#member_expression#Right AST#expression#Right . repeatType AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AlarmSettingTypes AST#expression#Right . REPEAT AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ] AST#array_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 . alarmSettingInfoArr AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left AlarmSettingItem AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left DetailConstants AST#expression#Right . DEFAULT_STRING_ALARM_NAME AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . alarmItem AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AlarmSettingTypes AST#expression#Right . ALARM_NAME AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left AlarmSettingItem AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left DetailConstants AST#expression#Right . DEFAULT_STRING_DURATION AST#member_expression#Right AST#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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . alarmItem AST#member_expression#Right AST#expression#Right . duration AST#member_expression#Right AST#expression#Right + AST#expression#Left DetailConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . DEFAULT_STRING_MINUTE AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AlarmSettingTypes AST#expression#Right . RING_DURATION AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left AlarmSettingItem AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left DetailConstants AST#expression#Right . DEFAULT_STRING_INTERVAL AST#member_expression#Right AST#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 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 AST#member_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 . alarmItem AST#member_expression#Right AST#expression#Right . intervalMinute AST#member_expression#Right AST#expression#Right + AST#expression#Left DetailConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . DEFAULT_STRING_MINUTE AST#member_expression#Right AST#expression#Right + AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . DEFAULT_STRING_COMMA AST#member_expression#Right AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . alarmItem AST#member_expression#Right AST#expression#Right . intervalTimes AST#member_expression#Right AST#expression#Right + AST#expression#Left DetailConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . DEFAULT_STRING_TIMES AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AlarmSettingTypes AST#expression#Right . INTERVAL AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ] AST#array_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 // 定义页面进入和退出的过渡效果 AST#method_declaration#Left pageTransition 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 PageTransitionEnter ( AST#component_parameters#Left { AST#component_parameter#Left type : AST#expression#Left AST#member_expression#Left AST#expression#Left RouteType AST#expression#Right . None AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left duration : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . ANIMATION_SHORT_DURATION AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . slide ( AST#expression#Left AST#member_expression#Left AST#expression#Left SlideEffect AST#expression#Right . Bottom AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#expression_statement#Left AST#expression#Left AST#expression#Right ; AST#expression_statement#Right // 页面退出效果 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left PageTransitionExit ( AST#component_parameters#Left { AST#component_parameter#Left type : AST#expression#Left AST#member_expression#Left AST#expression#Left RouteType AST#expression#Right . None AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left duration : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . ANIMATION_SHORT_DURATION AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . slide ( AST#expression#Left AST#member_expression#Left AST#expression#Left SlideEffect AST#expression#Right . Bottom AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#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#container_content_body#Left { // 顶部容器,包括标题和取消/保存按钮 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left BackContainer ( AST#component_parameters#Left { AST#component_parameter#Left header : AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isNew AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.new_alarm' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.update_alarm' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left backImgRes : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_cancel' AST#expression#Right ) AST#resource_expression#Right 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#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.ic_confirm' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . objectFit ( AST#expression#Left AST#member_expression#Left AST#expression#Left ImageFit AST#expression#Right . Fill 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 . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.trans_parent' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DimensionUtil AST#expression#Right . getVp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.title_button_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DimensionUtil AST#expression#Right . getVp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.title_button_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . alarmItem AST#member_expression#Right AST#expression#Right . isOpen 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#member_expression#Left AST#expression#Left this AST#expression#Right . viewModel AST#member_expression#Right AST#expression#Right . setAlarmRemind 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 . alarmItem 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 let AST#variable_declarator#Left nextAlarmTime = AST#expression#Left AST#call_expression#Left AST#expression#Left findNearestAlarmTime 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 . alarmItem 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#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 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#call_expression#Left AST#expression#Left generateNearestAlarmTimeToast AST#expression#Right AST#argument_list#Left ( AST#expression#Left nextAlarmTime 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#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 . back 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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#container_content_body#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 DatePickArea ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 设置项,包括重复设置和闹钟设置 AST#ui_custom_component_statement#Left SettingItem ( AST#component_parameters#Left { AST#component_parameter#Left settingInfo : AST#expression#Left $repeatSettingArr AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right AST#ui_custom_component_statement#Left SettingItem ( AST#component_parameters#Left { AST#component_parameter#Left settingInfo : AST#expression#Left $alarmSettingInfoArr AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#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#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.delete' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . visibility ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isNew AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left Visibility AST#expression#Right . None AST#member_expression#Right AST#expression#Right : AST#expression#Left Visibility AST#expression#Right AST#conditional_expression#Right AST#expression#Right . Visible AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DimensionUtil AST#expression#Right . getVp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.delete_button_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DimensionUtil AST#expression#Right . getVp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.delete_button_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DimensionUtil AST#expression#Right . getFp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.delete_button_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.red_light' 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.grey_with_opacity' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DimensionUtil AST#expression#Right . getVp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.delete_button_radius' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DimensionUtil AST#expression#Right . getVp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.delete_button_margin_bottom' AST#expression#Right ) AST#resource_expression#Right 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#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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . viewModel AST#member_expression#Right AST#expression#Right . removeAlarmRemind 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 . alarmItem AST#member_expression#Right AST#expression#Right . id 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 router AST#expression#Right . back 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#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.grey_light' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FULL_LENGTH AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FULL_LENGTH 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#ERROR#Left ; AST#ERROR#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Entry
@Component
export default struct DetailPage {
@Watch('onAlarmItemChange') @Provide(DetailConstants.DEFAULT_PROVIDER_KEY) alarmItem: AlarmItem = new AlarmItem();
@State repeatSettingArr: Array<AlarmSettingItem> = [];
@State alarmSettingInfoArr: Array<AlarmSettingItem> = [];
private isNew: boolean = true;
private viewModel: DetailModel = DetailModel.instant;
aboutToAppear() {
let params = router.getParams() as Record<string, Object | undefined>;
if (params !== undefined) {
let alarmItem: AlarmItem = params.alarmItem as AlarmItem;
if (alarmItem !== undefined) {
this.isNew = false;
this.alarmItem = alarmItem;
this.viewModel.setAlarmDefaultTime(this.alarmItem);
} else {
this.viewModel.setAlarmDefaultTime();
}
} else {
this.viewModel.setAlarmDefaultTime();
}
this.initData();
}
onAlarmItemChange() {
this.initData();
}
initData() {
this.repeatSettingArr = [
new AlarmSettingItem(DetailConstants.DEFAULT_STRING_REPEAT,
this.alarmItem.repeatType,
AlarmSettingTypes.REPEAT)
];
this.alarmSettingInfoArr = [
new AlarmSettingItem(DetailConstants.DEFAULT_STRING_ALARM_NAME, this.alarmItem.name, AlarmSettingTypes.ALARM_NAME),
new AlarmSettingItem(DetailConstants.DEFAULT_STRING_DURATION,
this.alarmItem.duration + DetailConstants.DEFAULT_STRING_MINUTE, AlarmSettingTypes.RING_DURATION),
new AlarmSettingItem(DetailConstants.DEFAULT_STRING_INTERVAL, this.alarmItem.intervalMinute
+ DetailConstants.DEFAULT_STRING_MINUTE + CommonConstants.DEFAULT_STRING_COMMA
+ this.alarmItem.intervalTimes + DetailConstants.DEFAULT_STRING_TIMES, AlarmSettingTypes.INTERVAL)
];
}
pageTransition() {
PageTransitionEnter({ type: RouteType.None, duration: CommonConstants.ANIMATION_SHORT_DURATION })
.slide(SlideEffect.Bottom);
PageTransitionExit({ type: RouteType.None, duration: CommonConstants.ANIMATION_SHORT_DURATION })
.slide(SlideEffect.Bottom);
}
build() {
Column() {
BackContainer({
header: this.isNew ? $r('app.string.new_alarm') : $r('app.string.update_alarm'),
backImgRes: $r('app.media.ic_cancel'),
}) {
Button() {
Image($r('app.media.ic_confirm')).objectFit(ImageFit.Fill)
}
.backgroundColor($r('app.color.trans_parent'))
.width(DimensionUtil.getVp($r('app.float.title_button_size')))
.height(DimensionUtil.getVp($r('app.float.title_button_size')))
.onClick(() => {
this.alarmItem.isOpen = true;
this.viewModel.setAlarmRemind(this.alarmItem);
let nextAlarmTime = findNearestAlarmTime([this.alarmItem]);
promptAction.showToast({
message: generateNearestAlarmTimeToast(nextAlarmTime)
});
router.back();
});
}
DatePickArea()
SettingItem({
settingInfo: $repeatSettingArr
});
SettingItem({
settingInfo: $alarmSettingInfoArr
});
Blank()
Button($r('app.string.delete'))
.visibility(this.isNew ? Visibility.None : Visibility.Visible)
.width(DimensionUtil.getVp($r('app.float.delete_button_width')))
.height(DimensionUtil.getVp($r('app.float.delete_button_height')))
.fontSize(DimensionUtil.getFp($r('app.float.delete_button_font_size')))
.fontColor($r('app.color.red_light'))
.backgroundColor($r('app.color.grey_with_opacity'))
.borderRadius(DimensionUtil.getVp($r('app.float.delete_button_radius')))
.margin({
bottom: DimensionUtil.getVp($r('app.float.delete_button_margin_bottom'))
})
.onClick(() => {
this.viewModel.removeAlarmRemind(this.alarmItem.id);
router.back();
});
}
.backgroundColor($r('app.color.grey_light'))
.width(CommonConstants.FULL_LENGTH)
.height(CommonConstants.FULL_LENGTH);
}
}
|
https://github.com/2763981847/Clock-Alarm.git/blob/8949bedddb7d011021848196735f30ffe2bd1daf/entry/src/main/ets/pages/DetailPage.ets#L17-L155
|
11bf33eb16d5362b81c04e2034db1c781842eed2
|
github
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/theme/ThemeManager.ets
|
arkts
|
initializeThemeManager
|
初始化主题管理器
|
private async initializeThemeManager(): Promise<void> {
try {
// 加载预设主题
await this.loadPresetThemes();
// 加载字体配置
await this.loadFontConfigs();
// 加载当前主题配置
await this.loadCurrentTheme();
// 应用主题
if (this.currentTheme) {
await this.applyTheme(this.currentTheme);
}
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, 'ThemeManager initialized');
} catch (error) {
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to initialize ThemeManager: ${error}`);
}
}
|
AST#method_declaration#Left private async initializeThemeManager 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 this AST#expression#Right AST#await_expression#Right AST#expression#Right . loadPresetThemes 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#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . loadFontConfigs 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#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . loadCurrentTheme 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#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentTheme 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 AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . applyTheme 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 . currentTheme 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#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 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 'ThemeManager initialized' 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 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 initialize ThemeManager: 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 initializeThemeManager(): Promise<void> {
try {
await this.loadPresetThemes();
await this.loadFontConfigs();
await this.loadCurrentTheme();
if (this.currentTheme) {
await this.applyTheme(this.currentTheme);
}
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, 'ThemeManager initialized');
} catch (error) {
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to initialize ThemeManager: ${error}`);
}
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/theme/ThemeManager.ets#L144-L164
|
b8b930199073d83fa31ea93086df590179e7c87b
|
github
|
BohanSu/LumosAgent-HarmonyOS.git
|
9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76
|
entry/src/main/ets/services/AgentService.ets
|
arkts
|
executeSaveMemo
|
Execute save_memo function
Saves a new memo in the database
@param args - Function arguments
@returns Result message
|
private async executeSaveMemo(args: SaveMemoArgs): Promise<string> {
try {
const normalizedContent = this.normalizeQuotes(args.content) ?? args.content;
console.info(`[AgentService] Saving memo: ${normalizedContent}`);
// Create memo object
const memo = new Memo(0, normalizedContent, Date.now());
// Insert into database
const memoId = await this.rdbHelper.insertMemo(memo);
const resultMsg = `Memo saved successfully with ID: ${memoId}`;
console.info(`[AgentService] ${resultMsg}`);
return resultMsg;
} catch (error) {
const err = error as BusinessError;
console.error(`[AgentService] Failed to save memo: ${err.message}`);
return `Failed to save memo: ${err.message}`;
}
}
|
AST#method_declaration#Left private async executeSaveMemo AST#parameter_list#Left ( AST#parameter#Left args : AST#type_annotation#Left AST#primary_type#Left SaveMemoArgs 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#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left normalizedContent = AST#expression#Left AST#member_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 this AST#expression#Right . normalizeQuotes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left args AST#expression#Right . content AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ?? AST#expression#Left args AST#expression#Right AST#binary_expression#Right AST#expression#Right . content 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 console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [AgentService] Saving memo: AST#template_substitution#Left $ { AST#expression#Left normalizedContent 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 // Create memo object AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left memo = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Memo AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left normalizedContent AST#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#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // Insert into database AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left memoId = 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 . rdbHelper AST#member_expression#Right AST#expression#Right . insertMemo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left memo 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 resultMsg = AST#expression#Left AST#template_literal#Left ` Memo saved successfully with ID: AST#template_substitution#Left $ { AST#expression#Left memoId 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 console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [AgentService] AST#template_substitution#Left $ { AST#expression#Left resultMsg 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#return_statement#Left return AST#expression#Left resultMsg 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#variable_declaration#Left const AST#variable_declarator#Left err = 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 console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [AgentService] Failed to save memo: 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#return_statement#Left return AST#expression#Left AST#template_literal#Left ` Failed to save memo: 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#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
|
private async executeSaveMemo(args: SaveMemoArgs): Promise<string> {
try {
const normalizedContent = this.normalizeQuotes(args.content) ?? args.content;
console.info(`[AgentService] Saving memo: ${normalizedContent}`);
const memo = new Memo(0, normalizedContent, Date.now());
const memoId = await this.rdbHelper.insertMemo(memo);
const resultMsg = `Memo saved successfully with ID: ${memoId}`;
console.info(`[AgentService] ${resultMsg}`);
return resultMsg;
} catch (error) {
const err = error as BusinessError;
console.error(`[AgentService] Failed to save memo: ${err.message}`);
return `Failed to save memo: ${err.message}`;
}
}
|
https://github.com/BohanSu/LumosAgent-HarmonyOS.git/blob/9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76/entry/src/main/ets/services/AgentService.ets#L594-L614
|
0f3494445dbaa6df64471fa0256645b619ede9fb
|
github
|
Joker-x-dev/CoolMallArkTS.git
|
9f3fabf89fb277692cb82daf734c220c7282919c
|
feature/order/src/main/ets/viewmodel/OrderDetailViewModel.ets
|
arkts
|
hideConfirmReceiveDialog
|
隐藏确认收货弹窗
@returns {void} 无返回值
|
hideConfirmReceiveDialog(): void {
this.showConfirmDialog = false;
}
|
AST#method_declaration#Left hideConfirmReceiveDialog 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 . 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#builder_function_body#Right AST#method_declaration#Right
|
hideConfirmReceiveDialog(): void {
this.showConfirmDialog = false;
}
|
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/order/src/main/ets/viewmodel/OrderDetailViewModel.ets#L279-L281
|
ea0049959e7c7a5a2709096f838e5bb2c16dc8ad
|
github
|
openharmony/arkui_ace_engine
|
30c7d1ee12fbedf0fabece54291d75897e2ad44f
|
examples/Select/entry/src/main/ets/pages/components/checkbox/checkboxShape.ets
|
arkts
|
CheckboxShapeBuilder
|
Copyright (c) 2025 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.
|
@Builder
export function CheckboxShapeBuilder(name: string, param: Object) {
CheckboxShapeExample()
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function CheckboxShapeBuilder AST#parameter_list#Left ( AST#parameter#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left param : AST#type_annotation#Left AST#primary_type#Left Object 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 CheckboxShapeExample ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#decorated_export_declaration#Right
|
@Builder
export function CheckboxShapeBuilder(name: string, param: Object) {
CheckboxShapeExample()
}
|
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/examples/Select/entry/src/main/ets/pages/components/checkbox/checkboxShape.ets#L16-L19
|
c26c82e7615fa6db4378d9e63bc6d22a4c301368
|
gitee
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/customdrawtabbar/src/main/ets/components/tabsConcaveCircle/TabsConcaveCircle.ets
|
arkts
|
getAnimateSelectIndex
|
获取动画控制的下标
用于切换选项时,先让标签回到底部,然后让当前选项在上移
|
getAnimateSelectIndex() {
// 动画等待时间 - 用于等待上一个选项动画结束
let animateDelay = 500;
animateTo({
duration: this.animateTime,
delay: animateDelay
}, () => {
this.animateSelectIndex = this.selectIndex
})
// 绘制canvas 用于兼容点击 凸起时,canvas 同时移动
this.createAnimation()
}
|
AST#method_declaration#Left getAnimateSelectIndex AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { // 动画等待时间 - 用于等待上一个选项动画结束 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left animateDelay = AST#expression#Left 500 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 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . animateTime AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left delay AST#property_name#Right : AST#expression#Left animateDelay 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 this AST#expression#Right . animateSelectIndex AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectIndex 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#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // 绘制canvas 用于兼容点击 凸起时,canvas 同时移动 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 . createAnimation 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
|
getAnimateSelectIndex() {
let animateDelay = 500;
animateTo({
duration: this.animateTime,
delay: animateDelay
}, () => {
this.animateSelectIndex = this.selectIndex
})
this.createAnimation()
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/customdrawtabbar/src/main/ets/components/tabsConcaveCircle/TabsConcaveCircle.ets#L64-L76
|
123a697513b952bc3c787248027a7e79375dfd84
|
gitee
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/photopickandsave/src/main/ets/components/SaveNetWorkPictures.ets
|
arkts
|
saveImage
|
保存ArrayBuffer到图库
@param buffer:图片ArrayBuffer
@returns
|
async saveImage(buffer: ArrayBuffer | string): Promise<void> {
const context = getContext(this) as common.UIAbilityContext; // 获取getPhotoAccessHelper需要的context
const helper = photoAccessHelper.getPhotoAccessHelper(context); // 获取相册管理模块的实例
const uri = await helper.createAsset(photoAccessHelper.PhotoType.IMAGE, 'jpg'); // 指定待创建的文件类型、后缀和创建选项,创建图片或视频资源
const file = await fs.open(uri, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
await fs.write(file.fd, buffer);
await fs.close(file.fd);
}
|
AST#method_declaration#Left async saveImage AST#parameter_list#Left ( AST#parameter#Left buffer : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ArrayBuffer AST#primary_type#Right | AST#primary_type#Left string 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#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 context = 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 // 获取getPhotoAccessHelper需要的context AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left helper = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left photoAccessHelper AST#expression#Right . getPhotoAccessHelper 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 获取相册管理模块的实例 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left uri = 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 helper AST#expression#Right AST#await_expression#Right AST#expression#Right . createAsset 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 photoAccessHelper AST#expression#Right . PhotoType AST#member_expression#Right AST#expression#Right . IMAGE AST#member_expression#Right AST#expression#Right , AST#expression#Left 'jpg' 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 file = 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 fs AST#expression#Right AST#await_expression#Right AST#expression#Right . open AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uri AST#expression#Right , AST#expression#Left AST#member_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#member_expression#Left AST#expression#Left fs AST#expression#Right . OpenMode AST#member_expression#Right AST#expression#Right . READ_WRITE AST#member_expression#Right AST#expression#Right | AST#expression#Left fs AST#expression#Right AST#binary_expression#Right AST#expression#Right . OpenMode AST#member_expression#Right AST#expression#Right . CREATE 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 AST#await_expression#Left await AST#expression#Left fs AST#expression#Right AST#await_expression#Right AST#expression#Right . write 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 buffer 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 fs AST#expression#Right AST#await_expression#Right AST#expression#Right . close 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#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 saveImage(buffer: ArrayBuffer | string): Promise<void> {
const context = getContext(this) as common.UIAbilityContext;
const helper = photoAccessHelper.getPhotoAccessHelper(context);
const uri = await helper.createAsset(photoAccessHelper.PhotoType.IMAGE, 'jpg');
const file = await fs.open(uri, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
await fs.write(file.fd, buffer);
await fs.close(file.fd);
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/photopickandsave/src/main/ets/components/SaveNetWorkPictures.ets#L96-L103
|
ea9523963dd6a59c80893b72c8d88fe6a54f149d
|
gitee
|
JHB11Hinson/mineMointorAPP.git
|
b6b853cf534021ac39e66c9b3a35113896a272b2
|
entry/src/main/ets/pages/DustMonitoringPage.ets
|
arkts
|
getNormalAreaCount
|
获取正常区域数量
|
private getNormalAreaCount(): number {
return this.dustList.filter(item => item.status === 0).length;
}
|
AST#method_declaration#Left private getNormalAreaCount 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#return_statement#Left return 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 . dustList AST#member_expression#Right AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left item => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . status AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private getNormalAreaCount(): number {
return this.dustList.filter(item => item.status === 0).length;
}
|
https://github.com/JHB11Hinson/mineMointorAPP.git/blob/b6b853cf534021ac39e66c9b3a35113896a272b2/entry/src/main/ets/pages/DustMonitoringPage.ets#L184-L186
|
3bd8679bdb7760c92d5c3ffdd0bfdab85999956a
|
github
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/selecttextmenu/Index.ets
|
arkts
|
SelectTextMenuComponent
|
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.
|
export { SelectTextMenuComponent } from './src/main/ets/view/SelectTextMenu';
|
AST#export_declaration#Left export { SelectTextMenuComponent } from './src/main/ets/view/SelectTextMenu' ; AST#export_declaration#Right
|
export { SelectTextMenuComponent } from './src/main/ets/view/SelectTextMenu';
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/selecttextmenu/Index.ets#L16-L16
|
fcebc9436cb7f2da1e1468e91d8930604bbe7fbf
|
gitee
|
L1rics06/arkTS-.git
|
991fd131bfdb11e2933152133c97453d86092ac0
|
entry/src/main/ets/pages/NetworkUtil.ets
|
arkts
|
聊天消息请求参数
|
export interface ChatMessagesParams {
sessionId: string;
pageNum: number;
pageSize: number;
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface ChatMessagesParams AST#object_type#Left { AST#type_member#Left sessionId : 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 pageNum : 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 pageSize : 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 ChatMessagesParams {
sessionId: string;
pageNum: number;
pageSize: number;
}
|
https://github.com/L1rics06/arkTS-.git/blob/991fd131bfdb11e2933152133c97453d86092ac0/entry/src/main/ets/pages/NetworkUtil.ets#L206-L210
|
8a822de715932b9b850380d372fd832f90150a46
|
github
|
|
openharmony/developtools_profiler
|
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
|
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/renderer/DataRenderer.ets
|
arkts
|
Superclass of all render classes for the different data types (line, bar, ...).
@author Philipp Jahoda
|
export default abstract class DataRenderer extends Renderer {
/**
* the animator object used to perform animations on the chart data
*/
protected mAnimator: ChartAnimator = new ChartAnimator();
/**
* main paint object used for rendering
*/
protected mRenderPaint: Paint;
protected mPathPaint: PathPaint;
/**
* paint used for highlighting values
*/
protected mHighlightPaint: Paint;
protected mDrawPaint: Paint;
/**
* paint object for drawing values (text representing values of chart
* entries)
*/
public mValuePaint: Paint;
constructor(animator: ChartAnimator, viewPortHandler: ViewPortHandler) {
super(viewPortHandler);
this.mAnimator = animator;
this.mRenderPaint = new Paint();
this.mRenderPaint.setStyle(Style.FILL);
this.mPathPaint = new PathPaint();
this.mDrawPaint = new Paint();
this.mValuePaint = new Paint();
this.mValuePaint.setColor(Color.Green);
this.mValuePaint.setTextAlign(TextAlign.Center);
this.mValuePaint.setTextSize(10);
this.mHighlightPaint = new Paint();
this.mHighlightPaint.setStyle(Style.STROKE);
this.mHighlightPaint.setStrokeWidth(2);
this.mHighlightPaint.setColor(Color.Orange);
}
protected isDrawingValuesAllowed(chart: ChartInterface): boolean {
return chart.getData().getEntryCount() < chart.getMaxVisibleCount() * this.mViewPortHandler.getScaleX();
}
/**
* Returns the Paint object this renderer uses for drawing the values
* (value-text).
*
* @return
*/
public getPaintValues(): Paint {
return this.mValuePaint;
}
/**
* Returns the Paint object this renderer uses for drawing highlight
* indicators.
*
* @return
*/
public getPaintHighlight(): Paint {
return this.mHighlightPaint;
}
/**
* Returns the Paint object used for rendering.
*
* @return
*/
public getPaintRender(): Paint {
return this.mRenderPaint;
}
public getPathPaint(): PathPaint {
return this.mPathPaint;
}
/**
* Applies the required styling (provided by the DataSet) to the value-paint
* object.
*
* @param set
*/
protected applyValueTextStyle(dateSet: IDataSet<EntryOhos>) {
this.mValuePaint.setTypeface(dateSet.getValueTypeface());
this.mValuePaint.setTextSize(dateSet.getValueTextSize());
}
/**
* Initializes the buffers used for rendering with a new size. Since this
* method performs memory allocations, it should only be called if
* necessary.
*/
public abstract initBuffers();
/**
* Draws the actual data in form of lines, bars, ... depending on Renderer subclass.
*
* @param c
*/
public abstract drawData(): Paint[];
/**
* Loops over all Entrys and draws their values.
*
* @param c
*/
public abstract drawValues(): Paint[];
/**
* Draws the value of the given entry by using the provided IValueFormatter.
*
* @param c canvas
* @param formatter formatter for custom value-formatting
* @param value the value to be drawn
* @param entry the entry the value belongs to
* @param dataSetIndex the index of the DataSet the drawn Entry belongs to
* @param x position
* @param y position
* @param color
*/
public drawValue(
formatter: IValueFormatter,
value: number,
entry: EntryOhos,
dataSetIndex: number,
x: number,
y: number,
color: number
): Paint[] {
this.mValuePaint.setColor(color);
let textPaint = new TextPaint();
textPaint.set(this.mValuePaint);
textPaint.setText(formatter.getFormattedValue(value, entry, dataSetIndex, this.mViewPortHandler));
textPaint.setX(x);
textPaint.setY(y);
return [textPaint];
}
/**
* Draws any kind of additional information (e.g. line-circles).
*
* @param c
*/
public abstract drawExtras(): Paint[];
/**
* Draws all highlight indicators for the values that are currently highlighted.
*
* @param c
* @param indices the highlighted values
*/
public abstract drawHighlighted(indices: Highlight[]): Paint[];
}
|
AST#export_declaration#Left export default AST#class_declaration#Left abstract class DataRenderer extends AST#type_annotation#Left AST#primary_type#Left Renderer AST#primary_type#Right AST#type_annotation#Right AST#class_body#Left { /**
* the animator object used to perform animations on the chart data
*/ AST#property_declaration#Left protected mAnimator : AST#type_annotation#Left AST#primary_type#Left ChartAnimator 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 ChartAnimator 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 /**
* main paint object used for rendering
*/ AST#property_declaration#Left protected mRenderPaint : AST#type_annotation#Left AST#primary_type#Left Paint AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left protected mPathPaint : AST#type_annotation#Left AST#primary_type#Left PathPaint AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* paint used for highlighting values
*/ AST#property_declaration#Left protected mHighlightPaint : AST#type_annotation#Left AST#primary_type#Left Paint AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left protected mDrawPaint : AST#type_annotation#Left AST#primary_type#Left Paint AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* paint object for drawing values (text representing values of chart
* entries)
*/ AST#property_declaration#Left public mValuePaint : AST#type_annotation#Left AST#primary_type#Left Paint AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left animator : AST#type_annotation#Left AST#primary_type#Left ChartAnimator AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left viewPortHandler : AST#type_annotation#Left AST#primary_type#Left ViewPortHandler 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 super AST#expression#Right AST#argument_list#Left ( AST#expression#Left viewPortHandler 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 . mAnimator AST#member_expression#Right = AST#expression#Left animator 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 . mRenderPaint AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Paint 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#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 . mRenderPaint AST#member_expression#Right AST#expression#Right . setStyle AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Style AST#expression#Right . FILL 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mPathPaint AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left PathPaint 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#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 . mDrawPaint AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Paint 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#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 . mValuePaint AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Paint 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#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 . mValuePaint AST#member_expression#Right AST#expression#Right . setColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Green 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . mValuePaint AST#member_expression#Right AST#expression#Right . setTextAlign AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . mValuePaint AST#member_expression#Right AST#expression#Right . setTextSize 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#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 . mHighlightPaint AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Paint 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#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 . mHighlightPaint AST#member_expression#Right AST#expression#Right . setStyle AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Style AST#expression#Right . STROKE 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . mHighlightPaint AST#member_expression#Right AST#expression#Right . setStrokeWidth 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 ; 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 . mHighlightPaint AST#member_expression#Right AST#expression#Right . setColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Orange 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#constructor_declaration#Right AST#method_declaration#Left protected isDrawingValuesAllowed AST#parameter_list#Left ( AST#parameter#Left chart : AST#type_annotation#Left AST#primary_type#Left ChartInterface 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 AST#member_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#binary_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 chart AST#expression#Right . getData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getEntryCount 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 chart AST#expression#Right AST#binary_expression#Right AST#expression#Right . getMaxVisibleCount 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 this AST#expression#Right AST#binary_expression#Right AST#expression#Right . mViewPortHandler AST#member_expression#Right AST#expression#Right . getScaleX 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 /**
* Returns the Paint object this renderer uses for drawing the values
* (value-text).
*
* @return
*/ AST#method_declaration#Left public getPaintValues AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left Paint 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 this AST#expression#Right . mValuePaint AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* Returns the Paint object this renderer uses for drawing highlight
* indicators.
*
* @return
*/ AST#method_declaration#Left public getPaintHighlight AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left Paint 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 this AST#expression#Right . mHighlightPaint AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* Returns the Paint object used for rendering.
*
* @return
*/ AST#method_declaration#Left public getPaintRender AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left Paint 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 this AST#expression#Right . mRenderPaint AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left public getPathPaint AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left PathPaint 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 this AST#expression#Right . mPathPaint AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* Applies the required styling (provided by the DataSet) to the value-paint
* object.
*
* @param set
*/ AST#method_declaration#Left protected applyValueTextStyle AST#parameter_list#Left ( AST#parameter#Left dateSet : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left IDataSet AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left EntryOhos 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#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 . mValuePaint AST#member_expression#Right AST#expression#Right . setTypeface 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 dateSet AST#expression#Right . getValueTypeface 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#expression_statement#Right 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 . mValuePaint AST#member_expression#Right AST#expression#Right . setTextSize 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 dateSet AST#expression#Right . getValueTextSize 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#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* Initializes the buffers used for rendering with a new size. Since this
* method performs memory allocations, it should only be called if
* necessary.
*/ AST#method_declaration#Left public abstract initBuffers AST#parameter_list#Left ( ) AST#parameter_list#Right ; AST#method_declaration#Right /**
* Draws the actual data in form of lines, bars, ... depending on Renderer subclass.
*
* @param c
*/ AST#method_declaration#Left public abstract drawData AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Paint [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right /**
* Loops over all Entrys and draws their values.
*
* @param c
*/ AST#method_declaration#Left public abstract drawValues AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Paint [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right /**
* Draws the value of the given entry by using the provided IValueFormatter.
*
* @param c canvas
* @param formatter formatter for custom value-formatting
* @param value the value to be drawn
* @param entry the entry the value belongs to
* @param dataSetIndex the index of the DataSet the drawn Entry belongs to
* @param x position
* @param y position
* @param color
*/ AST#method_declaration#Left public drawValue AST#parameter_list#Left ( AST#parameter#Left formatter : AST#type_annotation#Left AST#primary_type#Left IValueFormatter AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , 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 entry : AST#type_annotation#Left AST#primary_type#Left EntryOhos AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left dataSetIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left x : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left y : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left color : 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 Paint [ ] AST#array_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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . mValuePaint AST#member_expression#Right AST#expression#Right . setColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left color 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 textPaint = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left TextPaint 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 textPaint AST#expression#Right . set 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 . mValuePaint 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 textPaint AST#expression#Right . setText 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 formatter AST#expression#Right . getFormattedValue AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left value AST#expression#Right , AST#expression#Left entry AST#expression#Right , AST#expression#Left dataSetIndex AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mViewPortHandler 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 textPaint AST#expression#Right . setX AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left x 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 textPaint AST#expression#Right . setY AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left y 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#array_literal#Left [ AST#expression#Left textPaint AST#expression#Right ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* Draws any kind of additional information (e.g. line-circles).
*
* @param c
*/ AST#method_declaration#Left public abstract drawExtras AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Paint [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right /**
* Draws all highlight indicators for the values that are currently highlighted.
*
* @param c
* @param indices the highlighted values
*/ AST#method_declaration#Left public abstract drawHighlighted AST#parameter_list#Left ( AST#parameter#Left indices : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Highlight [ ] 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 Paint [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export default abstract class DataRenderer extends Renderer {
protected mAnimator: ChartAnimator = new ChartAnimator();
protected mRenderPaint: Paint;
protected mPathPaint: PathPaint;
protected mHighlightPaint: Paint;
protected mDrawPaint: Paint;
public mValuePaint: Paint;
constructor(animator: ChartAnimator, viewPortHandler: ViewPortHandler) {
super(viewPortHandler);
this.mAnimator = animator;
this.mRenderPaint = new Paint();
this.mRenderPaint.setStyle(Style.FILL);
this.mPathPaint = new PathPaint();
this.mDrawPaint = new Paint();
this.mValuePaint = new Paint();
this.mValuePaint.setColor(Color.Green);
this.mValuePaint.setTextAlign(TextAlign.Center);
this.mValuePaint.setTextSize(10);
this.mHighlightPaint = new Paint();
this.mHighlightPaint.setStyle(Style.STROKE);
this.mHighlightPaint.setStrokeWidth(2);
this.mHighlightPaint.setColor(Color.Orange);
}
protected isDrawingValuesAllowed(chart: ChartInterface): boolean {
return chart.getData().getEntryCount() < chart.getMaxVisibleCount() * this.mViewPortHandler.getScaleX();
}
public getPaintValues(): Paint {
return this.mValuePaint;
}
public getPaintHighlight(): Paint {
return this.mHighlightPaint;
}
public getPaintRender(): Paint {
return this.mRenderPaint;
}
public getPathPaint(): PathPaint {
return this.mPathPaint;
}
protected applyValueTextStyle(dateSet: IDataSet<EntryOhos>) {
this.mValuePaint.setTypeface(dateSet.getValueTypeface());
this.mValuePaint.setTextSize(dateSet.getValueTextSize());
}
public abstract initBuffers();
public abstract drawData(): Paint[];
public abstract drawValues(): Paint[];
public drawValue(
formatter: IValueFormatter,
value: number,
entry: EntryOhos,
dataSetIndex: number,
x: number,
y: number,
color: number
): Paint[] {
this.mValuePaint.setColor(color);
let textPaint = new TextPaint();
textPaint.set(this.mValuePaint);
textPaint.setText(formatter.getFormattedValue(value, entry, dataSetIndex, this.mViewPortHandler));
textPaint.setX(x);
textPaint.setY(y);
return [textPaint];
}
public abstract drawExtras(): Paint[];
public abstract drawHighlighted(indices: Highlight[]): Paint[];
}
|
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/renderer/DataRenderer.ets#L33-L194
|
3a817afd17b911f10508c082be5ca446e4b6c21e
|
gitee
|
|
tomorrowKreswell/Ledger.git
|
1f2783ae70b8540d677af8a27f29db1b4089ea69
|
ledger/entry/src/main/ets/common/database/Rdb.ets
|
arkts
|
导出一个名为 Rdb 的类,用于封装关系型数据库的操作
|
export default class Rdb {
private rdbStore: relationalStore.RdbStore | null = null;
private tableName: string;
private sqlCreateTable: string;
private columns: Array<string>;
/**
* 构造函数,用于创建 Rdb 类的实例
* @param tableName - 表名
* @param sqlCreateTable - 创建表的 SQL 语句
* @param columns - 表的列名数组
*/
constructor(tableName: string, sqlCreateTable: string, columns: Array<string>) {
this.tableName = tableName;
this.sqlCreateTable = sqlCreateTable;
this.columns = columns;
}
/**
* 获取关系型数据库存储对象
* @param callback - 获取成功后的回调函数
*/
getRdbStore(callback: Function = () => {
}): void {
// 如果回调函数未提供,记录警告信息
if (!callback || typeof callback === 'undefined' || callback === undefined) {
Logger.info(CommonConstants.RDB_TAG, 'getRdbStore() has no callback!');
return;
}
// 如果 rdbStore 已存在,直接调用回调函数并返回
if (this.rdbStore !== null) {
Logger.info(CommonConstants.RDB_TAG, 'The rdbStore exists.');
callback();
return;
}
// 获取应用上下文
let context: Context = getContext(this) as Context;
// 使用关系型存储库的 API 获取 RdbStore
relationalStore.getRdbStore(context, CommonConstants.STORE_CONFIG, (err, rdb) => {
if (err) {
Logger.error(CommonConstants.RDB_TAG, `getRdbStore() failed, err: ${err}`);
return;
}
// 将获取到的 RdbStore 存储在实例变量中
this.rdbStore = rdb;
// 执行创建表的 SQL 语句
this.rdbStore.executeSql(this.sqlCreateTable);
Logger.info(CommonConstants.RDB_TAG, 'getRdbStore() finished.');
// 调用回调函数
callback();
});
}
/**
* 批量插入数据
* @param data - 要插入的数据数组
* @param callback - 插入成功后的回调函数
*/
batchInsert(data: relationalStore.ValuesBucket[], callback: Function = () => {
}): void {
// 如果回调函数未提供,记录警告信息
if (!callback || typeof callback === 'undefined' || callback === undefined) {
Logger.info(CommonConstants.RDB_TAG, 'batchInsert() has no callback!');
return;
}
let resFlag: boolean = false;
const valueBuckets: relationalStore.ValuesBucket[] = data;
// 如果 rdbStore 存在,使用关系型存储库的 API 进行批量插入
if (this.rdbStore) {
this.rdbStore.batchInsert(this.tableName, valueBuckets, (err, ret) => {
if (err) {
Logger.error(CommonConstants.RDB_TAG, `batchInsert() failed, err: ${err}`);
callback(resFlag);
return;
}
Logger.info(CommonConstants.RDB_TAG, `batchInsert() finished: ${ret}`);
callback(ret);
});
}
}
/**
* 插入单条数据
* @param data - 要插入的数据
* @param callback - 插入成功后的回调函数
*/
insertData(data: relationalStore.ValuesBucket, callback: Function = () => {
}): void {
// 调用批量插入的方法,传入单条数据
this.batchInsert([data], callback);
}
/**
* 删除数据
* @param predicates - 删除数据的条件
* @param callback - 删除成功后的回调函数
*/
deleteData(predicates: relationalStore.RdbPredicates, callback: Function = () => {
}): void {
// 如果回调函数未提供,记录警告信息
if (!callback || typeof callback === 'undefined' || callback === undefined) {
Logger.info(CommonConstants.RDB_TAG, 'deleteData() has no callback!');
return;
}
let resFlag: boolean = false;
// 如果 rdbStore 存在,使用关系型存储库的 API 进行删除
if (this.rdbStore) {
this.rdbStore.delete(predicates, (err, ret) => {
if (err) {
Logger.error(CommonConstants.RDB_TAG, `deleteData() failed, err: ${err}`);
callback(resFlag);
return;
}
Logger.info(CommonConstants.RDB_TAG, `deleteData() finished: ${ret}`);
callback(!resFlag);
});
}
}
/**
* 更新数据
* @param predicates - 更新数据的条件
* @param data - 要更新的数据
* @param callback - 更新成功后的回调函数
*/
updateData(predicates: relationalStore.RdbPredicates, data: relationalStore.ValuesBucket, callback: Function = () => {
}): void {
// 如果回调函数未提供,记录警告信息
if (!callback || typeof callback === 'undefined' || callback === undefined) {
Logger.info(CommonConstants.RDB_TAG, 'updateData() has no callback!');
return;
}
let resFlag: boolean = false;
const valueBucket: relationalStore.ValuesBucket = data;
// 如果 rdbStore 存在,使用关系型存储库的 API 进行更新
if (this.rdbStore) {
this.rdbStore.update(valueBucket, predicates, (err, ret) => {
if (err) {
Logger.error(CommonConstants.RDB_TAG, `updateData() failed, err: ${err}`);
callback(resFlag);
return;
}
Logger.info(CommonConstants.RDB_TAG, `updateData() finished: ${ret}`);
callback(!resFlag);
});
}
}
/**
* 查询数据
* @param predicates - 查询数据的条件
* @param callback - 查询成功后的回调函数
*/
query(predicates: relationalStore.RdbPredicates, callback: Function = () => {
}): void {
// 如果回调函数未提供,记录警告信息
if (!callback || typeof callback === 'undefined' || callback === undefined) {
Logger.info(CommonConstants.RDB_TAG, 'query() has no callback!');
return;
}
// 如果 rdbStore 存在,使用关系型存储库的 API 进行查询
if (this.rdbStore) {
this.rdbStore.query(predicates, this.columns, (err, resultSet) => {
if (err) {
Logger.error(CommonConstants.RDB_TAG, `query() failed, err: ${err}`);
return;
}
Logger.info(CommonConstants.RDB_TAG, 'query() finished.');
// 调用回调函数,并关闭结果集
callback(resultSet);
resultSet.close();
});
}
}
}
|
AST#export_declaration#Left export default AST#class_declaration#Left class Rdb AST#class_body#Left { AST#property_declaration#Left private rdbStore : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#qualified_type#Left relationalStore . RdbStore AST#qualified_type#Right 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#property_declaration#Left private tableName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left private sqlCreateTable : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left private columns : 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 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#property_declaration#Right /**
* 构造函数,用于创建 Rdb 类的实例
* @param tableName - 表名
* @param sqlCreateTable - 创建表的 SQL 语句
* @param columns - 表的列名数组
*/ AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left tableName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left sqlCreateTable : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left columns : 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 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#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 . tableName AST#member_expression#Right = AST#expression#Left tableName 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 . sqlCreateTable AST#member_expression#Right = AST#expression#Left sqlCreateTable 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 . columns AST#member_expression#Right = AST#expression#Left columns AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right /**
* 获取关系型数据库存储对象
* @param callback - 获取成功后的回调函数
*/ AST#method_declaration#Left getRdbStore AST#parameter_list#Left ( AST#parameter#Left callback : AST#type_annotation#Left AST#primary_type#Left Function AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#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#binary_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left callback AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left callback AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left 'undefined' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || 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#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 Logger 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 CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left 'getRdbStore() has no callback!' 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 // 如果 rdbStore 已存在,直接调用回调函数并返回 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 . rdbStore 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#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#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left 'The rdbStore exists.' 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#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 context : AST#type_annotation#Left AST#primary_type#Left Context 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 Context 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 // 使用关系型存储库的 API 获取 RdbStore AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left relationalStore AST#expression#Right . getRdbStore AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . STORE_CONFIG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right , AST#parameter#Left rdb AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left err 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 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 CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` getRdbStore() failed, err: AST#template_substitution#Left $ { AST#expression#Left err 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#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 将获取到的 RdbStore 存储在实例变量中 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 . rdbStore AST#member_expression#Right = AST#expression#Left rdb AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 执行创建表的 SQL 语句 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 . rdbStore AST#member_expression#Right AST#expression#Right . executeSql 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 . sqlCreateTable 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 AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left 'getRdbStore() finished.' 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#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 /**
* 批量插入数据
* @param data - 要插入的数据数组
* @param callback - 插入成功后的回调函数
*/ AST#method_declaration#Left batchInsert AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left relationalStore . ValuesBucket AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right AST#ERROR#Left [ ] AST#ERROR#Right , AST#parameter#Left callback : AST#type_annotation#Left AST#primary_type#Left Function AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#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#binary_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left callback AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left callback AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left 'undefined' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || 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#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 Logger 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 CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left 'batchInsert() has no callback!' 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 resFlag : 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left valueBuckets : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left relationalStore AST#ERROR#Left . ValuesBucket AST#ERROR#Right [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left data AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 如果 rdbStore 存在,使用关系型存储库的 API 进行批量插入 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rdbStore 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . rdbStore AST#member_expression#Right AST#expression#Right . batchInsert 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 . tableName AST#member_expression#Right AST#expression#Right , AST#expression#Left valueBuckets AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right , AST#parameter#Left ret AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left err 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 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 CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` batchInsert() failed, err: AST#template_substitution#Left $ { AST#expression#Left err 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 resFlag 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#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#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` batchInsert() finished: AST#template_substitution#Left $ { AST#expression#Left ret 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 ret 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#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 插入单条数据
* @param data - 要插入的数据
* @param callback - 插入成功后的回调函数
*/ AST#method_declaration#Left insertData AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left relationalStore . ValuesBucket AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left callback : AST#type_annotation#Left AST#primary_type#Left Function AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#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 this AST#expression#Right . batchInsert AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left data AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left callback 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 /**
* 删除数据
* @param predicates - 删除数据的条件
* @param callback - 删除成功后的回调函数
*/ AST#method_declaration#Left deleteData AST#parameter_list#Left ( AST#parameter#Left predicates : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left relationalStore . RdbPredicates AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left callback : AST#type_annotation#Left AST#primary_type#Left Function AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#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#binary_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left callback AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left callback AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left 'undefined' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || 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#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 Logger 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 CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left 'deleteData() has no callback!' 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 resFlag : 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 如果 rdbStore 存在,使用关系型存储库的 API 进行删除 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rdbStore 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . rdbStore AST#member_expression#Right AST#expression#Right . delete AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left predicates AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right , AST#parameter#Left ret AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left err 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 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 CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` deleteData() failed, err: AST#template_substitution#Left $ { AST#expression#Left err 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 resFlag 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#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#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` deleteData() finished: AST#template_substitution#Left $ { AST#expression#Left ret 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#unary_expression#Left ! AST#expression#Left resFlag AST#expression#Right AST#unary_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#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 更新数据
* @param predicates - 更新数据的条件
* @param data - 要更新的数据
* @param callback - 更新成功后的回调函数
*/ AST#method_declaration#Left updateData AST#parameter_list#Left ( AST#parameter#Left predicates : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left relationalStore . RdbPredicates AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left relationalStore . ValuesBucket AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left callback : AST#type_annotation#Left AST#primary_type#Left Function AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#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#binary_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left callback AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left callback AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left 'undefined' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || 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#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 Logger 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 CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left 'updateData() has no callback!' 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 resFlag : 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left valueBucket : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left relationalStore . ValuesBucket AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left data AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 如果 rdbStore 存在,使用关系型存储库的 API 进行更新 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rdbStore 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . rdbStore AST#member_expression#Right AST#expression#Right . update AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left valueBucket AST#expression#Right , AST#expression#Left predicates AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right , AST#parameter#Left ret AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left err 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 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 CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` updateData() failed, err: AST#template_substitution#Left $ { AST#expression#Left err 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 resFlag 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#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#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` updateData() finished: AST#template_substitution#Left $ { AST#expression#Left ret 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#unary_expression#Left ! AST#expression#Left resFlag AST#expression#Right AST#unary_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#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 查询数据
* @param predicates - 查询数据的条件
* @param callback - 查询成功后的回调函数
*/ AST#method_declaration#Left query AST#parameter_list#Left ( AST#parameter#Left predicates : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left relationalStore . RdbPredicates AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left callback : AST#type_annotation#Left AST#primary_type#Left Function AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#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#binary_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left callback AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left callback AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left 'undefined' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || 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#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 Logger 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 CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left 'query() has no callback!' 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 // 如果 rdbStore 存在,使用关系型存储库的 API 进行查询 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rdbStore 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . rdbStore AST#member_expression#Right AST#expression#Right . query AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left predicates AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . columns AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right , AST#parameter#Left resultSet AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left err 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 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 CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` query() failed, err: AST#template_substitution#Left $ { AST#expression#Left err 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#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#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#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . RDB_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left 'query() finished.' 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 resultSet 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 resultSet AST#expression#Right . close 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#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 } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export default class Rdb {
private rdbStore: relationalStore.RdbStore | null = null;
private tableName: string;
private sqlCreateTable: string;
private columns: Array<string>;
constructor(tableName: string, sqlCreateTable: string, columns: Array<string>) {
this.tableName = tableName;
this.sqlCreateTable = sqlCreateTable;
this.columns = columns;
}
getRdbStore(callback: Function = () => {
}): void {
if (!callback || typeof callback === 'undefined' || callback === undefined) {
Logger.info(CommonConstants.RDB_TAG, 'getRdbStore() has no callback!');
return;
}
if (this.rdbStore !== null) {
Logger.info(CommonConstants.RDB_TAG, 'The rdbStore exists.');
callback();
return;
}
let context: Context = getContext(this) as Context;
relationalStore.getRdbStore(context, CommonConstants.STORE_CONFIG, (err, rdb) => {
if (err) {
Logger.error(CommonConstants.RDB_TAG, `getRdbStore() failed, err: ${err}`);
return;
}
this.rdbStore = rdb;
this.rdbStore.executeSql(this.sqlCreateTable);
Logger.info(CommonConstants.RDB_TAG, 'getRdbStore() finished.');
callback();
});
}
batchInsert(data: relationalStore.ValuesBucket[], callback: Function = () => {
}): void {
if (!callback || typeof callback === 'undefined' || callback === undefined) {
Logger.info(CommonConstants.RDB_TAG, 'batchInsert() has no callback!');
return;
}
let resFlag: boolean = false;
const valueBuckets: relationalStore.ValuesBucket[] = data;
if (this.rdbStore) {
this.rdbStore.batchInsert(this.tableName, valueBuckets, (err, ret) => {
if (err) {
Logger.error(CommonConstants.RDB_TAG, `batchInsert() failed, err: ${err}`);
callback(resFlag);
return;
}
Logger.info(CommonConstants.RDB_TAG, `batchInsert() finished: ${ret}`);
callback(ret);
});
}
}
insertData(data: relationalStore.ValuesBucket, callback: Function = () => {
}): void {
this.batchInsert([data], callback);
}
deleteData(predicates: relationalStore.RdbPredicates, callback: Function = () => {
}): void {
if (!callback || typeof callback === 'undefined' || callback === undefined) {
Logger.info(CommonConstants.RDB_TAG, 'deleteData() has no callback!');
return;
}
let resFlag: boolean = false;
if (this.rdbStore) {
this.rdbStore.delete(predicates, (err, ret) => {
if (err) {
Logger.error(CommonConstants.RDB_TAG, `deleteData() failed, err: ${err}`);
callback(resFlag);
return;
}
Logger.info(CommonConstants.RDB_TAG, `deleteData() finished: ${ret}`);
callback(!resFlag);
});
}
}
updateData(predicates: relationalStore.RdbPredicates, data: relationalStore.ValuesBucket, callback: Function = () => {
}): void {
if (!callback || typeof callback === 'undefined' || callback === undefined) {
Logger.info(CommonConstants.RDB_TAG, 'updateData() has no callback!');
return;
}
let resFlag: boolean = false;
const valueBucket: relationalStore.ValuesBucket = data;
if (this.rdbStore) {
this.rdbStore.update(valueBucket, predicates, (err, ret) => {
if (err) {
Logger.error(CommonConstants.RDB_TAG, `updateData() failed, err: ${err}`);
callback(resFlag);
return;
}
Logger.info(CommonConstants.RDB_TAG, `updateData() finished: ${ret}`);
callback(!resFlag);
});
}
}
query(predicates: relationalStore.RdbPredicates, callback: Function = () => {
}): void {
if (!callback || typeof callback === 'undefined' || callback === undefined) {
Logger.info(CommonConstants.RDB_TAG, 'query() has no callback!');
return;
}
if (this.rdbStore) {
this.rdbStore.query(predicates, this.columns, (err, resultSet) => {
if (err) {
Logger.error(CommonConstants.RDB_TAG, `query() failed, err: ${err}`);
return;
}
Logger.info(CommonConstants.RDB_TAG, 'query() finished.');
,并关闭结果集
callback(resultSet);
resultSet.close();
});
}
}
}
|
https://github.com/tomorrowKreswell/Ledger.git/blob/1f2783ae70b8540d677af8a27f29db1b4089ea69/ledger/entry/src/main/ets/common/database/Rdb.ets#L11-L198
|
3185eaa7a8409a4c24bbf422be8f3a712200ae2c
|
github
|
|
openharmony/arkui_ace_engine
|
30c7d1ee12fbedf0fabece54291d75897e2ad44f
|
examples/Overlay/entry/src/main/ets/pages/components/menu/bindContextMenuTransition.ets
|
arkts
|
BindContextMenuTransitionBuilder
|
Copyright (c) 2025 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.
|
@Builder
export function BindContextMenuTransitionBuilder(name: string, param: Object) {
BindContextMenuTransitionExample()
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function BindContextMenuTransitionBuilder AST#parameter_list#Left ( AST#parameter#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left param : AST#type_annotation#Left AST#primary_type#Left Object 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 BindContextMenuTransitionExample ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#decorated_export_declaration#Right
|
@Builder
export function BindContextMenuTransitionBuilder(name: string, param: Object) {
BindContextMenuTransitionExample()
}
|
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/examples/Overlay/entry/src/main/ets/pages/components/menu/bindContextMenuTransition.ets#L16-L19
|
769ef05261352c0d3d64ae776736c708af21b540
|
gitee
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
ef_crypto/src/main/ets/crypto/encryption/AESSync.ets
|
arkts
|
decodeCBC128
|
解密-CBC模式-128位
@param str 加密的字符串
@param aesKey AES密钥
@param iv iv偏移量字符串
@param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式
@param dataCoding 入参字符串编码方式(hex/base64) - 不传默认为base64
@returns
|
static decodeCBC128(str: string, aesKey: string, iv: string,
keyCoding: buffer.BufferEncoding, dataCoding: buffer.BufferEncoding = 'base64'): string {
return CryptoSyncUtil.decodeCBC(str, aesKey, iv, 'AES128', 'AES128|CBC|PKCS7', 128, keyCoding, dataCoding);
}
|
AST#method_declaration#Left static decodeCBC128 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#Left iv : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left keyCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left dataCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'base64' AST#expression#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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CryptoSyncUtil AST#expression#Right . decodeCBC 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 iv AST#expression#Right , AST#expression#Left 'AES128' AST#expression#Right , AST#expression#Left 'AES128|CBC|PKCS7' AST#expression#Right , AST#expression#Left 128 AST#expression#Right , AST#expression#Left keyCoding AST#expression#Right , AST#expression#Left dataCoding 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 decodeCBC128(str: string, aesKey: string, iv: string,
keyCoding: buffer.BufferEncoding, dataCoding: buffer.BufferEncoding = 'base64'): string {
return CryptoSyncUtil.decodeCBC(str, aesKey, iv, 'AES128', 'AES128|CBC|PKCS7', 128, keyCoding, dataCoding);
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto/src/main/ets/crypto/encryption/AESSync.ets#L244-L247
|
960e2013063b06094cec6e4c498275f755d94591
|
gitee
|
YShelter/Accouting_ArkTS.git
|
8c663c85f2c11738d4eabf269c23dc1ec84eb013
|
entry/src/main/ets/view/Detail/DetailTopComponent.ets
|
arkts
|
DetailTopView
|
明细页展示结余信息
|
@Component
@Preview
export default struct DetailTopView {
@Link homeStore: HomeStore;
@Link detailType: string;
build() {
Row() {
Column() {
Row() {
Text(this.getTitle() + '结余')
.fontSize(Const.DEFAULT_24)
Text('¥ ' + this.homeStore.getCustomBalance())
.fontSize(Const.DEFAULT_24)
.fontColor('rgba(255, 0, 159, 1.00)')
}
.justifyContent(FlexAlign.SpaceBetween)
.width(Const.THOUSANDTH_900)
.layoutWeight(2)
Row() {
Text(this.getTitle() + '支出')
.width(Const.THOUSANDTH_200)
.fontSize(Const.DEFAULT_16)
.fontColor(Color.Gray)
Row() {
Row()
.width(this.getExpense('expense'))
.height(Const.DEFAULT_6)
.backgroundColor('rgba(255, 195, 0, 1.00)')
.borderRadius(Const.BORDER_RADIUS_PERCENT_50)
}
.backgroundColor('#F1F3F5')
.width(Const.THOUSANDTH_50)
Text(this.homeStore.getExpense())
.width(Const.THOUSANDTH_200)
.fontSize(Const.DEFAULT_16)
.fontColor(Color.Gray)
.textAlign(TextAlign.End)
}
.justifyContent(FlexAlign.SpaceBetween)
.width(Const.THOUSANDTH_900)
.layoutWeight(1)
Row() {
Text(this.getTitle() + '收入')
.width(Const.THOUSANDTH_200)
.height(Const.DEFAULT_16)
.fontSize(Const.DEFAULT_16)
.fontColor(Color.Gray)
Row() {
Row()
.width(this.getExpense('income'))
.height(Const.DEFAULT_6)
.backgroundColor('rgba(255, 62, 62, 1.00)')
.borderRadius(Const.BORDER_RADIUS_PERCENT_50)
}
.backgroundColor('#F1F3F5')
.width(Const.THOUSANDTH_500)
Text(this.homeStore.getIncome())
.width(Const.THOUSANDTH_200)
.fontSize(Const.DEFAULT_16)
.fontColor(Color.Gray)
.textAlign(TextAlign.End)
}
.justifyContent(FlexAlign.SpaceBetween)
.width(Const.THOUSANDTH_900)
.layoutWeight(1)
}
.height(Const.THOUSANDTH_1000)
.borderRadius($r('app.float.default_24'))
.backgroundColor($r('app.color.white'))
.margin({top: Const.DEFAULT_56})
.width(Const.THOUSANDTH_1000)
.border({
radius: Const.DEFAULT_24,
color: Color.Black,
width: Const.DEFAULT_2
})
}
.width(Const.THOUSANDTH_1000)
.height(Const.THOUSANDTH_300)
.padding(Const.THOUSANDTH_50)
.justifyContent(FlexAlign.End)
.backgroundImagePosition({x: 0, y: 0})
.backgroundImage($r('app.media.home_background'))
.backgroundImageSize({ width: Const.THOUSANDTH_1000, height: Const.THOUSANDTH_1000 })
}
getTitle() {
switch (this.detailType) {
case DetailType[0]:
return '本月'
break;
case DetailType[1]:
return '本年'
break;
case DetailType[2]:
return '总'
break;
case DetailType[3]:
return ''
break;
default:
return ''
break;
}
}
getExpense(type: string): string {
let expense:number = parseInt(this.homeStore.getExpense());
let income:number = parseInt(this.homeStore.getIncome());
let sum:number = expense + income;
if (type === 'expense') {
let length = (expense / sum) * 100;
return length.toFixed(0)+'%';
}
else if (type === 'income') {
let length = (income / sum) * 100;
return length.toFixed(0)+'%';
}
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right AST#decorator#Left @ Preview AST#decorator#Right export default struct DetailTopView AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Link AST#decorator#Right homeStore : AST#type_annotation#Left AST#primary_type#Left HomeStore AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Link AST#decorator#Right detailType : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_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 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 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#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getTitle 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#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . DEFAULT_24 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 Text ( 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#binary_expression#Left AST#expression#Left '¥ ' AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . homeStore AST#member_expression#Right AST#expression#Right . getCustomBalance AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . DEFAULT_24 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left 'rgba(255, 0, 159, 1.00)' 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#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceBetween AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . THOUSANDTH_900 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 2 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 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#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getTitle 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#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . THOUSANDTH_200 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . DEFAULT_16 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Gray 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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getExpense AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'expense' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . DEFAULT_6 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 'rgba(255, 195, 0, 1.00)' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . BORDER_RADIUS_PERCENT_50 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#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#F1F3F5' AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . THOUSANDTH_50 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#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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . homeStore AST#member_expression#Right AST#expression#Right . getExpense AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . THOUSANDTH_200 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . DEFAULT_16 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Gray AST#member_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#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 . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceBetween AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . THOUSANDTH_900 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 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 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#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getTitle 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#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . THOUSANDTH_200 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . DEFAULT_16 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . DEFAULT_16 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Gray 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#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getExpense AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'income' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . DEFAULT_6 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 'rgba(255, 62, 62, 1.00)' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . BORDER_RADIUS_PERCENT_50 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#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#F1F3F5' AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . THOUSANDTH_500 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#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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . homeStore AST#member_expression#Right AST#expression#Right . getIncome AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . THOUSANDTH_200 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . DEFAULT_16 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Gray AST#member_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#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 . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceBetween AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . THOUSANDTH_900 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 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 . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . THOUSANDTH_1000 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.default_24' 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.white' 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#member_expression#Left AST#expression#Left Const AST#expression#Right . DEFAULT_56 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#member_expression#Left AST#expression#Left Const AST#expression#Right . THOUSANDTH_1000 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . border ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . DEFAULT_24 AST#member_expression#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#member_expression#Left AST#expression#Left Color AST#expression#Right . Black AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . DEFAULT_2 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#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . THOUSANDTH_1000 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . THOUSANDTH_300 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . THOUSANDTH_50 AST#member_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 . End AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundImagePosition ( 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#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundImage ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.home_background' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundImageSize ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . THOUSANDTH_1000 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . THOUSANDTH_1000 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#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right AST#method_declaration#Left getTitle 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 switch ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . detailType AST#member_expression#Right AST#expression#Right ) AST#container_content_body#Left { AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left DetailType AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#ERROR#Left : return AST#ERROR#Right AST#expression_statement#Left AST#expression#Left '本月' AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left break AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left DetailType AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#ERROR#Left : return AST#ERROR#Right AST#expression_statement#Left AST#expression#Left '本年' AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left break AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left DetailType AST#expression#Right [ AST#expression#Left 2 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#ERROR#Left : return AST#ERROR#Right AST#expression_statement#Left AST#expression#Left '总' AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left break AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left DetailType AST#expression#Right [ AST#expression#Left 3 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#ERROR#Left : return AST#ERROR#Right AST#expression_statement#Left AST#expression#Left '' AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left break AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left default AST#expression#Right AST#expression_statement#Right AST#ERROR#Left : return AST#ERROR#Right AST#expression_statement#Left AST#expression#Left '' AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left break 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#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left getExpense AST#parameter_list#Left ( AST#parameter#Left type : 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#variable_declaration#Left let AST#variable_declarator#Left expense : 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 parseInt 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 this AST#expression#Right . homeStore AST#member_expression#Right AST#expression#Right . getExpense 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 let AST#variable_declarator#Left income : 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 parseInt 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 this AST#expression#Right . homeStore AST#member_expression#Right AST#expression#Right . getIncome 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 let AST#variable_declarator#Left sum : 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 expense AST#expression#Right + AST#expression#Left income 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 type AST#expression#Right === AST#expression#Left 'expense' 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 length = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left expense AST#expression#Right / AST#expression#Left sum 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#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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left length AST#expression#Right . toFixed AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left '%' AST#expression#Right AST#binary_expression#Right 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 type AST#expression#Right === AST#expression#Left 'income' 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 length = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left income AST#expression#Right / AST#expression#Left sum 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#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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left length AST#expression#Right . toFixed AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left '%' 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#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
@Preview
export default struct DetailTopView {
@Link homeStore: HomeStore;
@Link detailType: string;
build() {
Row() {
Column() {
Row() {
Text(this.getTitle() + '结余')
.fontSize(Const.DEFAULT_24)
Text('¥ ' + this.homeStore.getCustomBalance())
.fontSize(Const.DEFAULT_24)
.fontColor('rgba(255, 0, 159, 1.00)')
}
.justifyContent(FlexAlign.SpaceBetween)
.width(Const.THOUSANDTH_900)
.layoutWeight(2)
Row() {
Text(this.getTitle() + '支出')
.width(Const.THOUSANDTH_200)
.fontSize(Const.DEFAULT_16)
.fontColor(Color.Gray)
Row() {
Row()
.width(this.getExpense('expense'))
.height(Const.DEFAULT_6)
.backgroundColor('rgba(255, 195, 0, 1.00)')
.borderRadius(Const.BORDER_RADIUS_PERCENT_50)
}
.backgroundColor('#F1F3F5')
.width(Const.THOUSANDTH_50)
Text(this.homeStore.getExpense())
.width(Const.THOUSANDTH_200)
.fontSize(Const.DEFAULT_16)
.fontColor(Color.Gray)
.textAlign(TextAlign.End)
}
.justifyContent(FlexAlign.SpaceBetween)
.width(Const.THOUSANDTH_900)
.layoutWeight(1)
Row() {
Text(this.getTitle() + '收入')
.width(Const.THOUSANDTH_200)
.height(Const.DEFAULT_16)
.fontSize(Const.DEFAULT_16)
.fontColor(Color.Gray)
Row() {
Row()
.width(this.getExpense('income'))
.height(Const.DEFAULT_6)
.backgroundColor('rgba(255, 62, 62, 1.00)')
.borderRadius(Const.BORDER_RADIUS_PERCENT_50)
}
.backgroundColor('#F1F3F5')
.width(Const.THOUSANDTH_500)
Text(this.homeStore.getIncome())
.width(Const.THOUSANDTH_200)
.fontSize(Const.DEFAULT_16)
.fontColor(Color.Gray)
.textAlign(TextAlign.End)
}
.justifyContent(FlexAlign.SpaceBetween)
.width(Const.THOUSANDTH_900)
.layoutWeight(1)
}
.height(Const.THOUSANDTH_1000)
.borderRadius($r('app.float.default_24'))
.backgroundColor($r('app.color.white'))
.margin({top: Const.DEFAULT_56})
.width(Const.THOUSANDTH_1000)
.border({
radius: Const.DEFAULT_24,
color: Color.Black,
width: Const.DEFAULT_2
})
}
.width(Const.THOUSANDTH_1000)
.height(Const.THOUSANDTH_300)
.padding(Const.THOUSANDTH_50)
.justifyContent(FlexAlign.End)
.backgroundImagePosition({x: 0, y: 0})
.backgroundImage($r('app.media.home_background'))
.backgroundImageSize({ width: Const.THOUSANDTH_1000, height: Const.THOUSANDTH_1000 })
}
getTitle() {
switch (this.detailType) {
case DetailType[0]:
return '本月'
break;
case DetailType[1]:
return '本年'
break;
case DetailType[2]:
return '总'
break;
case DetailType[3]:
return ''
break;
default:
return ''
break;
}
}
getExpense(type: string): string {
let expense:number = parseInt(this.homeStore.getExpense());
let income:number = parseInt(this.homeStore.getIncome());
let sum:number = expense + income;
if (type === 'expense') {
let length = (expense / sum) * 100;
return length.toFixed(0)+'%';
}
else if (type === 'income') {
let length = (income / sum) * 100;
return length.toFixed(0)+'%';
}
}
}
|
https://github.com/YShelter/Accouting_ArkTS.git/blob/8c663c85f2c11738d4eabf269c23dc1ec84eb013/entry/src/main/ets/view/Detail/DetailTopComponent.ets#L8-L137
|
6fcd856fd6cb04fa68f8ac34d4bccc25e99b84be
|
github
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/common/types/GreetingTypes.ets
|
arkts
|
祝福语统计接口
|
export interface GreetingStatistics {
total: number;
totalGenerated: number;
totalUsed: number;
averageRating: number;
byStyle: Record<string, number>;
byOccasion: Record<string, number>;
byLanguage: Record<string, number>;
customCount: number;
presetCount: number;
popularGreetings: Greeting[];
topRatedGreetings: Greeting[];
popularStyles: string[];
popularOccasions: string[];
recentActivity: GreetingHistory[];
mostUsedGreetings: Greeting[];
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface GreetingStatistics AST#object_type#Left { AST#type_member#Left total : 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 totalGenerated : 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 totalUsed : 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 averageRating : 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 byStyle : 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 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#type_member#Right ; AST#type_member#Left byOccasion : 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 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#type_member#Right ; AST#type_member#Left byLanguage : 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 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#type_member#Right ; AST#type_member#Left customCount : 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 presetCount : 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 popularGreetings : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Greeting [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left topRatedGreetings : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Greeting [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left popularStyles : 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#type_member#Left popularOccasions : 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#type_member#Left recentActivity : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left GreetingHistory [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left mostUsedGreetings : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Greeting [ ] 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 GreetingStatistics {
total: number;
totalGenerated: number;
totalUsed: number;
averageRating: number;
byStyle: Record<string, number>;
byOccasion: Record<string, number>;
byLanguage: Record<string, number>;
customCount: number;
presetCount: number;
popularGreetings: Greeting[];
topRatedGreetings: Greeting[];
popularStyles: string[];
popularOccasions: string[];
recentActivity: GreetingHistory[];
mostUsedGreetings: Greeting[];
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/GreetingTypes.ets#L240-L256
|
45ed3027ee4997f017977854e545f81d52e7a9e7
|
github
|
|
wangjinyuan/JS-TS-ArkTS-database.git
|
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
|
npm/alprazolamdiv/11.5.1/package/src/client/websocket/packets/handlers/ChannelPinsUpdate.ets
|
arkts
|
handle
|
应用约束:1. 强制使用静态类型,明确方法参数类型
|
handle(packet: Packet): void {
const client = this.packetManager.client;
const data = packet.d;
// 应用约束:1. 强制使用静态类型,添加类型断言
const channel = client.channels.get(data.channel_id) as Channel | undefined;
// 应用约束:32. 限制一元运算符使用,显式转换日期
const timeStr = data.last_pin_timestamp ? data.last_pin_timestamp : '';
const time = timeStr ? new Date(timeStr) : null;
if (channel && time) {
// 应用约束:2. 禁止运行时变更对象布局,使用合法属性赋值
channel.lastPinTimestamp = time.getTime();
// 应用约束:1. 强制使用静态类型,事件参数保持类型一致
client.emit(Constants.Events.CHANNEL_PINS_UPDATE, channel, time);
}
}
|
AST#method_declaration#Left handle AST#parameter_list#Left ( AST#parameter#Left packet : AST#type_annotation#Left AST#primary_type#Left Packet 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 const AST#variable_declarator#Left client = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . packetManager AST#member_expression#Right AST#expression#Right . client 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 data = AST#expression#Left AST#member_expression#Left AST#expression#Left packet AST#expression#Right . d AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 应用约束:1. 强制使用静态类型,添加类型断言 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left channel = AST#expression#Left AST#as_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 client AST#expression#Right . channels AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . channel_id AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Channel AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 应用约束:32. 限制一元运算符使用,显式转换日期 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left timeStr = AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . last_pin_timestamp AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . last_pin_timestamp AST#member_expression#Right AST#expression#Right : AST#expression#Left '' 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 time = AST#expression#Left AST#conditional_expression#Left AST#expression#Left timeStr AST#expression#Right ? 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 timeStr AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left AST#null_literal#Left null AST#null_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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left channel AST#expression#Right && AST#expression#Left time AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // 应用约束:2. 禁止运行时变更对象布局,使用合法属性赋值 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left channel AST#expression#Right . lastPinTimestamp AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left time 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#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 应用约束:1. 强制使用静态类型,事件参数保持类型一致 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left client AST#expression#Right . emit 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 Constants AST#expression#Right . Events AST#member_expression#Right AST#expression#Right . CHANNEL_PINS_UPDATE AST#member_expression#Right AST#expression#Right , AST#expression#Left channel AST#expression#Right , AST#expression#Left time 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#method_declaration#Right
|
handle(packet: Packet): void {
const client = this.packetManager.client;
const data = packet.d;
const channel = client.channels.get(data.channel_id) as Channel | undefined;
const timeStr = data.last_pin_timestamp ? data.last_pin_timestamp : '';
const time = timeStr ? new Date(timeStr) : null;
if (channel && time) {
channel.lastPinTimestamp = time.getTime();
client.emit(Constants.Events.CHANNEL_PINS_UPDATE, channel, time);
}
}
|
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/client/websocket/packets/handlers/ChannelPinsUpdate.ets#L15-L33
|
e534c0c0363c525272ed8a354331dafde5735b99
|
github
|
bigbear20240612/planner_build-.git
|
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
|
entry/src/main/ets/common/utils/DateUtils.ets
|
arkts
|
getMonthDates
|
获取本月的日期数组
@returns 本月所有日期数组
|
static getMonthDates(): Date[] {
const monthStart = DateUtils.getMonthStart();
const monthEnd = new Date(monthStart.getFullYear(), monthStart.getMonth() + 1, 0);
const dates: Date[] = [];
for (let i = 1; i <= monthEnd.getDate(); i++) {
dates.push(new Date(monthStart.getFullYear(), monthStart.getMonth(), i));
}
return dates;
}
|
AST#method_declaration#Left static getMonthDates AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Date [ ] 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 monthStart = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateUtils AST#expression#Right . getMonthStart 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 monthEnd = 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left monthStart 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 monthStart 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 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 dates : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Date [ ] 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#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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right <= AST#expression#Left monthEnd AST#expression#Right AST#binary_expression#Right 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#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 dates AST#expression#Right . push 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 Date 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 monthStart 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left monthStart 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 i 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#return_statement#Left return AST#expression#Left dates AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static getMonthDates(): Date[] {
const monthStart = DateUtils.getMonthStart();
const monthEnd = new Date(monthStart.getFullYear(), monthStart.getMonth() + 1, 0);
const dates: Date[] = [];
for (let i = 1; i <= monthEnd.getDate(); i++) {
dates.push(new Date(monthStart.getFullYear(), monthStart.getMonth(), i));
}
return dates;
}
|
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/common/utils/DateUtils.ets#L178-L188
|
ad30c4f4508bbe025c9d6a2b4f567ffeae822619
|
github
|
openharmony-tpc/ImageKnife
|
bc55de9e2edd79ed4646ce37177ad94b432874f7
|
library/src/main/ets/utils/FileUtils.ets
|
arkts
|
writeData
|
异步向path写入数据
@param path 文件绝对路径
@param content 文件内容
|
async writeData(path: string, content: ArrayBuffer | string): Promise<boolean> {
try {
let fd = (await fs.open(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE)).fd
let stat = await fs.stat(path)
await fs.write(fd, content, { offset: stat.size })
await fs.close(fd)
return true
}
catch (err) {
LogUtil.error('FileUtils writeData failed: err msg=' + err.message + ' err code=' + err.code);
return false
}
}
|
AST#method_declaration#Left async writeData 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#Left content : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ArrayBuffer AST#primary_type#Right | AST#primary_type#Left string 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#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#variable_declaration#Left let AST#variable_declarator#Left fd = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#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 fs AST#expression#Right AST#await_expression#Right AST#expression#Right . open AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left path AST#expression#Right , AST#expression#Left AST#member_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#member_expression#Left AST#expression#Left fs AST#expression#Right . OpenMode AST#member_expression#Right AST#expression#Right . READ_WRITE AST#member_expression#Right AST#expression#Right | AST#expression#Left fs AST#expression#Right AST#binary_expression#Right AST#expression#Right . OpenMode AST#member_expression#Right AST#expression#Right . CREATE AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . fd 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 stat = 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 fs AST#expression#Right AST#await_expression#Right AST#expression#Right . stat 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#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 fs AST#expression#Right AST#await_expression#Right AST#expression#Right . write AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left fd AST#expression#Right , AST#expression#Left content AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left offset AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left stat AST#expression#Right . size 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#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 fs AST#expression#Right AST#await_expression#Right AST#expression#Right . close AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left fd 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 LogUtil 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 'FileUtils writeData failed: err msg=' 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#expression#Left ' err code=' 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#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 writeData(path: string, content: ArrayBuffer | string): Promise<boolean> {
try {
let fd = (await fs.open(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE)).fd
let stat = await fs.stat(path)
await fs.write(fd, content, { offset: stat.size })
await fs.close(fd)
return true
}
catch (err) {
LogUtil.error('FileUtils writeData failed: err msg=' + err.message + ' err code=' + err.code);
return false
}
}
|
https://github.com/openharmony-tpc/ImageKnife/blob/bc55de9e2edd79ed4646ce37177ad94b432874f7/library/src/main/ets/utils/FileUtils.ets#L93-L105
|
67648b066c5c3c7c0365f577b4aef522e9c918ea
|
gitee
|
Joker-x-dev/HarmonyKit.git
|
f97197ce157df7f303244fba42e34918306dfb08
|
core/state/src/main/ets/UserState.ets
|
arkts
|
getUserId
|
获取当前用户 ID
@returns {number | null} 用户 ID,未登录返回 null
|
getUserId(): number | null {
return this.userInfo?.id ?? null;
}
|
AST#method_declaration#Left getUserId AST#parameter_list#Left ( ) AST#parameter_list#Right : 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#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#member_expression#Left AST#expression#Left this AST#expression#Right . userInfo AST#member_expression#Right AST#expression#Right ?. id 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
getUserId(): number | null {
return this.userInfo?.id ?? null;
}
|
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/state/src/main/ets/UserState.ets#L138-L140
|
924afe6d6e974cd411e4ad86088b81fd7ceded4a
|
github
|
wenfujing/honms-super-market.git
|
0858abecd8be5db7b8dcf88dcd77b7c66d37517a
|
common/src/main/ets/utils/Utils.ets
|
arkts
|
Format date.
@param timestamp time
@param format = "yyyy-mm-dd"
@returns res
|
export function formatDate(timestamp: number, format = 'yyyy-mm-dd') {
let res = "";
try {
const date = new Date(timestamp);
const opt: Opt = {
yy: date.getFullYear().toString(),
mm: (date.getMonth() + 1).toString(),
dd: date.getDate().toString(),
HH: date.getHours().toString(),
MM: date.getMinutes().toString(),
SS: date.getSeconds().toString(),
};
const regKeys: string[] = ['y+', 'm+', 'd+', 'H+', 'M+', 'S+'];
for (let i = 0; i < regKeys.length; i++) {
const regKey = regKeys[i];
const reg = new RegExp(regKey);
let ret = reg.exec(format);
if (ret) {
switch (regKey) {
case 'y+':
format = format.replace(reg, ret.length === 1 ? opt.yy : opt.yy.padStart(ret.length, "0"));
case 'm+':
format = format.replace(reg, ret.length === 1 ? opt.mm : opt.mm.padStart(ret.length, "0"));
case 'd+':
format = format.replace(reg, ret.length === 1 ? opt.dd : opt.dd.padStart(ret.length, "0"));
case 'H+':
format = format.replace(reg, ret.length === 1 ? opt.HH : opt.HH.padStart(ret.length, "0"));
case 'M+':
format = format.replace(reg, ret.length === 1 ? opt.MM : opt.MM.padStart(ret.length, "0"));
case 'S+':
format = format.replace(reg, ret.length === 1 ? opt.SS : opt.SS.padStart(ret.length, "0"));
}
}
}
res = format;
} catch (error) {
Logger.error("ERROR formatDate" + error);
}
return res;
}
|
AST#export_declaration#Left export AST#function_declaration#Left function formatDate AST#parameter_list#Left ( AST#parameter#Left timestamp : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left format = AST#expression#Left 'yyyy-mm-dd' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left res = AST#expression#Left "" 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 const AST#variable_declarator#Left date = 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 timestamp 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 opt : AST#type_annotation#Left AST#primary_type#Left Opt AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left yy 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#member_expression#Left AST#expression#Left date 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 . toString 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 mm AST#property_name#Right : 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date 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#parenthesized_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#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left dd 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#member_expression#Left AST#expression#Left date 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 . toString 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 HH 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#member_expression#Left AST#expression#Left date AST#expression#Right . getHours 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#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left MM 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#member_expression#Left AST#expression#Left date AST#expression#Right . getMinutes 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#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left SS 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#member_expression#Left AST#expression#Left date AST#expression#Right . getSeconds 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#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#variable_declaration#Left const AST#variable_declarator#Left regKeys : 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 'y+' AST#expression#Right , AST#expression#Left 'm+' AST#expression#Right , AST#expression#Left 'd+' AST#expression#Right , AST#expression#Left 'H+' AST#expression#Right , AST#expression#Left 'M+' AST#expression#Right , AST#expression#Left 'S+' 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 regKeys 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 regKey = AST#expression#Left AST#subscript_expression#Left AST#expression#Left regKeys AST#expression#Right [ AST#expression#Left i 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 const AST#variable_declarator#Left reg = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left RegExp AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left regKey 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 ret = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left reg AST#expression#Right . exec AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left format 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 ret AST#expression#Right ) AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left switch AST#property_name#Right AST#parameter_list#Left ( AST#parameter#Left regKey AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { 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 'y+' 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#assignment_expression#Left format = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left format AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left reg AST#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#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ret 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#expression#Left AST#member_expression#Left AST#expression#Left opt AST#expression#Right . yy AST#member_expression#Right AST#expression#Right : AST#expression#Left opt AST#expression#Right AST#conditional_expression#Right AST#expression#Right . yy AST#member_expression#Right AST#expression#Right . padStart AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left ret AST#expression#Right . length AST#member_expression#Right AST#expression#Right , AST#expression#Left "0" 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#assignment_expression#Right AST#expression#Right ; AST#expression_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 'm+' 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#assignment_expression#Left format = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left format AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left reg AST#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#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ret 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#expression#Left AST#member_expression#Left AST#expression#Left opt AST#expression#Right . mm AST#member_expression#Right AST#expression#Right : AST#expression#Left opt AST#expression#Right AST#conditional_expression#Right AST#expression#Right . mm AST#member_expression#Right AST#expression#Right . padStart AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left ret AST#expression#Right . length AST#member_expression#Right AST#expression#Right , AST#expression#Left "0" 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#assignment_expression#Right AST#expression#Right ; AST#expression_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 'd+' 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#assignment_expression#Left format = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left format AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left reg AST#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#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ret 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#expression#Left AST#member_expression#Left AST#expression#Left opt AST#expression#Right . dd AST#member_expression#Right AST#expression#Right : AST#expression#Left opt AST#expression#Right AST#conditional_expression#Right AST#expression#Right . dd AST#member_expression#Right AST#expression#Right . padStart AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left ret AST#expression#Right . length AST#member_expression#Right AST#expression#Right , AST#expression#Left "0" 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#assignment_expression#Right AST#expression#Right ; AST#expression_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 'H+' 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#assignment_expression#Left format = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left format AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left reg AST#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#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ret 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#expression#Left AST#member_expression#Left AST#expression#Left opt AST#expression#Right . HH AST#member_expression#Right AST#expression#Right : AST#expression#Left opt AST#expression#Right AST#conditional_expression#Right AST#expression#Right . HH AST#member_expression#Right AST#expression#Right . padStart AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left ret AST#expression#Right . length AST#member_expression#Right AST#expression#Right , AST#expression#Left "0" 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#assignment_expression#Right AST#expression#Right ; AST#expression_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 'M+' 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#assignment_expression#Left format = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left format AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left reg AST#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#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ret 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#expression#Left AST#member_expression#Left AST#expression#Left opt AST#expression#Right . MM AST#member_expression#Right AST#expression#Right : AST#expression#Left opt AST#expression#Right AST#conditional_expression#Right AST#expression#Right . MM AST#member_expression#Right AST#expression#Right . padStart AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left ret AST#expression#Right . length AST#member_expression#Right AST#expression#Right , AST#expression#Left "0" 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#assignment_expression#Right AST#expression#Right ; AST#expression_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 'S+' 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#assignment_expression#Left format = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left format AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left reg AST#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#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ret 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#expression#Left AST#member_expression#Left AST#expression#Left opt AST#expression#Right . SS AST#member_expression#Right AST#expression#Right : AST#expression#Left opt AST#expression#Right AST#conditional_expression#Right AST#expression#Right . SS AST#member_expression#Right AST#expression#Right . padStart AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left ret AST#expression#Right . length AST#member_expression#Right AST#expression#Right , AST#expression#Left "0" 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#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#if_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#assignment_expression#Left res = AST#expression#Left format 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 Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left "ERROR formatDate" AST#expression#Right + AST#expression#Left error 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#catch_clause#Right AST#try_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left res AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export function formatDate(timestamp: number, format = 'yyyy-mm-dd') {
let res = "";
try {
const date = new Date(timestamp);
const opt: Opt = {
yy: date.getFullYear().toString(),
mm: (date.getMonth() + 1).toString(),
dd: date.getDate().toString(),
HH: date.getHours().toString(),
MM: date.getMinutes().toString(),
SS: date.getSeconds().toString(),
};
const regKeys: string[] = ['y+', 'm+', 'd+', 'H+', 'M+', 'S+'];
for (let i = 0; i < regKeys.length; i++) {
const regKey = regKeys[i];
const reg = new RegExp(regKey);
let ret = reg.exec(format);
if (ret) {
switch (regKey) {
case 'y+':
format = format.replace(reg, ret.length === 1 ? opt.yy : opt.yy.padStart(ret.length, "0"));
case 'm+':
format = format.replace(reg, ret.length === 1 ? opt.mm : opt.mm.padStart(ret.length, "0"));
case 'd+':
format = format.replace(reg, ret.length === 1 ? opt.dd : opt.dd.padStart(ret.length, "0"));
case 'H+':
format = format.replace(reg, ret.length === 1 ? opt.HH : opt.HH.padStart(ret.length, "0"));
case 'M+':
format = format.replace(reg, ret.length === 1 ? opt.MM : opt.MM.padStart(ret.length, "0"));
case 'S+':
format = format.replace(reg, ret.length === 1 ? opt.SS : opt.SS.padStart(ret.length, "0"));
}
}
}
res = format;
} catch (error) {
Logger.error("ERROR formatDate" + error);
}
return res;
}
|
https://github.com/wenfujing/honms-super-market.git/blob/0858abecd8be5db7b8dcf88dcd77b7c66d37517a/common/src/main/ets/utils/Utils.ets#L13-L53
|
84df89b0121b1880d914e8eeb7acb48bdae66afe
|
github
|
|
openharmony-tpc/ohos_mpchart
|
4fb43a7137320ef2fee2634598f53d93975dfb4a
|
library/src/main/ets/components/data/PieDataSet.ets
|
arkts
|
isUsingSliceColorAsValueLineColor
|
This method is deprecated.
Use isUseValueColorForLineEnabled() instead.
@Deprecated
|
public isUsingSliceColorAsValueLineColor(): boolean {
return this.isUseValueColorForLineEnabled();
}
|
AST#method_declaration#Left public isUsingSliceColorAsValueLineColor AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isUseValueColorForLineEnabled 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
|
public isUsingSliceColorAsValueLineColor(): boolean {
return this.isUseValueColorForLineEnabled();
}
|
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/data/PieDataSet.ets#L165-L167
|
d051a7c86e228faeaf65dd16f3721e0526439032
|
gitee
|
waylau/harmonyos-tutorial
|
74e23dfa769317f8f057cc77c2d09f0b1f2e0773
|
samples/ArkUIWantOpenManageApplications/entry/src/main/ets/pages/Index.ets
|
arkts
|
implicitStartAbility
|
隐示启动Ability
|
async implicitStartAbility() {
try {
let want = {
// 调用应用管理
"action": wantConstant.Action.ACTION_MANAGE_APPLICATIONS_SETTINGS
}
let context = getContext(this) as context.AbilityContext;
await context.startAbility(want)
console.info(`implicit start ability succeed`)
} catch (error) {
console.info(`implicit start ability failed with ${error.code}`)
}
}
|
AST#method_declaration#Left async implicitStartAbility 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 want = 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 wantConstant AST#expression#Right . Action AST#member_expression#Right AST#expression#Right . ACTION_MANAGE_APPLICATIONS_SETTINGS AST#member_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#variable_declaration#Left let AST#variable_declarator#Left context = 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 context . AbilityContext 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 AST#await_expression#Left await AST#expression#Left context AST#expression#Right AST#await_expression#Right AST#expression#Right . startAbility AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left want 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#template_literal#Left ` implicit start ability succeed ` 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 . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` implicit start ability failed with 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 ` 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 implicitStartAbility() {
try {
let want = {
"action": wantConstant.Action.ACTION_MANAGE_APPLICATIONS_SETTINGS
}
let context = getContext(this) as context.AbilityContext;
await context.startAbility(want)
console.info(`implicit start ability succeed`)
} catch (error) {
console.info(`implicit start ability failed with ${error.code}`)
}
}
|
https://github.com/waylau/harmonyos-tutorial/blob/74e23dfa769317f8f057cc77c2d09f0b1f2e0773/samples/ArkUIWantOpenManageApplications/entry/src/main/ets/pages/Index.ets#L23-L35
|
e0949b1b0ce66df53369c36d07cbdb0e951865ff
|
gitee
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/CharUtil.ets
|
arkts
|
isIdeograph
|
判断字符串char是否是表意文字
@param char
@returns
|
static isIdeograph(char: string): boolean {
return i18n.Unicode.isIdeograph(char);
}
|
AST#method_declaration#Left static isIdeograph AST#parameter_list#Left ( AST#parameter#Left char : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#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 AST#member_expression#Left AST#expression#Left i18n AST#expression#Right . Unicode AST#member_expression#Right AST#expression#Right . isIdeograph AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left char 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 isIdeograph(char: string): boolean {
return i18n.Unicode.isIdeograph(char);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/CharUtil.ets#L94-L96
|
cc19a2a105b7f33b57092d36e9bf5fc1281b4925
|
gitee
|
awa_Liny/LinysBrowser_NEXT
|
a5cd96a9aa8114cae4972937f94a8967e55d4a10
|
home/src/main/ets/hosts/bunch_of_history_index.ets
|
arkts
|
search_timestamps
|
Searches in the index_map and return eligible timestamps
@param key the keywords, for example "huawei developers harmony"
@returns number[] of timestamps
|
static search_timestamps(key: string, max?: number) {
let div_keys = divide_string(key);
// console.log("[qwq]" + div_keys.toString());
let ranges: collections.Array<collections.Array<number>> = new collections.Array<collections.Array<number>>();
for (const key of div_keys) {
// Pushes it
ranges.push(bunch_of_history_index.index_map.get(key) || new collections.Array<number>());
// console.log("[awa]" + (bunch_of_history_index.index_map.get(key) || []).toString());
}
// console.log(log_head() + "Found ranges of keys: " + ranges.join(" "));
return bunch_of_history_index.findCommonElements(ranges, max);
}
|
AST#method_declaration#Left static search_timestamps 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#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#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left div_keys = AST#expression#Left AST#call_expression#Left AST#expression#Left divide_string 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 // console.log("[qwq]" + div_keys.toString()); AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left ranges : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left AST#qualified_type#Left collections . Array AST#qualified_type#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left AST#qualified_type#Left collections . Array AST#qualified_type#Right AST#type_arguments#Left < 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#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 AST#new_expression#Left new AST#expression#Left collections AST#expression#Right AST#new_expression#Right AST#expression#Right . Array AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left AST#qualified_type#Left collections . Array AST#qualified_type#Right AST#type_arguments#Left < 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#type_arguments#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 key of AST#expression#Left div_keys AST#expression#Right ) AST#block_statement#Left { // Pushes it AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ranges AST#expression#Right . push 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left bunch_of_history_index AST#expression#Right . index_map AST#member_expression#Right AST#expression#Right . get 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#expression#Left AST#new_expression#Left new AST#expression#Left collections AST#expression#Right AST#new_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . Array AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#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#expression_statement#Right AST#statement#Right // console.log("[awa]" + (bunch_of_history_index.index_map.get(key) || []).toString()); } AST#block_statement#Right AST#for_statement#Right AST#statement#Right // console.log(log_head() + "Found ranges of keys: " + ranges.join(" ")); 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 bunch_of_history_index AST#expression#Right . findCommonElements AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left ranges AST#expression#Right , AST#expression#Left max 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 search_timestamps(key: string, max?: number) {
let div_keys = divide_string(key);
let ranges: collections.Array<collections.Array<number>> = new collections.Array<collections.Array<number>>();
for (const key of div_keys) {
ranges.push(bunch_of_history_index.index_map.get(key) || new collections.Array<number>());
}
return bunch_of_history_index.findCommonElements(ranges, max);
}
|
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/hosts/bunch_of_history_index.ets#L64-L76
|
4587ce0c6dcf2c8c957d9cc1109be0f216740b0b
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/pages/SimpleBirthdayApp.ets
|
arkts
|
buildCalendarDay
|
构建日历日期格子
|
@Builder
buildCalendarDay(week: number, day: number) {
Column({ space: 2 }) {
Text(((week - 1) * 7 + day).toString())
.fontSize(14)
.fontWeight(((week - 1) * 7 + day) === new Date().getDate() ? FontWeight.Bold : FontWeight.Normal)
.fontColor(((week - 1) * 7 + day) === new Date().getDate() ? '#FFFFFF' : (((week - 1) * 7 + day) > 31 ? '#cccccc' : '#333333'))
if ([8, 15, 25].includes((week - 1) * 7 + day)) {
Text('🎂')
.fontSize(8)
}
}
.width('14.28%')
.height(40)
.backgroundColor(((week - 1) * 7 + day) === new Date().getDate() ? '#4ECDC4' : ([8, 15, 25].includes((week - 1) * 7 + day) ? '#fff0f0' : 'transparent'))
.borderRadius(8)
.justifyContent(FlexAlign.Center)
.onClick(() => {
let dayNumber = (week - 1) * 7 + day;
if (dayNumber <= 31) {
promptAction.showToast({
message: [8, 15, 25].includes(dayNumber) ? `${dayNumber}日有生日提醒` : `查看${dayNumber}日详情`,
duration: 1500
});
}
})
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildCalendarDay 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 day : 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 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#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 AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_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 week 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#expression#Left 7 AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left day AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_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#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_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#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_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 week 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#expression#Left 7 AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left day AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right === AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right 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#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right : AST#expression#Left FontWeight AST#expression#Right AST#conditional_expression#Right AST#expression#Right . Normal AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#conditional_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#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_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 week 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#expression#Left 7 AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left day AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right === AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right 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#expression#Left '#FFFFFF' AST#expression#Right : 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#parenthesized_expression#Left ( AST#expression#Left AST#binary_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 week 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#expression#Left 7 AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left day AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right > AST#expression#Left 31 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left '#cccccc' AST#expression#Right : AST#expression#Left '#333333' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#conditional_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#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#array_literal#Left [ AST#expression#Left 8 AST#expression#Right , AST#expression#Left 15 AST#expression#Right , AST#expression#Left 25 AST#expression#Right ] AST#array_literal#Right AST#expression#Right . includes 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#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left week 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#expression#Left 7 AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left day AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_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#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 8 AST#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 . width ( AST#expression#Left '14.28%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#conditional_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#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_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 week 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#expression#Left 7 AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left day AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right === AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right 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#expression#Left '#4ECDC4' AST#expression#Right : AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#array_literal#Left [ AST#expression#Left 8 AST#expression#Right , AST#expression#Left 15 AST#expression#Right , AST#expression#Left 25 AST#expression#Right ] AST#array_literal#Right AST#expression#Right . includes 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#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left week 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#expression#Left 7 AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left day AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ? AST#expression#Left '#fff0f0' AST#expression#Right : AST#expression#Left 'transparent' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 8 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#variable_declaration#Left let AST#variable_declarator#Left dayNumber = AST#expression#Left AST#binary_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 week 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#expression#Left 7 AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left day 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 dayNumber AST#expression#Right <= AST#expression#Left 31 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#conditional_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#array_literal#Left [ AST#expression#Left 8 AST#expression#Right , AST#expression#Left 15 AST#expression#Right , AST#expression#Left 25 AST#expression#Right ] AST#array_literal#Right AST#expression#Right . includes 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#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left dayNumber AST#expression#Right } AST#template_substitution#Right 日有生日提醒 ` AST#template_literal#Right AST#expression#Right : AST#expression#Left AST#template_literal#Left ` 查看 AST#template_substitution#Left $ { AST#expression#Left dayNumber AST#expression#Right } AST#template_substitution#Right 日详情 ` AST#template_literal#Right AST#expression#Right AST#conditional_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 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#if_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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
buildCalendarDay(week: number, day: number) {
Column({ space: 2 }) {
Text(((week - 1) * 7 + day).toString())
.fontSize(14)
.fontWeight(((week - 1) * 7 + day) === new Date().getDate() ? FontWeight.Bold : FontWeight.Normal)
.fontColor(((week - 1) * 7 + day) === new Date().getDate() ? '#FFFFFF' : (((week - 1) * 7 + day) > 31 ? '#cccccc' : '#333333'))
if ([8, 15, 25].includes((week - 1) * 7 + day)) {
Text('🎂')
.fontSize(8)
}
}
.width('14.28%')
.height(40)
.backgroundColor(((week - 1) * 7 + day) === new Date().getDate() ? '#4ECDC4' : ([8, 15, 25].includes((week - 1) * 7 + day) ? '#fff0f0' : 'transparent'))
.borderRadius(8)
.justifyContent(FlexAlign.Center)
.onClick(() => {
let dayNumber = (week - 1) * 7 + day;
if (dayNumber <= 31) {
promptAction.showToast({
message: [8, 15, 25].includes(dayNumber) ? `${dayNumber}日有生日提醒` : `查看${dayNumber}日详情`,
duration: 1500
});
}
})
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/SimpleBirthdayApp.ets#L1285-L1312
|
32a1c68f2b1bb5785e3f3744b1cf5224884403c9
|
github
|
jianguo888/nut-recipes
|
262304b5d2bee2d5f1df4e29c094c9ddd58f9d51
|
entry/src/main/ets/MainAbility/model/processModel.ets
|
arkts
|
Copyright (c) 2021 JianGuo 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 class ProcessData {
pcontent: string //
pic: string //
}
|
AST#export_declaration#Left export AST#class_declaration#Left class ProcessData AST#class_body#Left { AST#ERROR#Left pcontent : string // pic : string AST#ERROR#Right // } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class ProcessData {
pcontent: string
pic: string
}
|
https://github.com/jianguo888/nut-recipes/blob/262304b5d2bee2d5f1df4e29c094c9ddd58f9d51/entry/src/main/ets/MainAbility/model/processModel.ets#L16-L22
|
92e38399d13e0edfb7d51de5636a0802e087dc11
|
gitee
|
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
harmonyos/src/main/ets/services/storage/PreferencesService.ets
|
arkts
|
putString
|
存储字符串值
@param key 键
@param value 值
|
async putString(key: string, value: string): Promise<void> {
try {
this.checkInitialized();
await this.dataPreferences!.put(key, value);
await this.dataPreferences!.flush();
} catch (error) {
const businessError = error as BusinessError;
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to put string: ${businessError.message}`);
throw new Error(businessError.message);
}
}
|
AST#method_declaration#Left async putString 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#Left value : 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 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 this AST#expression#Right . checkInitialized 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#non_null_assertion_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 . dataPreferences AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . put AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right , AST#expression#Left value 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#non_null_assertion_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 . dataPreferences AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_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#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 businessError = 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 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 put string: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left businessError 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#throw_statement#Left throw AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left businessError AST#expression#Right . message AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#throw_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 putString(key: string, value: string): Promise<void> {
try {
this.checkInitialized();
await this.dataPreferences!.put(key, value);
await this.dataPreferences!.flush();
} catch (error) {
const businessError = error as BusinessError;
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to put string: ${businessError.message}`);
throw new Error(businessError.message);
}
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/services/storage/PreferencesService.ets#L64-L74
|
d3836de4b90f220b34937ab0762fe76d6ca14a02
|
github
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/common/components/Language/LanguageManager.ets
|
arkts
|
getCurrentLanguage
|
获取当前实际使用的语言
|
static getCurrentLanguage(): AppLanguage {
try {
// 1️⃣ 优先读取应用设置的首选语言
const appLang = i18n.System.getAppPreferredLanguage();
if (appLang) {
if (appLang.startsWith("zh-Hant")) return AppLanguage.Traditional;
return AppLanguage.Simplified; // 默认简体
}
// 2️⃣ 如果没有设置应用首选语言,则使用系统语言
const systemLang = i18n.System.getSystemLanguage();
if (systemLang.startsWith("zh-Hant")) return AppLanguage.Traditional;
return AppLanguage.Simplified;
} catch (err) {
console.error("LanguageManager.getCurrentLanguage failed: " + (err instanceof Error ? err.message : err));
// 异常情况下返回默认语言
return LanguageManager.getDefault();
}
}
|
AST#method_declaration#Left static getCurrentLanguage AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AppLanguage AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 1️⃣ 优先读取应用设置的首选语言 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left appLang = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left i18n AST#expression#Right . System AST#member_expression#Right AST#expression#Right . getAppPreferredLanguage 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 appLang AST#expression#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 appLang AST#expression#Right . startsWith AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "zh-Hant" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AppLanguage AST#expression#Right . Traditional 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 AppLanguage AST#expression#Right . Simplified AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right // 默认简体 } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 2️⃣ 如果没有设置应用首选语言,则使用系统语言 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left systemLang = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left i18n AST#expression#Right . System AST#member_expression#Right AST#expression#Right . getSystemLanguage 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left systemLang AST#expression#Right . startsWith AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "zh-Hant" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AppLanguage AST#expression#Right . Traditional 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 AppLanguage AST#expression#Right . Simplified AST#member_expression#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#binary_expression#Left AST#expression#Left "LanguageManager.getCurrentLanguage failed: " AST#expression#Right + AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left err AST#expression#Right instanceof AST#expression#Left Error AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right : AST#expression#Left err AST#expression#Right AST#conditional_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#expression_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 LanguageManager AST#expression#Right . getDefault 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#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static getCurrentLanguage(): AppLanguage {
try {
const appLang = i18n.System.getAppPreferredLanguage();
if (appLang) {
if (appLang.startsWith("zh-Hant")) return AppLanguage.Traditional;
return AppLanguage.Simplified;
}
const systemLang = i18n.System.getSystemLanguage();
if (systemLang.startsWith("zh-Hant")) return AppLanguage.Traditional;
return AppLanguage.Simplified;
} catch (err) {
console.error("LanguageManager.getCurrentLanguage failed: " + (err instanceof Error ? err.message : err));
return LanguageManager.getDefault();
}
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/components/Language/LanguageManager.ets#L41-L60
|
e44bc50249425ef0688e855eeda6cf60f26b8e39
|
github
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
ef_ui/src/main/ets/ui/base/PickerUtil.ets
|
arkts
|
selectAudio
|
拉起picker选择音频 - 返回值方式
@returns
|
static async selectAudio(): Promise<Array<string>> {
//创建picker
let context = getContext() as common.UIAbilityContext;
let audioPicker = new picker.AudioViewPicker(context);
//拉起
let list = await audioPicker.select(new picker.AudioSelectOptions());
if (list !== null && list !== undefined) {
return list;
}
return new Array<string>();
}
|
AST#method_declaration#Left static async selectAudio AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array 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#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { //创建picker AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left context = 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#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 audioPicker = 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 picker AST#expression#Right AST#new_expression#Right AST#expression#Right . AudioViewPicker 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //拉起 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left list = 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 audioPicker AST#expression#Right AST#await_expression#Right AST#expression#Right . select 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#new_expression#Left new AST#expression#Left picker AST#expression#Right AST#new_expression#Right AST#expression#Right . AudioSelectOptions 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left list 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#expression#Left AST#binary_expression#Left AST#expression#Left list AST#expression#Right !== AST#expression#Left undefined 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#return_statement#Left return AST#expression#Left list 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#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 string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#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
|
static async selectAudio(): Promise<Array<string>> {
let context = getContext() as common.UIAbilityContext;
let audioPicker = new picker.AudioViewPicker(context);
let list = await audioPicker.select(new picker.AudioSelectOptions());
if (list !== null && list !== undefined) {
return list;
}
return new Array<string>();
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_ui/src/main/ets/ui/base/PickerUtil.ets#L217-L227
|
4fa2965c2328fa71b68bc840358c0e9239f93a60
|
gitee
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/PreviewUtil.ets
|
arkts
|
TODO 文件预览工具类
author: 桃花镇童长老ᥫ᭡
since: 2024/05/01
|
export class PreviewUtil {
/**
* 通过传入文件预览信息,打开预览窗口。1秒内重复调用无效。
* @param previewInfo 文件的预览信息
* @returns
*/
static openPreview(previewInfo: filePreview.PreviewInfo): Promise<void> {
return filePreview.openPreview(AppUtil.getContext(), previewInfo);
}
/**
* 通过传入文件的uri,打开预览窗口。1秒内重复调用无效。
* @param uri 文件的uri
* @returns
*/
static async openPreviewEasy(uri: string): Promise<void> {
const previewInfo = PreviewUtil.generatePreviewInfo(uri);
return filePreview.openPreview(AppUtil.getContext(), previewInfo);
}
/**
* 根据文件的uri判断文件是否可预览
* @param uri 文件的uri
* @returns
*/
static canPreview(uri: string): Promise<boolean> {
return filePreview.canPreview(AppUtil.getContext(), uri);
}
/**
* 判断预览窗口是否已经存在
*/
static hasDisplayed(): Promise<boolean> {
return filePreview.hasDisplayed(AppUtil.getContext());
}
/**
* 关闭预览窗口,仅当预览窗口存在时起效。
*/
static closePreview() {
return filePreview.closePreview(AppUtil.getContext());
}
/**
* 加载预览文件信息。仅当预览窗口存在时起效。
* @param previewInfo 文件的预览信息
* @returns
*/
static loadData(previewInfo: filePreview.PreviewInfo) {
return filePreview.loadData(AppUtil.getContext(), previewInfo);
}
/**
* 加载预览文件信息。仅当预览窗口存在时起效。
* @param uri 文件的uri
* @returns
*/
static async loadDataEasy(uri: string): Promise<void> {
const previewInfo = PreviewUtil.generatePreviewInfo(uri);
return filePreview.loadData(AppUtil.getContext(), previewInfo);
}
/**
* 调用其他应用预览文件
* @param uri 文件的uri
* @param write 是否有写入权限
* @returns
*/
static onSharePreview(uri: string, write: boolean = true): Promise<void> {
return WantUtil.openFile(uri, write);
}
/**
* 根据文件uri构建PreviewInfo
* @param uri 文件的uri
* @returns
*/
static generatePreviewInfo(uri: string): filePreview.PreviewInfo {
const fileName = FileUtil.getFileName(uri);
const fileExtention = FileUtil.getFileExtention(fileName);
const mimeType = PreviewUtil.getMimeType(fileExtention);
let previewInfo: filePreview.PreviewInfo = {
title: fileName,
uri: uri,
mimeType: mimeType
};
return previewInfo;
}
/**
* 根据文件后缀名获取TypeDescriptor(标准化数据类型的描述类)
* @param fileExtention 文件后缀名,例如:html txt doc ts mp3
*/
static getTypeDescriptor(fileExtention: string): uniformTypeDescriptor.TypeDescriptor {
const dataType = uniformTypeDescriptor.getUniformDataTypeByFilenameExtension(`.${fileExtention}`);
const typeDescriptor = uniformTypeDescriptor.getTypeDescriptor(dataType);
return typeDescriptor;
}
/**
* 根据文件后缀名获取文件mimeType
* @param fileExtention 文件后缀名,例如:html txt doc ts mp3
*/
static getMimeType(fileExtention: string): string {
const typeDescriptor = PreviewUtil.getTypeDescriptor(fileExtention);
const mimeTypes = typeDescriptor.mimeTypes;
if (mimeTypes && mimeTypes.length > 0) {
return mimeTypes[0];
} else {
return '*/*';
}
}
/**
* 根据文件后缀名获取对应文件类型的图标
* @param fileExtention 文件后缀名,例如:html txt doc ts mp3
*/
static getIconFileStr(fileExtention: string): string {
const descriptor = PreviewUtil.getTypeDescriptor(fileExtention);
return descriptor.iconFile;
}
/**
* 判断当前设备是否支持文件预览能力
* @returns
*/
static canIUsePreview() {
return canIUse("SystemCapability.FileManagement.FilePreview.Core")
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class PreviewUtil AST#class_body#Left { /**
* 通过传入文件预览信息,打开预览窗口。1秒内重复调用无效。
* @param previewInfo 文件的预览信息
* @returns
*/ AST#method_declaration#Left static openPreview AST#parameter_list#Left ( AST#parameter#Left previewInfo : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left filePreview . PreviewInfo 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 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left filePreview AST#expression#Right . openPreview 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 AppUtil AST#expression#Right . getContext 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 previewInfo 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 /**
* 通过传入文件的uri,打开预览窗口。1秒内重复调用无效。
* @param uri 文件的uri
* @returns
*/ AST#method_declaration#Left static async openPreviewEasy AST#parameter_list#Left ( AST#parameter#Left uri : 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 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 previewInfo = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PreviewUtil AST#expression#Right . generatePreviewInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uri 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left filePreview AST#expression#Right . openPreview 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 AppUtil AST#expression#Right . getContext 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 previewInfo 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 /**
* 根据文件的uri判断文件是否可预览
* @param uri 文件的uri
* @returns
*/ AST#method_declaration#Left static canPreview AST#parameter_list#Left ( AST#parameter#Left uri : 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left filePreview AST#expression#Right . canPreview 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 AppUtil AST#expression#Right . getContext 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 uri 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#method_declaration#Left static hasDisplayed 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left filePreview AST#expression#Right . hasDisplayed 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 AppUtil AST#expression#Right . getContext 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 关闭预览窗口,仅当预览窗口存在时起效。
*/ AST#method_declaration#Left static closePreview AST#parameter_list#Left ( ) AST#parameter_list#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 filePreview AST#expression#Right . closePreview 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 AppUtil AST#expression#Right . getContext 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 加载预览文件信息。仅当预览窗口存在时起效。
* @param previewInfo 文件的预览信息
* @returns
*/ AST#method_declaration#Left static loadData AST#parameter_list#Left ( AST#parameter#Left previewInfo : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left filePreview . PreviewInfo 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left filePreview AST#expression#Right . loadData 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 AppUtil AST#expression#Right . getContext 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 previewInfo 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 uri 文件的uri
* @returns
*/ AST#method_declaration#Left static async loadDataEasy AST#parameter_list#Left ( AST#parameter#Left uri : 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 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 previewInfo = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PreviewUtil AST#expression#Right . generatePreviewInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uri 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left filePreview AST#expression#Right . loadData 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 AppUtil AST#expression#Right . getContext 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 previewInfo 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 uri 文件的uri
* @param write 是否有写入权限
* @returns
*/ AST#method_declaration#Left static onSharePreview AST#parameter_list#Left ( AST#parameter#Left uri : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left write : 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_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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left WantUtil AST#expression#Right . openFile AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uri AST#expression#Right , AST#expression#Left write 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 /**
* 根据文件uri构建PreviewInfo
* @param uri 文件的uri
* @returns
*/ AST#method_declaration#Left static generatePreviewInfo AST#parameter_list#Left ( AST#parameter#Left uri : 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#qualified_type#Left filePreview . PreviewInfo AST#qualified_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 fileName = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtil AST#expression#Right . getFileName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uri 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 fileExtention = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtil AST#expression#Right . getFileExtention AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left fileName 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 mimeType = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PreviewUtil AST#expression#Right . getMimeType AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left fileExtention 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 previewInfo : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left filePreview . PreviewInfo AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left fileName AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left uri AST#property_name#Right : AST#expression#Left uri AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left mimeType AST#property_name#Right : AST#expression#Left mimeType 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#return_statement#Left return AST#expression#Left previewInfo AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 根据文件后缀名获取TypeDescriptor(标准化数据类型的描述类)
* @param fileExtention 文件后缀名,例如:html txt doc ts mp3
*/ AST#method_declaration#Left static getTypeDescriptor AST#parameter_list#Left ( AST#parameter#Left fileExtention : 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#qualified_type#Left uniformTypeDescriptor . TypeDescriptor AST#qualified_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 dataType = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left uniformTypeDescriptor AST#expression#Right . getUniformDataTypeByFilenameExtension AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` . AST#template_substitution#Left $ { AST#expression#Left fileExtention 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#variable_declaration#Left const AST#variable_declarator#Left typeDescriptor = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left uniformTypeDescriptor AST#expression#Right . getTypeDescriptor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left dataType 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 typeDescriptor AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 根据文件后缀名获取文件mimeType
* @param fileExtention 文件后缀名,例如:html txt doc ts mp3
*/ AST#method_declaration#Left static getMimeType AST#parameter_list#Left ( AST#parameter#Left fileExtention : 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#variable_declaration#Left const AST#variable_declarator#Left typeDescriptor = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PreviewUtil AST#expression#Right . getTypeDescriptor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left fileExtention 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 mimeTypes = AST#expression#Left AST#member_expression#Left AST#expression#Left typeDescriptor AST#expression#Right . mimeTypes 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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left mimeTypes AST#expression#Right && AST#expression#Left mimeTypes 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#subscript_expression#Left AST#expression#Left mimeTypes 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 else AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left '*/*' 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 fileExtention 文件后缀名,例如:html txt doc ts mp3
*/ AST#method_declaration#Left static getIconFileStr AST#parameter_list#Left ( AST#parameter#Left fileExtention : 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#variable_declaration#Left const AST#variable_declarator#Left descriptor = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PreviewUtil AST#expression#Right . getTypeDescriptor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left fileExtention 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 descriptor AST#expression#Right . iconFile AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 判断当前设备是否支持文件预览能力
* @returns
*/ AST#method_declaration#Left static canIUsePreview AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left canIUse AST#expression#Right AST#argument_list#Left ( AST#expression#Left "SystemCapability.FileManagement.FilePreview.Core" 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 PreviewUtil {
static openPreview(previewInfo: filePreview.PreviewInfo): Promise<void> {
return filePreview.openPreview(AppUtil.getContext(), previewInfo);
}
static async openPreviewEasy(uri: string): Promise<void> {
const previewInfo = PreviewUtil.generatePreviewInfo(uri);
return filePreview.openPreview(AppUtil.getContext(), previewInfo);
}
static canPreview(uri: string): Promise<boolean> {
return filePreview.canPreview(AppUtil.getContext(), uri);
}
static hasDisplayed(): Promise<boolean> {
return filePreview.hasDisplayed(AppUtil.getContext());
}
static closePreview() {
return filePreview.closePreview(AppUtil.getContext());
}
static loadData(previewInfo: filePreview.PreviewInfo) {
return filePreview.loadData(AppUtil.getContext(), previewInfo);
}
static async loadDataEasy(uri: string): Promise<void> {
const previewInfo = PreviewUtil.generatePreviewInfo(uri);
return filePreview.loadData(AppUtil.getContext(), previewInfo);
}
static onSharePreview(uri: string, write: boolean = true): Promise<void> {
return WantUtil.openFile(uri, write);
}
static generatePreviewInfo(uri: string): filePreview.PreviewInfo {
const fileName = FileUtil.getFileName(uri);
const fileExtention = FileUtil.getFileExtention(fileName);
const mimeType = PreviewUtil.getMimeType(fileExtention);
let previewInfo: filePreview.PreviewInfo = {
title: fileName,
uri: uri,
mimeType: mimeType
};
return previewInfo;
}
static getTypeDescriptor(fileExtention: string): uniformTypeDescriptor.TypeDescriptor {
const dataType = uniformTypeDescriptor.getUniformDataTypeByFilenameExtension(`.${fileExtention}`);
const typeDescriptor = uniformTypeDescriptor.getTypeDescriptor(dataType);
return typeDescriptor;
}
static getMimeType(fileExtention: string): string {
const typeDescriptor = PreviewUtil.getTypeDescriptor(fileExtention);
const mimeTypes = typeDescriptor.mimeTypes;
if (mimeTypes && mimeTypes.length > 0) {
return mimeTypes[0];
} else {
return '*/*';
}
}
static getIconFileStr(fileExtention: string): string {
const descriptor = PreviewUtil.getTypeDescriptor(fileExtention);
return descriptor.iconFile;
}
static canIUsePreview() {
return canIUse("SystemCapability.FileManagement.FilePreview.Core")
}
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/PreviewUtil.ets#L28-L171
|
d2972777c7f8335fc4116a8578b982efda0fe90f
|
gitee
|
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/common/iab/SubscribeManager.ets
|
arkts
|
loadCurrentItem
|
------------------------- 本地偏好读取/保存 ------------------------- 加载当前订阅项
|
private loadCurrentItem(): void {
const pref = this.getPrefs();
if (!pref) return;
const sku = pref.getSync(SubscribeManagerPref.kSku, null) as string | null;
const expDate = pref.getSync(SubscribeManagerPref.kExpiresDate, 0) as number;
const token = pref.getSync(SubscribeManagerPref.kPurchaseToken, null) as string | null;
const platform = pref.getSync(SubscribeManagerPref.kPurchasedPlatform, null) as string | null;
if (sku) {
this.currentItem = new SubscribeItem(sku, expDate, token, platform);
}
}
|
AST#method_declaration#Left private loadCurrentItem AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left pref = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getPrefs 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#unary_expression#Left ! AST#expression#Left pref AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left sku = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left pref AST#expression#Right . getSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left SubscribeManagerPref AST#expression#Right . kSku AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as 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#as_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 expDate = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left pref AST#expression#Right . getSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left SubscribeManagerPref AST#expression#Right . kExpiresDate AST#member_expression#Right AST#expression#Right , AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left token = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left pref AST#expression#Right . getSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left SubscribeManagerPref AST#expression#Right . kPurchaseToken AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as 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#as_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 platform = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left pref AST#expression#Right . getSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left SubscribeManagerPref AST#expression#Right . kPurchasedPlatform AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as 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#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 sku 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 . currentItem AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left SubscribeItem AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sku AST#expression#Right , AST#expression#Left expDate AST#expression#Right , AST#expression#Left token AST#expression#Right , AST#expression#Left platform 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#method_declaration#Right
|
private loadCurrentItem(): void {
const pref = this.getPrefs();
if (!pref) return;
const sku = pref.getSync(SubscribeManagerPref.kSku, null) as string | null;
const expDate = pref.getSync(SubscribeManagerPref.kExpiresDate, 0) as number;
const token = pref.getSync(SubscribeManagerPref.kPurchaseToken, null) as string | null;
const platform = pref.getSync(SubscribeManagerPref.kPurchasedPlatform, null) as string | null;
if (sku) {
this.currentItem = new SubscribeItem(sku, expDate, token, platform);
}
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/iab/SubscribeManager.ets#L77-L89
|
2680ff39be3a5c27940fddd8a8ae60d0ce17c159
|
github
|
liuchao0739/arkTS_universal_starter.git
|
0ca845f5ae0e78db439dc09f712d100c0dd46ed3
|
entry/src/main/ets/localization/I18nManager.ets
|
arkts
|
addResources
|
添加语言资源
|
addResources(language: Language, resources: LanguageResources): void {
this.resources[language] = {
...this.resources[language],
...resources
};
}
|
AST#method_declaration#Left addResources AST#parameter_list#Left ( AST#parameter#Left language : AST#type_annotation#Left AST#primary_type#Left Language AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left resources : AST#type_annotation#Left AST#primary_type#Left LanguageResources 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#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . resources AST#member_expression#Right AST#expression#Right [ AST#expression#Left language AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#ERROR#Left = AST#ERROR#Right AST#expression_statement#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left ... AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . resources AST#member_expression#Right AST#expression#Right [ AST#expression#Left language AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left ... AST#expression#Left resources AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
addResources(language: Language, resources: LanguageResources): void {
this.resources[language] = {
...this.resources[language],
...resources
};
}
|
https://github.com/liuchao0739/arkTS_universal_starter.git/blob/0ca845f5ae0e78db439dc09f712d100c0dd46ed3/entry/src/main/ets/localization/I18nManager.ets#L115-L120
|
cf7f7bc5201437932fed36e80dca37e838d7d319
|
github
|
harmonyos/samples
|
f5d967efaa7666550ee3252d118c3c73a77686f5
|
ETSUI/ListSample/entry/src/main/ets/view/ListAreaComponent.ets
|
arkts
|
ListAreaComponent
|
List area of the main tab content.
|
@Component
export struct ListAreaComponent {
build() {
Column() {
List() {
LazyForEach(PageViewModel.getListDataSource(), (item: ListItemData) => {
ListItem() {
ListItemComponent({ itemInfo: item })
}
.onClick(() => {
router.push({
url: CommonConstants.PAGE_NAME,
params: {
data: item.title
}
});
})
}, item => JSON.stringify(item))
}
.width(CommonConstants.LIST_WIDTH_PERCENT)
.divider({
strokeWidth: $r('app.float.divider_height'),
color: $r('app.color.list_divider'),
startMargin: $r('app.float.list_divider_start_margin'),
endMargin: $r('app.float.list_divider_end_margin')
})
.margin({ bottom: $r('app.float.tab_bar_height') })
}
.width(CommonConstants.COLUMN_WIDTH_PERCENT)
.height(CommonConstants.COLUMN_HEIGHT_PERCENT)
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ListAreaComponent AST#component_body#Left { 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 List ( ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#lazy_for_each_statement#Left LazyForEach ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PageViewModel AST#expression#Right . getListDataSource AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) 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 ListItemData 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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ListItemComponent ( AST#component_parameters#Left { AST#component_parameter#Left itemInfo : AST#expression#Left item 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 . 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 router AST#expression#Right . push 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 AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . PAGE_NAME AST#member_expression#Right 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 data AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . title 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#arrow_function#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 item => 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 item AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#lazy_for_each_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . LIST_WIDTH_PERCENT 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 AST#resource_expression#Left $r ( AST#expression#Left 'app.float.divider_height' AST#expression#Right ) AST#resource_expression#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.list_divider' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left startMargin AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.list_divider_start_margin' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left endMargin AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.list_divider_end_margin' 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 . 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.float.tab_bar_height' 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#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#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . COLUMN_WIDTH_PERCENT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . COLUMN_HEIGHT_PERCENT 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#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct ListAreaComponent {
build() {
Column() {
List() {
LazyForEach(PageViewModel.getListDataSource(), (item: ListItemData) => {
ListItem() {
ListItemComponent({ itemInfo: item })
}
.onClick(() => {
router.push({
url: CommonConstants.PAGE_NAME,
params: {
data: item.title
}
});
})
}, item => JSON.stringify(item))
}
.width(CommonConstants.LIST_WIDTH_PERCENT)
.divider({
strokeWidth: $r('app.float.divider_height'),
color: $r('app.color.list_divider'),
startMargin: $r('app.float.list_divider_start_margin'),
endMargin: $r('app.float.list_divider_end_margin')
})
.margin({ bottom: $r('app.float.tab_bar_height') })
}
.width(CommonConstants.COLUMN_WIDTH_PERCENT)
.height(CommonConstants.COLUMN_HEIGHT_PERCENT)
}
}
|
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/ETSUI/ListSample/entry/src/main/ets/view/ListAreaComponent.ets#L10-L41
|
3a2eb8eae1703443249e14f1ccabb8d1b30a0ff9
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/common/types/CommonTypes.ets
|
arkts
|
映射函数类型
|
export type Mapper<T, R> = (item: T) => R;
|
AST#export_declaration#Left export AST#type_declaration#Left type Mapper AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right , AST#type_parameter#Left R AST#type_parameter#Right > AST#type_parameters#Right = 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 R AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right ; AST#type_declaration#Right AST#export_declaration#Right
|
export type Mapper<T, R> = (item: T) => R;
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/CommonTypes.ets#L261-L261
|
4a891a602759de04588b5c715b181b9b8a4ded77
|
github
|
|
openharmony/interface_sdk-js
|
c349adc73e2ec1f61f6fca489b5af059e3ed6999
|
api/@ohos.arkui.advanced.Filter.d.ets
|
arkts
|
This parameter is used to define the input of each filtering dimension.
@syscap SystemCapability.ArkUI.ArkUI.Full
@since 10
This parameter is used to define the input of each filtering dimension.
@syscap SystemCapability.ArkUI.ArkUI.Full
@atomicservice
@since 11
|
export declare class FilterParams {
/**
* filter item name.
* @type { ResourceStr }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
/**
* filter item name.
* @type { ResourceStr }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/
name: ResourceStr;
/**
* filter options.
* @type { Array<ResourceStr> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
/**
* filter options.
* @type { Array<ResourceStr> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/
options: Array<ResourceStr>;
}
|
AST#export_declaration#Left export AST#ERROR#Left declare AST#ERROR#Right AST#class_declaration#Left class FilterParams AST#class_body#Left { /**
* filter item name.
* @type { ResourceStr }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/ /**
* filter item name.
* @type { ResourceStr }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/ AST#property_declaration#Left name : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* filter options.
* @type { Array<ResourceStr> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/ /**
* filter options.
* @type { Array<ResourceStr> }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/ AST#property_declaration#Left options : 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 ResourceStr 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#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export declare class FilterParams {
name: ResourceStr;
options: Array<ResourceStr>;
}
|
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.arkui.advanced.Filter.d.ets#L79-L108
|
c37767f7007594e4bd231fa01f70c21e0fccfb87
|
gitee
|
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/common/types/GreetingTypes.ets
|
arkts
|
祝福语导出数据接口
|
export interface GreetingExportData {
greetings: Greeting[];
history: GreetingHistory[];
statistics: GreetingStatistics;
exportDate: string;
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface GreetingExportData AST#object_type#Left { AST#type_member#Left greetings : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Greeting [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left history : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left GreetingHistory [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left statistics : AST#type_annotation#Left AST#primary_type#Left GreetingStatistics AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left exportDate : AST#type_annotation#Left AST#primary_type#Left string 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 GreetingExportData {
greetings: Greeting[];
history: GreetingHistory[];
statistics: GreetingStatistics;
exportDate: string;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/GreetingTypes.ets#L259-L264
|
f0481ba9e7a1da9d5137cd1bb066b206f34f5ab8
|
github
|
|
openharmony/arkui_ace_engine
|
30c7d1ee12fbedf0fabece54291d75897e2ad44f
|
frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/Storage.ets
|
arkts
|
Set
|
Called when setting.
@since 7
@deprecated since 10
|
static Set<T>(propName: string, newValue: T): boolean {
return AppStorage.set(propName, newValue)
}
|
AST#method_declaration#Left static Set AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left propName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left newValue : 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#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 AppStorage AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left propName AST#expression#Right , AST#expression#Left newValue 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 Set<T>(propName: string, newValue: T): boolean {
return AppStorage.set(propName, newValue)
}
|
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/Storage.ets#L149-L151
|
9750ac436041131e110b87266afbfc20c5e179c4
|
gitee
|
Joker-x-dev/HarmonyKit.git
|
f97197ce157df7f303244fba42e34918306dfb08
|
core/data/src/main/ets/repository/AuthRepository.ets
|
arkts
|
loginByPassword
|
密码登录
@param params 登录参数,包含用户名、密码等
@returns 包含认证信息的网络响应
|
async loginByPassword(params: PasswordLoginRequest): Promise<NetworkResponse<Auth>> {
return this.networkDataSource.loginByPassword(params);
}
|
AST#method_declaration#Left async loginByPassword AST#parameter_list#Left ( AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left PasswordLoginRequest 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 Auth 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#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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . networkDataSource AST#member_expression#Right AST#expression#Right . loginByPassword AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left params 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
|
async loginByPassword(params: PasswordLoginRequest): Promise<NetworkResponse<Auth>> {
return this.networkDataSource.loginByPassword(params);
}
|
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/data/src/main/ets/repository/AuthRepository.ets#L36-L38
|
a3ba8a889d22c52493670daa5d22b2ec08f5c59d
|
github
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Media/ImageEdit/entry/src/main/ets/viewModel/Ratio.ets
|
arkts
|
getH
|
Get height.
@returns
|
getH(): number {
return this.h;
}
|
AST#method_declaration#Left getH 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#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . h AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
getH(): number {
return this.h;
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Media/ImageEdit/entry/src/main/ets/viewModel/Ratio.ets#L59-L61
|
066f8f0aa5fa24f3ed8341fced7d5ec1ee6b64bf
|
gitee
|
Joker-x-dev/HarmonyKit.git
|
f97197ce157df7f303244fba42e34918306dfb08
|
core/ui/src/main/ets/component/navdestination/AppNavDestination.ets
|
arkts
|
渲染通用 NavDestination
@returns {void} 无返回值
|
build() {
NavDestination() {
if (this.content) {
this.content();
}
}
.title(this.title, this.titleOptions)
.hideTitleBar(this.hideTitleBar)
.menus(this.menus, this.menuOptions)
.onShown((reason: VisibilityChangeReason) => {
this.viewModel.onShown(reason);
})
.onHidden((reason: VisibilityChangeReason) => {
this.viewModel.onHidden(reason);
})
.backgroundColor(this.pageBackgroundColor)
.padding(this.paddingValue ?? (this.safeAreaEnabled ? this.getSafeAreaPadding() : 0));
}
|
AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left NavDestination ( ) 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 . content 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 this AST#expression#Right . content 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#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . title ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . title AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . titleOptions AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . hideTitleBar ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . hideTitleBar AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . menus ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . menus AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . menuOptions AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onShown ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left reason : AST#type_annotation#Left AST#primary_type#Left VisibilityChangeReason 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 . viewModel AST#member_expression#Right AST#expression#Right . onShown AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left reason 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 . onHidden ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left reason : AST#type_annotation#Left AST#primary_type#Left VisibilityChangeReason 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 . viewModel AST#member_expression#Right AST#expression#Right . onHidden AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left reason 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 . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . pageBackgroundColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . paddingValue AST#member_expression#Right AST#expression#Right ?? AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . safeAreaEnabled AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getSafeAreaPadding 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#conditional_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#build_body#Right AST#build_method#Right
|
build() {
NavDestination() {
if (this.content) {
this.content();
}
}
.title(this.title, this.titleOptions)
.hideTitleBar(this.hideTitleBar)
.menus(this.menus, this.menuOptions)
.onShown((reason: VisibilityChangeReason) => {
this.viewModel.onShown(reason);
})
.onHidden((reason: VisibilityChangeReason) => {
this.viewModel.onHidden(reason);
})
.backgroundColor(this.pageBackgroundColor)
.padding(this.paddingValue ?? (this.safeAreaEnabled ? this.getSafeAreaPadding() : 0));
}
|
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/ui/src/main/ets/component/navdestination/AppNavDestination.ets#L122-L139
|
0b92034cbbdadbb837a27274ded2ef45a99851e7
|
github
|
|
Joker-x-dev/CoolMallArkTS.git
|
9f3fabf89fb277692cb82daf734c220c7282919c
|
feature/user/src/main/ets/view/ProfilePage.ets
|
arkts
|
AccountInfoCard
|
账号信息卡片
@returns {void} 无返回值
|
@Builder
private AccountInfoCard(): void {
Card() {
IBestCellGroup({
inset: true,
radius: $r("app.float.radius_medium"),
outerMargin: 0
}) {
IBestCell({
title: $r("app.string.phone"),
value: this.vm.getPhoneText(),
hasBorder: true,
isLink: false,
cellPadding: $r("app.float.space_padding_large")
});
IBestCell({
title: $r("app.string.account"),
value: this.vm.getAccountText(),
hasBorder: false,
isLink: false,
cellPadding: $r("app.float.space_padding_large")
});
}
}
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right private AccountInfoCard AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Card ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left IBestCellGroup ( AST#component_parameters#Left { AST#component_parameter#Left inset : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left radius : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.float.radius_medium" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left outerMargin : AST#expression#Left 0 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#ui_custom_component_statement#Left IBestCell ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.phone" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left value : 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 . vm AST#member_expression#Right AST#expression#Right . getPhoneText 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 hasBorder : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left isLink : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left cellPadding : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.float.space_padding_large" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right AST#ui_custom_component_statement#Left IBestCell ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.account" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left value : 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 . vm AST#member_expression#Right AST#expression#Right . getAccountText 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 hasBorder : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left isLink : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left cellPadding : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.float.space_padding_large" AST#expression#Right ) AST#resource_expression#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#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#builder_function_body#Right AST#method_declaration#Right
|
@Builder
private AccountInfoCard(): void {
Card() {
IBestCellGroup({
inset: true,
radius: $r("app.float.radius_medium"),
outerMargin: 0
}) {
IBestCell({
title: $r("app.string.phone"),
value: this.vm.getPhoneText(),
hasBorder: true,
isLink: false,
cellPadding: $r("app.float.space_padding_large")
});
IBestCell({
title: $r("app.string.account"),
value: this.vm.getAccountText(),
hasBorder: false,
isLink: false,
cellPadding: $r("app.float.space_padding_large")
});
}
}
}
|
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/user/src/main/ets/view/ProfilePage.ets#L129-L154
|
46abeafbada807ebea30ffe3923215ceffa4c72a
|
github
|
openharmony/xts_acts
|
5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686
|
ability/ability_runtime/startup/startupmanualhelp1/entry/src/main/ets/MainAbility/PageAbility6.ets
|
arkts
|
onCreate
|
Sample_002 -> Sample_003 -> Sample_001
|
onCreate(want:Want, launchParam: AbilityConstant.LaunchParam){
hilog.info(0x0000, 'StartupTest PageAbility6', '%{public}s', 'Ability onCreate');
if (want.parameters && want.parameters?.keepAlive) {
console.info('StartupTest PageAbility6 keepAlive = true');
keepAlive = true;
}
if (want.parameters && want.parameters?.customConfig) {
console.info('StartupTest PageAbility6 customConfig = true');
customConfig = true;
}
uiContext = this.context;
let subscribeInfo: commonEventManager.CommonEventSubscribeInfo = {
events: ['StartupSample_002_onDependencyCompleted', 'StartupSample_003_onDependencyCompleted'],
};
commonEventManager.createSubscriber(subscribeInfo).then(data => {
console.info('StartupTest PageAbility6 createSubscriber success');
subscriber = data;
commonEventManager.subscribe(subscriber, (err, data)=>{
console.info('StartupTest PageAbility6 receive event, data = ' + JSON.stringify(data));
let event = data.event;
if (event === 'StartupSample_003_onDependencyCompleted') {
if (data.parameters?.name == 'Sample_001') {
hasInit001 = true;
}
let message: string;
if (!customConfig) {
message = '默认配置 Sample_003收到StartupSample_001加载完毕';
} else {
message = '自定义配置 Sample_003收到StartupSample_001加载完毕';
}
commonEventManager.publish('show_msg', {
parameters:{
msg:message
}
},()=>{
console.info('StartupTest PageAbility6 send msg');
})
}
if (event === 'StartupSample_002_onDependencyCompleted') {
if (data.parameters?.name == 'Sample_003') {
hasInit003 = true;
}
let message: string;
if (!customConfig) {
message = '默认配置 StartupSample_002收到Sample_003加载完毕';
} else {
message = '自定义配置 StartupSample_002收到Sample_003加载完毕';
}
commonEventManager.publish('show_msg', {
parameters:{
msg:message
}
},()=>{
console.info('StartupTest PageAbility6 send msg');
})
}
if (hasInit001 && hasInit003) {
console.info('StartupTest PageAbility6 terminateSelfWithResult , result = true');
if (!keepAlive) {
setTimeout(()=>{
uiContext?.terminateSelfWithResult({
resultCode: 0,
want:{
parameters:{
'hasInit001': hasInit001,
'hasInit003':hasInit003
}
}
})
}, 2000)
}
}
})
}).catch((error: BusinessError)=>{
console.info('StartupTest PageAbility6 createSubscriber failed, error=' + JSON.stringify(error));
})
}
|
AST#method_declaration#Left onCreate AST#parameter_list#Left ( AST#parameter#Left want : AST#type_annotation#Left AST#primary_type#Left Want AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left launchParam : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left AbilityConstant . LaunchParam 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 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 'StartupTest PageAbility6' AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left 'Ability onCreate' 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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left want AST#expression#Right . parameters AST#member_expression#Right AST#expression#Right && AST#expression#Left want AST#expression#Right AST#binary_expression#Right AST#expression#Right . parameters AST#member_expression#Right AST#expression#Right ?. keepAlive 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 . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'StartupTest PageAbility6 keepAlive = true' 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 keepAlive = 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 AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_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 want AST#expression#Right . parameters AST#member_expression#Right AST#expression#Right && AST#expression#Left want AST#expression#Right AST#binary_expression#Right AST#expression#Right . parameters AST#member_expression#Right AST#expression#Right ?. customConfig 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 . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'StartupTest PageAbility6 customConfig = true' 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 customConfig = 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 AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left uiContext = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context 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 subscribeInfo : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left commonEventManager . CommonEventSubscribeInfo AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left events AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'StartupSample_002_onDependencyCompleted' AST#expression#Right , AST#expression#Left 'StartupSample_003_onDependencyCompleted' AST#expression#Right ] AST#array_literal#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 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 commonEventManager AST#expression#Right . createSubscriber AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left subscribeInfo 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 data => 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 'StartupTest PageAbility6 createSubscriber success' 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 subscriber = AST#expression#Left data 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 commonEventManager AST#expression#Right . subscribe AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left subscriber AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right , AST#parameter#Left data 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 . 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 'StartupTest PageAbility6 receive event, data = ' 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 data 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#variable_declaration#Left let AST#variable_declarator#Left event = AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . event 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 event AST#expression#Right === AST#expression#Left 'StartupSample_003_onDependencyCompleted' AST#expression#Right AST#binary_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#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . parameters AST#member_expression#Right AST#expression#Right ?. name AST#member_expression#Right AST#expression#Right == AST#expression#Left 'Sample_001' 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 hasInit001 = 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 AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left message : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left customConfig AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left message = AST#expression#Left '默认配置 Sample_003收到StartupSample_001加载完毕' 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 message = AST#expression#Left '自定义配置 Sample_003收到StartupSample_001加载完毕' 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 commonEventManager AST#expression#Right . publish AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'show_msg' AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left parameters AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left msg AST#property_name#Right : AST#expression#Left message 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#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 'StartupTest PageAbility6 send msg' 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#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left event AST#expression#Right === AST#expression#Left 'StartupSample_002_onDependencyCompleted' AST#expression#Right AST#binary_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#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . parameters AST#member_expression#Right AST#expression#Right ?. name AST#member_expression#Right AST#expression#Right == AST#expression#Left 'Sample_003' 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 hasInit003 = 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 AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left message : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left customConfig AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left message = AST#expression#Left '默认配置 StartupSample_002收到Sample_003加载完毕' 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 message = AST#expression#Left '自定义配置 StartupSample_002收到Sample_003加载完毕' 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 commonEventManager AST#expression#Right . publish AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'show_msg' AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left parameters AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left msg AST#property_name#Right : AST#expression#Left message 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#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 'StartupTest PageAbility6 send msg' 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#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left hasInit001 AST#expression#Right && AST#expression#Left hasInit003 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 console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'StartupTest PageAbility6 terminateSelfWithResult , result = true' 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#unary_expression#Left ! AST#expression#Left keepAlive AST#expression#Right AST#unary_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 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left uiContext AST#expression#Right ?. terminateSelfWithResult 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 resultCode AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left want AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left parameters AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left 'hasInit001' AST#property_name#Right : AST#expression#Left hasInit001 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'hasInit003' AST#property_name#Right : AST#expression#Left hasInit003 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#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#expression#Left 2000 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#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 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 . 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 'StartupTest PageAbility6 createSubscriber failed, error=' 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 error 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#method_declaration#Right
|
onCreate(want:Want, launchParam: AbilityConstant.LaunchParam){
hilog.info(0x0000, 'StartupTest PageAbility6', '%{public}s', 'Ability onCreate');
if (want.parameters && want.parameters?.keepAlive) {
console.info('StartupTest PageAbility6 keepAlive = true');
keepAlive = true;
}
if (want.parameters && want.parameters?.customConfig) {
console.info('StartupTest PageAbility6 customConfig = true');
customConfig = true;
}
uiContext = this.context;
let subscribeInfo: commonEventManager.CommonEventSubscribeInfo = {
events: ['StartupSample_002_onDependencyCompleted', 'StartupSample_003_onDependencyCompleted'],
};
commonEventManager.createSubscriber(subscribeInfo).then(data => {
console.info('StartupTest PageAbility6 createSubscriber success');
subscriber = data;
commonEventManager.subscribe(subscriber, (err, data)=>{
console.info('StartupTest PageAbility6 receive event, data = ' + JSON.stringify(data));
let event = data.event;
if (event === 'StartupSample_003_onDependencyCompleted') {
if (data.parameters?.name == 'Sample_001') {
hasInit001 = true;
}
let message: string;
if (!customConfig) {
message = '默认配置 Sample_003收到StartupSample_001加载完毕';
} else {
message = '自定义配置 Sample_003收到StartupSample_001加载完毕';
}
commonEventManager.publish('show_msg', {
parameters:{
msg:message
}
},()=>{
console.info('StartupTest PageAbility6 send msg');
})
}
if (event === 'StartupSample_002_onDependencyCompleted') {
if (data.parameters?.name == 'Sample_003') {
hasInit003 = true;
}
let message: string;
if (!customConfig) {
message = '默认配置 StartupSample_002收到Sample_003加载完毕';
} else {
message = '自定义配置 StartupSample_002收到Sample_003加载完毕';
}
commonEventManager.publish('show_msg', {
parameters:{
msg:message
}
},()=>{
console.info('StartupTest PageAbility6 send msg');
})
}
if (hasInit001 && hasInit003) {
console.info('StartupTest PageAbility6 terminateSelfWithResult , result = true');
if (!keepAlive) {
setTimeout(()=>{
uiContext?.terminateSelfWithResult({
resultCode: 0,
want:{
parameters:{
'hasInit001': hasInit001,
'hasInit003':hasInit003
}
}
})
}, 2000)
}
}
})
}).catch((error: BusinessError)=>{
console.info('StartupTest PageAbility6 createSubscriber failed, error=' + JSON.stringify(error));
})
}
|
https://github.com/openharmony/xts_acts/blob/5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686/ability/ability_runtime/startup/startupmanualhelp1/entry/src/main/ets/MainAbility/PageAbility6.ets#L38-L116
|
5cba755123bb7c629794321a674b44ea3c1c1029
|
gitee
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/clickanimation/src/main/ets/model/ReviewDataModel.ets
|
arkts
|
ReviewListDataSource 类继承自 BasicDataSource<ReviewItem>,处理评论列表数据源操作
@extends {BasicDataSource<ReviewItem>}
|
export class ReviewListDataSource extends BasicDataSource<ReviewItem> {}
|
AST#export_declaration#Left export AST#class_declaration#Left class ReviewListDataSource extends 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 ReviewItem 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#class_body#Left { } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class ReviewListDataSource extends BasicDataSource<ReviewItem> {}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/clickanimation/src/main/ets/model/ReviewDataModel.ets#L35-L35
|
df0dd559967590036114a08551f9a5b628e61e01
|
gitee
|
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/common/components/Speech/Recorder/SpeechRecordManager.ets
|
arkts
|
startPlaying
|
===================== 播放核心方法 =====================
|
private async startPlaying(): Promise<void> {
await this.stopPlaying()
if (this.isPlaying || !this.soundName) return;
try {
// 1. 从数据库获取音频数据
const recordSound = await SpeechRecordDbAccessor.shared.getRecordSound(this.soundName);
if (!recordSound?.pronData) return;
// 2. 创建临时文件路径
const tempFilePath = `${this.soundPath}temp_${Date.now()}${RECORD_FILE_EXT}`;
// 3. 使用文件描述符写入数据(替代已废弃的 writeFile)
const arrayBuffer = recordSound.pronData.buffer.slice(recordSound.pronData.byteOffset, recordSound.pronData.byteOffset + recordSound.pronData.byteLength);
const file = await fs.open(tempFilePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
await fs.write(file.fd, arrayBuffer);
// 4. 创建 AVPlayer 并配置 fdSrc
this.avPlayer = await media.createAVPlayer();
const fileSize = (await fs.stat(tempFilePath)).size;
this.avPlayer.fdSrc = { fd: file.fd, offset: 0, length: fileSize };
// 5. 状态监听(包含资源清理)
this.avPlayer.on('stateChange', async (state: string) => {
// 播放完成时停止并清理
if (state === 'completed') {
this.stopPlaying();
}
// 播放器释放时关闭文件描述符
if (state === 'released') {
await fs.close(file.fd);
await fs.unlink(tempFilePath);
}
});
// 延迟确保AVPlayer初始化完成,避免prepare时状态错误
await awaitDelay(500)
// 6. 异步准备播放器(必须等待 prepared 状态)
await new Promise<void>((resolve, reject) => {
this.avPlayer?.prepare((err: BusinessError) => {
err ? reject(err) : resolve();
});
});
// 7. 开始播放
await this.avPlayer.play();
this.isPlaying = true;
} catch (err) {
console.error(`播放启动失败: ${JSON.stringify(err)}`);
}
}
|
AST#method_declaration#Left private async startPlaying 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#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 . stopPlaying 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#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 . isPlaying 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 . soundName AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 1. 从数据库获取音频数据 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left recordSound = 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 SpeechRecordDbAccessor AST#expression#Right AST#await_expression#Right AST#expression#Right . shared AST#member_expression#Right AST#expression#Right . getRecordSound 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 . soundName 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#unary_expression#Left ! AST#expression#Left recordSound AST#expression#Right AST#unary_expression#Right AST#expression#Right ?. pronData AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right // 2. 创建临时文件路径 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left tempFilePath = 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 . soundPath AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right temp_ 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 RECORD_FILE_EXT 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 // 3. 使用文件描述符写入数据(替代已废弃的 writeFile) AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left arrayBuffer = 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#member_expression#Left AST#expression#Left recordSound AST#expression#Right . pronData AST#member_expression#Right AST#expression#Right . buffer AST#member_expression#Right AST#expression#Right . slice 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 recordSound AST#expression#Right . pronData AST#member_expression#Right AST#expression#Right . byteOffset AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_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#member_expression#Left AST#expression#Left recordSound AST#expression#Right . pronData AST#member_expression#Right AST#expression#Right . byteOffset AST#member_expression#Right AST#expression#Right + AST#expression#Left recordSound AST#expression#Right AST#binary_expression#Right AST#expression#Right . pronData AST#member_expression#Right AST#expression#Right . byteLength 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 file = 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 fs AST#expression#Right AST#await_expression#Right AST#expression#Right . open AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tempFilePath AST#expression#Right , AST#expression#Left AST#member_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#member_expression#Left AST#expression#Left fs AST#expression#Right . OpenMode AST#member_expression#Right AST#expression#Right . CREATE AST#member_expression#Right AST#expression#Right | AST#expression#Left fs AST#expression#Right AST#binary_expression#Right AST#expression#Right . OpenMode AST#member_expression#Right AST#expression#Right . READ_WRITE 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 AST#await_expression#Left await AST#expression#Left fs AST#expression#Right AST#await_expression#Right AST#expression#Right . write 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 arrayBuffer AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 4. 创建 AVPlayer 并配置 fdSrc 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 . avPlayer 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 media AST#expression#Right AST#await_expression#Right AST#expression#Right . createAVPlayer 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 fileSize = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#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 fs AST#expression#Right AST#await_expression#Right AST#expression#Right . stat AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tempFilePath AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . size 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . avPlayer AST#member_expression#Right AST#expression#Right . fdSrc AST#member_expression#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left fd AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left file AST#expression#Right . fd AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offset AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left length AST#property_name#Right : AST#expression#Left fileSize 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 // 5. 状态监听(包含资源清理) 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 . avPlayer AST#member_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'stateChange' AST#expression#Right , AST#expression#Left AST#arrow_function#Left async AST#parameter_list#Left ( AST#parameter#Left state : 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left state AST#expression#Right === AST#expression#Left 'completed' 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 this AST#expression#Right . stopPlaying 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#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left state AST#expression#Right === AST#expression#Left 'released' 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#await_expression#Left await AST#expression#Left fs AST#expression#Right AST#await_expression#Right AST#expression#Right . close 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#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 fs AST#expression#Right AST#await_expression#Right AST#expression#Right . unlink AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tempFilePath 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 // 延迟确保AVPlayer初始化完成,避免prepare时状态错误 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 awaitDelay AST#expression#Right AST#await_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 500 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // 6. 异步准备播放器(必须等待 prepared 状态) 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 AST#new_expression#Left new AST#expression#Left Promise AST#expression#Right AST#new_expression#Right AST#expression#Right AST#await_expression#Right AST#expression#Right 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#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left resolve AST#parameter#Right , AST#parameter#Left reject 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 . avPlayer AST#member_expression#Right AST#expression#Right ?. prepare 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#conditional_expression#Left AST#expression#Left err AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left reject 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#expression#Left resolve AST#expression#Right AST#conditional_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#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 // 7. 开始播放 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 . avPlayer AST#member_expression#Right AST#expression#Right . play 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 . isPlaying 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 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#template_literal#Left ` 播放启动失败: 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 err 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 startPlaying(): Promise<void> {
await this.stopPlaying()
if (this.isPlaying || !this.soundName) return;
try {
const recordSound = await SpeechRecordDbAccessor.shared.getRecordSound(this.soundName);
if (!recordSound?.pronData) return;
const tempFilePath = `${this.soundPath}temp_${Date.now()}${RECORD_FILE_EXT}`;
const arrayBuffer = recordSound.pronData.buffer.slice(recordSound.pronData.byteOffset, recordSound.pronData.byteOffset + recordSound.pronData.byteLength);
const file = await fs.open(tempFilePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
await fs.write(file.fd, arrayBuffer);
this.avPlayer = await media.createAVPlayer();
const fileSize = (await fs.stat(tempFilePath)).size;
this.avPlayer.fdSrc = { fd: file.fd, offset: 0, length: fileSize };
this.avPlayer.on('stateChange', async (state: string) => {
if (state === 'completed') {
this.stopPlaying();
}
if (state === 'released') {
await fs.close(file.fd);
await fs.unlink(tempFilePath);
}
});
await awaitDelay(500)
await new Promise<void>((resolve, reject) => {
this.avPlayer?.prepare((err: BusinessError) => {
err ? reject(err) : resolve();
});
});
await this.avPlayer.play();
this.isPlaying = true;
} catch (err) {
console.error(`播放启动失败: ${JSON.stringify(err)}`);
}
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/components/Speech/Recorder/SpeechRecordManager.ets#L157-L211
|
a6ddb01800eec867403a1444343f62fd79c92631
|
github
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/views/onlinesearch/OnlineSearchWordsView.ets
|
arkts
|
search
|
执行搜索
|
private async search(val: string): Promise<void> {
if (!this.searchText.trim()) {
this.errorMessage = '请输入搜索内容';
return;
}
///会员检查
if (!MemberManager.shared.checkOnlineDictUsable()) {
return
}
//记录次数
DailyCountManager.shared.increase(DailyCountType.onlineDict)
this.isLoading = true;
this.errorMessage = '';
this.searchResults = [];
try {
Toast.showCustomDialog(()=> { this.buildLoadingDialog($r('app.string.online_search_loading'))}, false)
OnlineWordManager.shared.searchWords(this.searchText.trim(), 0, (success: boolean, msg: string | null, words: OnlineWord[] | null) => {
Toast.closeCustomDialog()
this.isLoading = false;
if (success && words) {
this.searchResults = words.map(v => v.asWordUser());
if (words.length === 0) {
this.errorMessage = '未找到相关单词';
}
} else {
this.errorMessage = msg || '搜索失败,请重试';
}
}
);
} catch (error) {
this.isLoading = false;
this.errorMessage = `搜索出错: ${error}`;
}
}
|
AST#method_declaration#Left private async search AST#parameter_list#Left ( AST#parameter#Left val : 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 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#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 this AST#expression#Right AST#unary_expression#Right AST#expression#Right . searchText AST#member_expression#Right 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#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 . errorMessage 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#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#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 . checkOnlineDictUsable AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DailyCountManager AST#expression#Right . shared AST#member_expression#Right AST#expression#Right . increase AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left DailyCountType AST#expression#Right . onlineDict 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#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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . errorMessage 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 . searchResults AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Toast AST#expression#Right . showCustomDialog 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 . buildLoadingDialog AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.online_search_loading' 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#block_statement#Right AST#arrow_function#Right 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#member_expression#Left AST#expression#Left OnlineWordManager AST#expression#Right . shared AST#member_expression#Right AST#expression#Right . searchWords 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#member_expression#Left AST#expression#Left this AST#expression#Right . searchText AST#member_expression#Right 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#expression#Left 0 AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left success : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left msg : 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#parameter#Right , AST#parameter#Left words : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#array_type#Left OnlineWord [ ] 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#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 Toast AST#expression#Right . closeCustomDialog 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 . 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#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left success AST#expression#Right && AST#expression#Left words 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 . searchResults AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left words AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left v => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left v AST#expression#Right . asWordUser 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#assignment_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 AST#member_expression#Left AST#expression#Left words 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . errorMessage 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#block_statement#Right AST#if_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 . errorMessage AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left msg AST#expression#Right || AST#expression#Left '搜索失败,请重试' 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#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#catch_clause#Left catch ( error ) 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#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . errorMessage AST#member_expression#Right = AST#expression#Left AST#template_literal#Left ` 搜索出错: AST#template_substitution#Left $ { AST#expression#Left error 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#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private async search(val: string): Promise<void> {
if (!this.searchText.trim()) {
this.errorMessage = '请输入搜索内容';
return;
}
if (!MemberManager.shared.checkOnlineDictUsable()) {
return
}
DailyCountManager.shared.increase(DailyCountType.onlineDict)
this.isLoading = true;
this.errorMessage = '';
this.searchResults = [];
try {
Toast.showCustomDialog(()=> { this.buildLoadingDialog($r('app.string.online_search_loading'))}, false)
OnlineWordManager.shared.searchWords(this.searchText.trim(), 0, (success: boolean, msg: string | null, words: OnlineWord[] | null) => {
Toast.closeCustomDialog()
this.isLoading = false;
if (success && words) {
this.searchResults = words.map(v => v.asWordUser());
if (words.length === 0) {
this.errorMessage = '未找到相关单词';
}
} else {
this.errorMessage = msg || '搜索失败,请重试';
}
}
);
} catch (error) {
this.isLoading = false;
this.errorMessage = `搜索出错: ${error}`;
}
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/views/onlinesearch/OnlineSearchWordsView.ets#L227-L264
|
24526fcd3ed954dc34bc3cc6ed4b49a9946fd4db
|
github
|
Nuist666/Alzheimer.git
|
c171b8e739357bfc5a3fc71c90aaea6ce5d463d1
|
entry/src/main/ets/utils/Recorder.ets
|
arkts
|
pauseRecord
|
暂停录制
|
async pauseRecord() {
// 仅在started状态下调用pause为合理状态切换
if (this.avRecorder != undefined && this.avRecorder.state === 'started') {
await this.avRecorder.pause();
}
}
|
AST#method_declaration#Left async pauseRecord AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { // 仅在started状态下调用pause为合理状态切换 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 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 . avRecorder AST#member_expression#Right AST#expression#Right != AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . avRecorder AST#member_expression#Right AST#expression#Right . state AST#member_expression#Right AST#expression#Right === AST#expression#Left 'started' 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 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 . avRecorder AST#member_expression#Right AST#expression#Right . pause 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#builder_function_body#Right AST#method_declaration#Right
|
async pauseRecord() {
if (this.avRecorder != undefined && this.avRecorder.state === 'started') {
await this.avRecorder.pause();
}
}
|
https://github.com/Nuist666/Alzheimer.git/blob/c171b8e739357bfc5a3fc71c90aaea6ce5d463d1/entry/src/main/ets/utils/Recorder.ets#L49-L54
|
5d9aab656a77fcf230c640f046f570763cb23991
|
github
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.