Datasets:
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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
openharmony-tpc/ohos_mpchart
|
4fb43a7137320ef2fee2634598f53d93975dfb4a
|
library/src/main/ets/components/components/AxisBase.ets
|
arkts
|
setAxisMaxLabels
|
The maximum number of labels on the axis
|
public setAxisMaxLabels(labels: number): void {
if (labels > 0)
this.mAxisMaxLabels = labels;
}
|
AST#method_declaration#Left public setAxisMaxLabels AST#parameter_list#Left ( AST#parameter#Left labels : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left labels AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#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 . mAxisMaxLabels AST#member_expression#Right = AST#expression#Left labels AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public setAxisMaxLabels(labels: number): void {
if (labels > 0)
this.mAxisMaxLabels = labels;
}
|
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/components/AxisBase.ets#L172-L175
|
8f580a33a220f9a3363cf76cb8226cc8792acd5c
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
harmonyos/src/main/ets/common/types/SettingsTypes.ets
|
arkts
|
数据设置接口(为DataSettings别名)
|
export interface DataSettings extends DataConfig {
// 继承DataConfig的所有属性
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface DataSettings AST#extends_clause#Left extends DataConfig AST#extends_clause#Right AST#object_type#Left { // 继承DataConfig的所有属性 } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
|
export interface DataSettings extends DataConfig {
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/common/types/SettingsTypes.ets#L182-L184
|
78178a0565b6ac9e5e363052f658c9d32908fe20
|
github
|
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
SegmentedPhotograph/entry/src/main/ets/mode/CameraService.ets
|
arkts
|
createVideoOutputFn
|
[End create_photo_outputFn]
Creating a videoOutPut Output Object
|
createVideoOutputFn(cameraManager: camera.CameraManager, videoProfileObj: camera.VideoProfile,
surfaceId: string): camera.VideoOutput | undefined {
let videoOutput: camera.VideoOutput;
try {
videoOutput = cameraManager.createVideoOutput(videoProfileObj, surfaceId);
Logger.info(TAG, `createVideoOutputFn success: ${videoOutput}`);
return videoOutput;
} catch (error) {
let err = error as BusinessError;
Logger.error(TAG, `createVideoOutputFn failed: ${JSON.stringify(err)}`);
return undefined;
}
}
|
AST#method_declaration#Left createVideoOutputFn AST#parameter_list#Left ( AST#parameter#Left cameraManager : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left camera . CameraManager AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left videoProfileObj : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left camera . VideoProfile AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left surfaceId : 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#union_type#Left AST#primary_type#Left AST#qualified_type#Left camera . VideoOutput AST#qualified_type#Right AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left videoOutput : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left camera . VideoOutput AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#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 videoOutput = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cameraManager AST#expression#Right . createVideoOutput AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left videoProfileObj AST#expression#Right , AST#expression#Left surfaceId 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 Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` createVideoOutputFn success: AST#template_substitution#Left $ { AST#expression#Left videoOutput 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 videoOutput 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 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 TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` createVideoOutputFn failed: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 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#return_statement#Left return AST#expression#Left undefined 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
|
createVideoOutputFn(cameraManager: camera.CameraManager, videoProfileObj: camera.VideoProfile,
surfaceId: string): camera.VideoOutput | undefined {
let videoOutput: camera.VideoOutput;
try {
videoOutput = cameraManager.createVideoOutput(videoProfileObj, surfaceId);
Logger.info(TAG, `createVideoOutputFn success: ${videoOutput}`);
return videoOutput;
} catch (error) {
let err = error as BusinessError;
Logger.error(TAG, `createVideoOutputFn failed: ${JSON.stringify(err)}`);
return undefined;
}
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/SegmentedPhotograph/entry/src/main/ets/mode/CameraService.ets#L385-L397
|
c4236dae084d96a4edf944d8c5fa3424a09138ab
|
gitee
|
zqaini002/YaoYaoLingXian.git
|
5095b12cbeea524a87c42d0824b1702978843d39
|
YaoYaoLingXian/entry/src/main/ets/pages/dream/DreamEditPage.ets
|
arkts
|
getErrorMessage
|
修改错误信息提取函数
|
function getErrorMessage(error: Object | string | null | undefined): string {
let errorMessage = '未知错误';
if (error === null || error === undefined) {
return errorMessage;
}
if (typeof error === 'string') {
return error;
}
if (typeof error === 'object') {
// 检查是否有message属性,不使用in操作符
const errorObj = error as Record<string, string>;
if (errorObj.message !== undefined) {
return String(errorObj.message);
}
}
return String(error);
}
|
AST#function_declaration#Left function getErrorMessage AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Object AST#primary_type#Right | AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null 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_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 errorMessage = AST#expression#Left '未知错误' 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 error 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 error 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 errorMessage 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left error AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left 'string' 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 error 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left error AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left 'object' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // 检查是否有message属性,不使用in操作符 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left errorObj = AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left 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#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left errorObj AST#expression#Right . message AST#member_expression#Right 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left String AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left errorObj AST#expression#Right . message 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#if_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 String AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
|
function getErrorMessage(error: Object | string | null | undefined): string {
let errorMessage = '未知错误';
if (error === null || error === undefined) {
return errorMessage;
}
if (typeof error === 'string') {
return error;
}
if (typeof error === 'object') {
const errorObj = error as Record<string, string>;
if (errorObj.message !== undefined) {
return String(errorObj.message);
}
}
return String(error);
}
|
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/pages/dream/DreamEditPage.ets#L243-L262
|
0fc51039604c664d9b2ab4888f4827b5171c9e71
|
github
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/main.ets
|
arkts
|
maybeNotCalledAtAllOptimize
|
[End import_change_global_var]
|
function maybeNotCalledAtAllOptimize() {
console.log(dataOptimize1);
console.log(dataOptimize2);
}
|
AST#function_declaration#Left function maybeNotCalledAtAllOptimize AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left dataOptimize1 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 . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left dataOptimize2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
|
function maybeNotCalledAtAllOptimize() {
console.log(dataOptimize1);
console.log(dataOptimize2);
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/ModuleLoadingSideEffects/entry/src/main/ets/pages/ModifyGlobalObject/main.ets#L30-L33
|
0fdbb0c49d07862aad838d2234c0f2dc89b2793f
|
gitee
|
openharmony/developtools_profiler
|
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
|
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/data/CandleEntry.ets
|
arkts
|
getHigh
|
Returns the upper shadows highest value.
@return
|
public getHigh(): number {
return this.mShadowHigh;
}
|
AST#method_declaration#Left public getHigh 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 . mShadowHigh AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public getHigh(): number {
return this.mShadowHigh;
}
|
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/data/CandleEntry.ets#L95-L97
|
857d0de3cd95d82ead64398d80dc5d9629a2d07a
|
gitee
|
openharmony/interface_sdk-js
|
c349adc73e2ec1f61f6fca489b5af059e3ed6999
|
api/arkui/component/lazyForEach.d.ets
|
arkts
|
Developers need to implement this interface to provide data to LazyForEach component.
@interface IDataSource
@syscap SystemCapability.ArkUI.ArkUI.Full
@crossplatform
@atomicservice
@since 20
|
export interface IDataSource<T> {
/**
* Total data count.
*
* @returns { number }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 20
*/
totalCount(): number;
/**
* Return the data of index.
*
* @param { number } index
* @returns { any }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 20
*/
getData(index: number): T;
/**
* Register data change listener.
*
* @param { DataChangeListener } listener
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 20
*/
registerDataChangeListener(listener: DataChangeListener): void;
/**
* Unregister data change listener.
*
* @param { DataChangeListener } listener
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 20
*/
unregisterDataChangeListener(listener: DataChangeListener): void;
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface IDataSource AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#object_type#Left { /**
* Total data count.
*
* @returns { number }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 20
*/ AST#type_member#Left totalCount 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#type_member#Right ; /**
* Return the data of index.
*
* @param { number } index
* @returns { any }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 20
*/ AST#type_member#Left getData 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#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /**
* Register data change listener.
*
* @param { DataChangeListener } listener
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 20
*/ AST#type_member#Left registerDataChangeListener 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#type_member#Right ; /**
* Unregister data change listener.
*
* @param { DataChangeListener } listener
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 20
*/ AST#type_member#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#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
|
export interface IDataSource<T> {
totalCount(): number;
getData(index: number): T;
registerDataChangeListener(listener: DataChangeListener): void;
unregisterDataChangeListener(listener: DataChangeListener): void;
}
|
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/arkui/component/lazyForEach.d.ets#L570-L612
|
ab0525b05c004efb9fbb256e4254782b29c2712e
|
gitee
|
|
bigbear20240612/planner_build-.git
|
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
|
entry/src/main/ets/viewmodel/LLMConfigManager.ets
|
arkts
|
sendChatRequest
|
使用配置发送聊天请求
|
async sendChatRequest(message: string, config?: LLMConfig, enableStream: boolean = false): Promise<string> {
const targetConfig = config || this.getDefaultConfig();
if (!targetConfig) {
throw new Error('⚠️ 未找到可用的大模型配置\n\n请点击右上角⚙️按钮配置您的AI模型:\n• 选择服务商(OpenAI、DeepSeek等)\n• 填入API密钥\n• 测试连接后保存\n\n配置完成后即可开始智能对话!');
}
try {
// 构建请求头
const headers: Record<string, string> = {
'Content-Type': 'application/json'
};
// 根据不同提供商设置认证头
if (targetConfig.provider === 'openai') {
headers['Authorization'] = `Bearer ${targetConfig.apiKey}`;
} else if (targetConfig.provider === 'anthropic') {
headers['x-api-key'] = targetConfig.apiKey;
headers['anthropic-version'] = '2023-06-01';
} else if (targetConfig.provider === 'deepseek') {
headers['Authorization'] = `Bearer ${targetConfig.apiKey}`;
} else {
headers['Authorization'] = `Bearer ${targetConfig.apiKey}`;
}
const systemMessage: ChatMessage = {
role: 'system',
content: `# AI超级效能教练系统提示词
## 🎯 角色定位
你是"智能计划助手"应用的AI超级效能教练,拥有深厚的时间管理和效能优化专业知识。你的使命是帮助用户构建高效的工作生活管理体系,提升个人和团队效能。
## 📱 应用生态了解
用户正在使用的"智能计划助手"是一款基于HarmonyOS NEXT的专业效能管理应用,包含以下核心模块:
### 🏠 智能首页功能
- 个性化问候和今日概览
- 实时任务完成情况展示
- 专注时间和番茄钟统计
- 天气信息和快速功能入口
### 📝 智能计划管理
- **方法论模板**: GTD、四象限法、番茄工作法、时间块管理、看板方法、OKR目标管理
- **任务管理**: 智能分类、优先级设置、状态跟踪
- **模板系统**: 预设工作流程和批量操作
### 🍅 番茄钟执行中心
- 25分钟工作+5分钟休息的科学时间管理
- 任务与番茄钟绑定执行
- 实时专注统计和成果展示
- 灵活的暂停/重置/跳过控制
### 📊 数据统计分析
- 多维度可视化:周概览、日趋势、月完成率
- 习惯追踪热力图(5×7网格)
- 时间分析洞察:平均耗时、专注分布、黄金时段
- 成就系统和数据验证工具
### 🎓 效能学院
- 分层学习体系:基础→进阶→专家→定制
- 个性化方法论推荐
- 学习进度跟踪和认证体系
## 🧠 专业知识体系
### 核心方法论掌握
1. **GTD(Getting Things Done)**: 收集→整理→组织→回顾→执行
2. **艾森豪威尔矩阵**: 重要性×紧急性四象限分析
3. **番茄工作法**: 25分钟专注块+科学休息间隔
4. **时间块管理**: 日程时间段分配和边界控制
5. **看板方法**: 可视化工作流和WIP限制
6. **OKR**: 目标与关键结果的对齐管理
7. **精益思维**: 价值流优化和浪费消除
### 效能分析能力
- 根据用户数据识别效能瓶颈
- 基于完成率趋势提供改进建议
- 分析专注时间分布优化工作节奏
- 识别黄金工作时段和能量管理
## 💬 对话风格指南
### 回应原则
1. **专业权威**: 基于科学的时间管理理论
2. **实用导向**: 提供具体可执行的行动建议
3. **个性化**: 结合用户的应用使用情况
4. **积极正面**: 鼓励持续改进和成长心态
5. **简洁有效**: 避免冗长理论,突出核心要点
### 回应结构建议
- 🎯 **问题分析**: 快速识别用户核心需求
- 📋 **方法推荐**: 推荐适合的应用内功能和方法论
- ⚡ **行动指导**: 给出3-5个具体执行步骤
- 📊 **效果预期**: 说明预期改善效果
- 🔄 **后续跟进**: 建议如何监测和调整
## 🎨 互动增强
- 使用恰当的emoji增强表达力
- 引用应用内具体功能("在计划页面使用GTD模板")
- 结合用户可能的使用场景
- 提供渐进式的能力建设路径
## ⚠️ 注意事项
- 始终记住你在为"智能计划助手"用户服务
- 优先推荐应用内已有的功能和工具
- 避免推荐需要额外下载的外部工具
- 保持专业度,避免过度个人化的建议
现在,请基于以上背景,为用户提供专业、实用、个性化的效能管理指导。`
};
const userMessage: ChatMessage = {
role: 'user',
content: message
};
let chatRequest: ChatRequest;
let requestBody: string;
// 根据不同提供商构建请求体
if (targetConfig.provider === 'anthropic') {
// Anthropic使用不同的API格式
const anthropicRequest: AnthropicRequest = {
model: targetConfig.modelName,
max_tokens: 500,
messages: [userMessage], // Anthropic不需要system消息在messages中
system: systemMessage.content, // system消息单独提供
temperature: 0.7,
stream: enableStream
};
requestBody = JSON.stringify(anthropicRequest);
} else {
// OpenAI、DeepSeek等使用标准格式
chatRequest = {
messages: [systemMessage, userMessage],
model: targetConfig.modelName,
max_tokens: 500,
temperature: 0.7,
stream: enableStream
};
requestBody = JSON.stringify(chatRequest);
}
hilog.info(0x0000, 'LLMConfigManager', 'Sending chat request to: %{public}s', targetConfig.url);
// 发送真实的HTTP请求
const httpRequest = http.createHttp();
const requestOptions: http.HttpRequestOptions = {
method: http.RequestMethod.POST,
header: headers,
extraData: requestBody,
expectDataType: http.HttpDataType.STRING,
connectTimeout: 30000,
readTimeout: 60000 // 聊天请求可能需要更长时间
};
const response = await httpRequest.request(targetConfig.url, requestOptions);
if (response.responseCode === 200) {
const responseBody = response.result as string;
hilog.info(0x0000, 'LLMConfigManager', 'Chat request successful, response length: %{public}d', responseBody.length);
try {
// 如果是流式输出,需要特殊处理
if (enableStream) {
return await this.parseStreamResponse(responseBody, targetConfig.provider);
} else {
// 非流式输出的标准解析
const parsedResponse: Record<string, Object> = JSON.parse(responseBody);
return this.parseNonStreamResponse(parsedResponse, targetConfig.provider);
}
} catch (parseError) {
hilog.error(0x0000, 'LLMConfigManager', 'Response parse error: %{public}s', (parseError as Error).message);
throw new Error(`🤖 AI响应解析失败\n\n可能的原因:\n• 模型服务暂时异常\n• API响应格式变化\n• 网络传输问题\n\n请稍后重试,或检查配置是否正确。`);
}
} else {
hilog.error(0x0000, 'LLMConfigManager', 'HTTP error code: %{public}d', response.responseCode);
let errorMessage = `🚫 连接${targetConfig.provider.toUpperCase()}服务失败\n\n`;
errorMessage += `错误代码:${response.responseCode}\n`;
errorMessage += `错误描述:${this.getHttpErrorMessage(response.responseCode)}\n\n`;
errorMessage += `解决建议:\n`;
if (response.responseCode === 401) {
errorMessage += `• 检查API密钥是否正确\n• 确认密钥是否已过期\n• 验证账户余额是否充足`;
} else if (response.responseCode === 403) {
errorMessage += `• 检查API访问权限\n• 确认服务商地区限制\n• 验证账户状态`;
} else if (response.responseCode === 429) {
errorMessage += `• 请求频率过高,请稍后重试\n• 检查账户配额限制\n• 考虑升级服务套餐`;
} else if (response.responseCode >= 500) {
errorMessage += `• 服务商服务器异常\n• 请稍后重试\n• 可尝试切换其他模型`;
} else {
errorMessage += `• 检查网络连接\n• 验证API地址是否正确\n• 重新测试配置`;
}
throw new Error(errorMessage);
}
} catch (error) {
hilog.error(0x0000, 'LLMConfigManager', 'Chat request error: %{public}s', (error as Error).message);
// 如果是我们自定义的错误信息,直接抛出
if ((error as Error).message.includes('🤖') || (error as Error).message.includes('🚫') || (error as Error).message.includes('⚠️')) {
throw new Error((error as Error).message);
}
// 网络连接错误
let networkError = `🌐 网络连接失败\n\n`;
networkError += `详细信息:${this.getNetworkErrorMessage((error as Error).message)}\n\n`;
networkError += `解决建议:\n`;
networkError += `• 检查网络连接状态\n`;
networkError += `• 确认防火墙设置\n`;
networkError += `• 验证API地址是否正确\n`;
networkError += `• 尝试切换网络环境\n\n`;
networkError += `如果问题持续,请点击⚙️重新配置或联系技术支持。`;
throw new Error(networkError);
}
}
|
AST#method_declaration#Left async sendChatRequest AST#parameter_list#Left ( AST#parameter#Left message : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left config ? : AST#type_annotation#Left AST#primary_type#Left LLMConfig AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left enableStream : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_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#variable_declaration#Left const AST#variable_declarator#Left targetConfig = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left config AST#expression#Right || AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . getDefaultConfig 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 targetConfig AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { 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 '⚠️ 未找到可用的大模型配置\n\n请点击右上角⚙️按钮配置您的AI模型:\n• 选择服务商(OpenAI、DeepSeek等)\n• 填入API密钥\n• 测试连接后保存\n\n配置完成后即可开始智能对话!' 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#if_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 构建请求头 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left headers : 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 string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left 'Content-Type' AST#property_name#Right : AST#expression#Left 'application/json' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#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 targetConfig AST#expression#Right . provider AST#member_expression#Right AST#expression#Right === AST#expression#Left 'openai' 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#subscript_expression#Left AST#expression#Left headers AST#expression#Right [ AST#expression#Left 'Authorization' AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#template_literal#Left ` Bearer AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left targetConfig AST#expression#Right . apiKey AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#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 targetConfig AST#expression#Right . provider AST#member_expression#Right AST#expression#Right === AST#expression#Left 'anthropic' 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#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left headers AST#expression#Right [ AST#expression#Left 'x-api-key' AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left = targetConfig AST#ERROR#Right . apiKey AST#member_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left headers AST#expression#Right [ AST#expression#Left 'anthropic-version' AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left '2023-06-01' 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 targetConfig AST#expression#Right . provider AST#member_expression#Right AST#expression#Right === AST#expression#Left 'deepseek' 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#subscript_expression#Left AST#expression#Left headers AST#expression#Right [ AST#expression#Left 'Authorization' AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#template_literal#Left ` Bearer AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left targetConfig AST#expression#Right . apiKey AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#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#subscript_expression#Left AST#expression#Left headers AST#expression#Right [ AST#expression#Left 'Authorization' AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#template_literal#Left ` Bearer AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left targetConfig AST#expression#Right . apiKey AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left systemMessage : AST#type_annotation#Left AST#primary_type#Left ChatMessage AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left role AST#property_name#Right : AST#expression#Left 'system' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left content AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` # AI超级效能教练系统提示词
## 🎯 角色定位
你是"智能计划助手"应用的AI超级效能教练,拥有深厚的时间管理和效能优化专业知识。你的使命是帮助用户构建高效的工作生活管理体系,提升个人和团队效能。
## 📱 应用生态了解
用户正在使用的"智能计划助手"是一款基于HarmonyOS NEXT的专业效能管理应用,包含以下核心模块:
### 🏠 智能首页功能
- 个性化问候和今日概览
- 实时任务完成情况展示
- 专注时间和番茄钟统计
- 天气信息和快速功能入口
### 📝 智能计划管理
- **方法论模板**: GTD、四象限法、番茄工作法、时间块管理、看板方法、OKR目标管理
- **任务管理**: 智能分类、优先级设置、状态跟踪
- **模板系统**: 预设工作流程和批量操作
### 🍅 番茄钟执行中心
- 25分钟工作+5分钟休息的科学时间管理
- 任务与番茄钟绑定执行
- 实时专注统计和成果展示
- 灵活的暂停/重置/跳过控制
### 📊 数据统计分析
- 多维度可视化:周概览、日趋势、月完成率
- 习惯追踪热力图(5×7网格)
- 时间分析洞察:平均耗时、专注分布、黄金时段
- 成就系统和数据验证工具
### 🎓 效能学院
- 分层学习体系:基础→进阶→专家→定制
- 个性化方法论推荐
- 学习进度跟踪和认证体系
## 🧠 专业知识体系
### 核心方法论掌握
1. **GTD(Getting Things Done)**: 收集→整理→组织→回顾→执行
2. **艾森豪威尔矩阵**: 重要性×紧急性四象限分析
3. **番茄工作法**: 25分钟专注块+科学休息间隔
4. **时间块管理**: 日程时间段分配和边界控制
5. **看板方法**: 可视化工作流和WIP限制
6. **OKR**: 目标与关键结果的对齐管理
7. **精益思维**: 价值流优化和浪费消除
### 效能分析能力
- 根据用户数据识别效能瓶颈
- 基于完成率趋势提供改进建议
- 分析专注时间分布优化工作节奏
- 识别黄金工作时段和能量管理
## 💬 对话风格指南
### 回应原则
1. **专业权威**: 基于科学的时间管理理论
2. **实用导向**: 提供具体可执行的行动建议
3. **个性化**: 结合用户的应用使用情况
4. **积极正面**: 鼓励持续改进和成长心态
5. **简洁有效**: 避免冗长理论,突出核心要点
### 回应结构建议
- 🎯 **问题分析**: 快速识别用户核心需求
- 📋 **方法推荐**: 推荐适合的应用内功能和方法论
- ⚡ **行动指导**: 给出3-5个具体执行步骤
- 📊 **效果预期**: 说明预期改善效果
- 🔄 **后续跟进**: 建议如何监测和调整
## 🎨 互动增强
- 使用恰当的emoji增强表达力
- 引用应用内具体功能("在计划页面使用GTD模板")
- 结合用户可能的使用场景
- 提供渐进式的能力建设路径
## ⚠️ 注意事项
- 始终记住你在为"智能计划助手"用户服务
- 优先推荐应用内已有的功能和工具
- 避免推荐需要额外下载的外部工具
- 保持专业度,避免过度个人化的建议
现在,请基于以上背景,为用户提供专业、实用、个性化的效能管理指导。 ` AST#template_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#variable_declaration#Left const AST#variable_declarator#Left userMessage : AST#type_annotation#Left AST#primary_type#Left ChatMessage AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left role AST#property_name#Right : AST#expression#Left 'user' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left content AST#property_name#Right : AST#expression#Left message 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 chatRequest : AST#type_annotation#Left AST#primary_type#Left ChatRequest AST#primary_type#Right AST#type_annotation#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left requestBody : 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left targetConfig AST#expression#Right . provider AST#member_expression#Right AST#expression#Right === AST#expression#Left 'anthropic' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // Anthropic使用不同的API格式 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left anthropicRequest : AST#type_annotation#Left AST#primary_type#Left AnthropicRequest AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left model AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left targetConfig AST#expression#Right . modelName AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left max_tokens AST#property_name#Right : AST#expression#Left 500 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left messages AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left userMessage AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right , // Anthropic不需要system消息在messages中 AST#property_assignment#Left AST#property_name#Left system AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left systemMessage AST#expression#Right . content AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // system消息单独提供 AST#property_assignment#Left AST#property_name#Left temperature AST#property_name#Right : AST#expression#Left 0.7 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left stream AST#property_name#Right : AST#expression#Left enableStream 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#assignment_expression#Left requestBody = 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 anthropicRequest 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 else AST#block_statement#Left { // OpenAI、DeepSeek等使用标准格式 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left chatRequest = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left messages AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left systemMessage AST#expression#Right , AST#expression#Left userMessage AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left model AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left targetConfig AST#expression#Right . modelName AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left max_tokens AST#property_name#Right : AST#expression#Left 500 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left temperature AST#property_name#Right : AST#expression#Left 0.7 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left stream AST#property_name#Right : AST#expression#Left enableStream AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left requestBody = 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 chatRequest 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#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 'LLMConfigManager' AST#expression#Right , AST#expression#Left 'Sending chat request to: %{public}s' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left targetConfig AST#expression#Right . url 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 // 发送真实的HTTP请求 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left httpRequest = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . createHttp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left requestOptions : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left http . HttpRequestOptions 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 method AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . RequestMethod AST#member_expression#Right AST#expression#Right . POST AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left header AST#property_name#Right : AST#expression#Left headers AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left extraData AST#property_name#Right : AST#expression#Left requestBody AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left expectDataType AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . HttpDataType AST#member_expression#Right AST#expression#Right . STRING AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left connectTimeout AST#property_name#Right : AST#expression#Left 30000 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left readTimeout AST#property_name#Right : AST#expression#Left 60000 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 response = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left httpRequest AST#expression#Right AST#await_expression#Right AST#expression#Right . request AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left targetConfig AST#expression#Right . url AST#member_expression#Right AST#expression#Right , AST#expression#Left requestOptions AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . responseCode AST#member_expression#Right AST#expression#Right === AST#expression#Left 200 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left responseBody = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . result AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'LLMConfigManager' AST#expression#Right , AST#expression#Left 'Chat request successful, response length: %{public}d' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left responseBody AST#expression#Right . length 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#try_statement#Left try AST#block_statement#Left { // 如果是流式输出,需要特殊处理 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left enableStream 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 AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . parseStreamResponse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left responseBody AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left targetConfig AST#expression#Right . provider 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 else AST#block_statement#Left { // 非流式输出的标准解析 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left parsedResponse : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#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 responseBody 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 this AST#expression#Right . parseNonStreamResponse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left parsedResponse AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left targetConfig AST#expression#Right . provider 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#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( parseError ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'LLMConfigManager' AST#expression#Right , AST#expression#Left 'Response parse error: %{public}s' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left parseError 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#parenthesized_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#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#template_literal#Left ` 🤖 AI响应解析失败 \n \n 可能的原因: \n • 模型服务暂时异常 \n • API响应格式变化 \n • 网络传输问题 \n \n 请稍后重试,或检查配置是否正确。 ` AST#template_literal#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 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 hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'LLMConfigManager' AST#expression#Right , AST#expression#Left 'HTTP error code: %{public}d' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . responseCode 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 errorMessage = 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 AST#member_expression#Left AST#expression#Left targetConfig AST#expression#Right . provider AST#member_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#template_substitution#Right 服务失败 \n \n ` 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#assignment_expression#Left errorMessage += AST#expression#Left AST#template_literal#Left ` 错误代码: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . responseCode 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#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left errorMessage += 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 this AST#expression#Right . getHttpErrorMessage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . responseCode AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right \n \n ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left errorMessage += AST#expression#Left AST#template_literal#Left ` 解决建议: \n ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#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 . responseCode AST#member_expression#Right AST#expression#Right === AST#expression#Left 401 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 errorMessage += AST#expression#Left AST#template_literal#Left ` • 检查API密钥是否正确 \n • 确认密钥是否已过期 \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 . responseCode AST#member_expression#Right AST#expression#Right === AST#expression#Left 403 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 errorMessage += AST#expression#Left AST#template_literal#Left ` • 检查API访问权限 \n • 确认服务商地区限制 \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 . responseCode AST#member_expression#Right AST#expression#Right === AST#expression#Left 429 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 errorMessage += AST#expression#Left AST#template_literal#Left ` • 请求频率过高,请稍后重试 \n • 检查账户配额限制 \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 . responseCode AST#member_expression#Right AST#expression#Right >= AST#expression#Left 500 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 errorMessage += AST#expression#Left AST#template_literal#Left ` • 服务商服务器异常 \n • 请稍后重试 \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#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left errorMessage += AST#expression#Left AST#template_literal#Left ` • 检查网络连接 \n • 验证API地址是否正确 \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 AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_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 errorMessage 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#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 0x0000 AST#expression#Right , AST#expression#Left 'LLMConfigManager' AST#expression#Right , AST#expression#Left 'Chat request error: %{public}s' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right ) AST#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#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#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 AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right . includes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '🤖' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right . includes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '🚫' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right . includes 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#block_statement#Left { 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 AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#throw_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 networkError = AST#expression#Left AST#template_literal#Left ` 🌐 网络连接失败 \n \n ` 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#assignment_expression#Left networkError += 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 this AST#expression#Right . getNetworkErrorMessage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right \n \n ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left networkError += AST#expression#Left AST#template_literal#Left ` 解决建议: \n ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left networkError += AST#expression#Left AST#template_literal#Left ` • 检查网络连接状态 \n ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left networkError += AST#expression#Left AST#template_literal#Left ` • 确认防火墙设置 \n ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left networkError += AST#expression#Left AST#template_literal#Left ` • 验证API地址是否正确 \n ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left networkError += AST#expression#Left AST#template_literal#Left ` • 尝试切换网络环境 \n \n ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left networkError += AST#expression#Left AST#template_literal#Left ` 如果问题持续,请点击⚙️重新配置或联系技术支持。 ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#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 networkError 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 sendChatRequest(message: string, config?: LLMConfig, enableStream: boolean = false): Promise<string> {
const targetConfig = config || this.getDefaultConfig();
if (!targetConfig) {
throw new Error('⚠️ 未找到可用的大模型配置\n\n请点击右上角⚙️按钮配置您的AI模型:\n• 选择服务商(OpenAI、DeepSeek等)\n• 填入API密钥\n• 测试连接后保存\n\n配置完成后即可开始智能对话!');
}
try {
const headers: Record<string, string> = {
'Content-Type': 'application/json'
};
if (targetConfig.provider === 'openai') {
headers['Authorization'] = `Bearer ${targetConfig.apiKey}`;
} else if (targetConfig.provider === 'anthropic') {
headers['x-api-key'] = targetConfig.apiKey;
headers['anthropic-version'] = '2023-06-01';
} else if (targetConfig.provider === 'deepseek') {
headers['Authorization'] = `Bearer ${targetConfig.apiKey}`;
} else {
headers['Authorization'] = `Bearer ${targetConfig.apiKey}`;
}
const systemMessage: ChatMessage = {
role: 'system',
content: `# AI超级效能教练系统提示词
## 🎯 角色定位
你是"智能计划助手"应用的AI超级效能教练,拥有深厚的时间管理和效能优化专业知识。你的使命是帮助用户构建高效的工作生活管理体系,提升个人和团队效能。
## 📱 应用生态了解
用户正在使用的"智能计划助手"是一款基于HarmonyOS NEXT的专业效能管理应用,包含以下核心模块:
### 🏠 智能首页功能
- 个性化问候和今日概览
- 实时任务完成情况展示
- 专注时间和番茄钟统计
- 天气信息和快速功能入口
### 📝 智能计划管理
- **方法论模板**: GTD、四象限法、番茄工作法、时间块管理、看板方法、OKR目标管理
- **任务管理**: 智能分类、优先级设置、状态跟踪
- **模板系统**: 预设工作流程和批量操作
### 🍅 番茄钟执行中心
- 25分钟工作+5分钟休息的科学时间管理
- 任务与番茄钟绑定执行
- 实时专注统计和成果展示
- 灵活的暂停/重置/跳过控制
### 📊 数据统计分析
- 多维度可视化:周概览、日趋势、月完成率
- 习惯追踪热力图(5×7网格)
- 时间分析洞察:平均耗时、专注分布、黄金时段
- 成就系统和数据验证工具
### 🎓 效能学院
- 分层学习体系:基础→进阶→专家→定制
- 个性化方法论推荐
- 学习进度跟踪和认证体系
## 🧠 专业知识体系
### 核心方法论掌握
1. **GTD(Getting Things Done)**: 收集→整理→组织→回顾→执行
2. **艾森豪威尔矩阵**: 重要性×紧急性四象限分析
3. **番茄工作法**: 25分钟专注块+科学休息间隔
4. **时间块管理**: 日程时间段分配和边界控制
5. **看板方法**: 可视化工作流和WIP限制
6. **OKR**: 目标与关键结果的对齐管理
7. **精益思维**: 价值流优化和浪费消除
### 效能分析能力
- 根据用户数据识别效能瓶颈
- 基于完成率趋势提供改进建议
- 分析专注时间分布优化工作节奏
- 识别黄金工作时段和能量管理
## 💬 对话风格指南
### 回应原则
1. **专业权威**: 基于科学的时间管理理论
2. **实用导向**: 提供具体可执行的行动建议
3. **个性化**: 结合用户的应用使用情况
4. **积极正面**: 鼓励持续改进和成长心态
5. **简洁有效**: 避免冗长理论,突出核心要点
### 回应结构建议
- 🎯 **问题分析**: 快速识别用户核心需求
- 📋 **方法推荐**: 推荐适合的应用内功能和方法论
- ⚡ **行动指导**: 给出3-5个具体执行步骤
- 📊 **效果预期**: 说明预期改善效果
- 🔄 **后续跟进**: 建议如何监测和调整
## 🎨 互动增强
- 使用恰当的emoji增强表达力
- 引用应用内具体功能("在计划页面使用GTD模板")
- 结合用户可能的使用场景
- 提供渐进式的能力建设路径
## ⚠️ 注意事项
- 始终记住你在为"智能计划助手"用户服务
- 优先推荐应用内已有的功能和工具
- 避免推荐需要额外下载的外部工具
- 保持专业度,避免过度个人化的建议
现在,请基于以上背景,为用户提供专业、实用、个性化的效能管理指导。`
};
const userMessage: ChatMessage = {
role: 'user',
content: message
};
let chatRequest: ChatRequest;
let requestBody: string;
if (targetConfig.provider === 'anthropic') {
const anthropicRequest: AnthropicRequest = {
model: targetConfig.modelName,
max_tokens: 500,
messages: [userMessage],
system: systemMessage.content,
temperature: 0.7,
stream: enableStream
};
requestBody = JSON.stringify(anthropicRequest);
} else {
chatRequest = {
messages: [systemMessage, userMessage],
model: targetConfig.modelName,
max_tokens: 500,
temperature: 0.7,
stream: enableStream
};
requestBody = JSON.stringify(chatRequest);
}
hilog.info(0x0000, 'LLMConfigManager', 'Sending chat request to: %{public}s', targetConfig.url);
const httpRequest = http.createHttp();
const requestOptions: http.HttpRequestOptions = {
method: http.RequestMethod.POST,
header: headers,
extraData: requestBody,
expectDataType: http.HttpDataType.STRING,
connectTimeout: 30000,
readTimeout: 60000
};
const response = await httpRequest.request(targetConfig.url, requestOptions);
if (response.responseCode === 200) {
const responseBody = response.result as string;
hilog.info(0x0000, 'LLMConfigManager', 'Chat request successful, response length: %{public}d', responseBody.length);
try {
if (enableStream) {
return await this.parseStreamResponse(responseBody, targetConfig.provider);
} else {
const parsedResponse: Record<string, Object> = JSON.parse(responseBody);
return this.parseNonStreamResponse(parsedResponse, targetConfig.provider);
}
} catch (parseError) {
hilog.error(0x0000, 'LLMConfigManager', 'Response parse error: %{public}s', (parseError as Error).message);
throw new Error(`🤖 AI响应解析失败\n\n可能的原因:\n• 模型服务暂时异常\n• API响应格式变化\n• 网络传输问题\n\n请稍后重试,或检查配置是否正确。`);
}
} else {
hilog.error(0x0000, 'LLMConfigManager', 'HTTP error code: %{public}d', response.responseCode);
let errorMessage = `🚫 连接${targetConfig.provider.toUpperCase()}服务失败\n\n`;
errorMessage += `错误代码:${response.responseCode}\n`;
errorMessage += `错误描述:${this.getHttpErrorMessage(response.responseCode)}\n\n`;
errorMessage += `解决建议:\n`;
if (response.responseCode === 401) {
errorMessage += `• 检查API密钥是否正确\n• 确认密钥是否已过期\n• 验证账户余额是否充足`;
} else if (response.responseCode === 403) {
errorMessage += `• 检查API访问权限\n• 确认服务商地区限制\n• 验证账户状态`;
} else if (response.responseCode === 429) {
errorMessage += `• 请求频率过高,请稍后重试\n• 检查账户配额限制\n• 考虑升级服务套餐`;
} else if (response.responseCode >= 500) {
errorMessage += `• 服务商服务器异常\n• 请稍后重试\n• 可尝试切换其他模型`;
} else {
errorMessage += `• 检查网络连接\n• 验证API地址是否正确\n• 重新测试配置`;
}
throw new Error(errorMessage);
}
} catch (error) {
hilog.error(0x0000, 'LLMConfigManager', 'Chat request error: %{public}s', (error as Error).message);
if ((error as Error).message.includes('🤖') || (error as Error).message.includes('🚫') || (error as Error).message.includes('⚠️')) {
throw new Error((error as Error).message);
}
let networkError = `🌐 网络连接失败\n\n`;
networkError += `详细信息:${this.getNetworkErrorMessage((error as Error).message)}\n\n`;
networkError += `解决建议:\n`;
networkError += `• 检查网络连接状态\n`;
networkError += `• 确认防火墙设置\n`;
networkError += `• 验证API地址是否正确\n`;
networkError += `• 尝试切换网络环境\n\n`;
networkError += `如果问题持续,请点击⚙️重新配置或联系技术支持。`;
throw new Error(networkError);
}
}
|
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/viewmodel/LLMConfigManager.ets#L324-L544
|
f3b58de3e45acd3e8dbd8cc958a9335398a32ca0
|
github
|
jxdiaodeyi/YX_Sports.git
|
af5346bd3d5003c33c306ff77b4b5e9184219893
|
YX_Sports/oh_modules/.ohpm/@pura+spinkit@1.0.5/oh_modules/@pura/spinkit/src/main/ets/components/SpinA.ets
|
arkts
|
SpinA
|
TODO SpinKit动画组件
author: 桃花镇童长老
since: 2024/05/01
仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fspinkit
github: https://github.com/787107497
gitee: https://gitee.com/tongyuyan/spinkit
QQ交流群: 569512366
|
@ComponentV2
export struct SpinA {
@Require @Param spinSize: number;
@Require @Param spinColor: ResourceColor;
@Local x: number = 0;
@Local y: number = 0;
@Local angle: number = 0;
build() {
Canvas()
.width(this.spinSize)
.height(this.spinSize)
.backgroundColor(this.spinColor)
.renderFit(RenderFit.CENTER)
.shadow(ShadowStyle.OUTER_DEFAULT_XS)
.rotate({ perspective: this.spinSize, x: this.x, y: this.y, angle: this.angle })
.onAppear(() => {
this.getUIContext().keyframeAnimateTo({ iterations: -1, delay: 0 }, [
{
duration: 600,
curve: Curve.EaseInOut,
event: () => {
this.angle = 180
this.x = this.spinSize/2
this.y = 0
}
},
{
duration: 0,
curve: Curve.EaseInOut,
event: () => {
this.angle = 0
}
},
{
duration: 600,
curve: Curve.EaseInOut,
event: () => {
this.angle = 180
this.x = 0
this.y = this.spinSize/2
}
}
])
})
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ ComponentV2 AST#decorator#Right export struct SpinA AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Require AST#decorator#Right AST#decorator#Left @ Param AST#decorator#Right spinSize : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Require AST#decorator#Right AST#decorator#Left @ Param AST#decorator#Right spinColor : AST#type_annotation#Left AST#primary_type#Left ResourceColor AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right 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 AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right y : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right angle : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Canvas ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . spinSize AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . spinSize AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . spinColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . renderFit ( AST#expression#Left AST#member_expression#Left AST#expression#Left RenderFit AST#expression#Right . CENTER AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . shadow ( AST#expression#Left AST#member_expression#Left AST#expression#Left ShadowStyle AST#expression#Right . OUTER_DEFAULT_XS AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . rotate ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left perspective AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . spinSize AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . x AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . y AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left angle AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . angle AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onAppear ( 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getUIContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . keyframeAnimateTo 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 iterations AST#property_name#Right : AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_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 0 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left 600 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left curve AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Curve AST#expression#Right . EaseInOut AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left event AST#property_name#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 . angle AST#member_expression#Right = AST#expression#Left 180 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 . x 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 . spinSize AST#member_expression#Right AST#expression#Right / AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . y AST#member_expression#Right = AST#expression#Left 0 AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left curve AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Curve AST#expression#Right . EaseInOut AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left event AST#property_name#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 . angle AST#member_expression#Right = AST#expression#Left 0 AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left 600 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left curve AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Curve AST#expression#Right . EaseInOut AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left event AST#property_name#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 . angle AST#member_expression#Right = AST#expression#Left 180 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 . x AST#member_expression#Right = AST#expression#Left 0 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 . y 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 . spinSize AST#member_expression#Right AST#expression#Right / AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@ComponentV2
export struct SpinA {
@Require @Param spinSize: number;
@Require @Param spinColor: ResourceColor;
@Local x: number = 0;
@Local y: number = 0;
@Local angle: number = 0;
build() {
Canvas()
.width(this.spinSize)
.height(this.spinSize)
.backgroundColor(this.spinColor)
.renderFit(RenderFit.CENTER)
.shadow(ShadowStyle.OUTER_DEFAULT_XS)
.rotate({ perspective: this.spinSize, x: this.x, y: this.y, angle: this.angle })
.onAppear(() => {
this.getUIContext().keyframeAnimateTo({ iterations: -1, delay: 0 }, [
{
duration: 600,
curve: Curve.EaseInOut,
event: () => {
this.angle = 180
this.x = this.spinSize/2
this.y = 0
}
},
{
duration: 0,
curve: Curve.EaseInOut,
event: () => {
this.angle = 0
}
},
{
duration: 600,
curve: Curve.EaseInOut,
event: () => {
this.angle = 180
this.x = 0
this.y = this.spinSize/2
}
}
])
})
}
}
|
https://github.com/jxdiaodeyi/YX_Sports.git/blob/af5346bd3d5003c33c306ff77b4b5e9184219893/YX_Sports/oh_modules/.ohpm/@pura+spinkit@1.0.5/oh_modules/@pura/spinkit/src/main/ets/components/SpinA.ets#L26-L72
|
dcb054cb766da207c52c1207af9edca547a3d739
|
github
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/3des_ecb_encryption_decryption_synchronous.ets
|
arkts
|
decryptMessage
|
解密消息
|
function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) {
let decoder = cryptoFramework.createCipher('3DES192|ECB|PKCS7');
decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, null);
let decryptData = decoder.doFinalSync(cipherText);
return decryptData;
}
|
AST#function_declaration#Left function decryptMessage AST#parameter_list#Left ( AST#parameter#Left symKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . SymKey AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left cipherText : 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_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left decoder = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createCipher AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '3DES192|ECB|PKCS7' 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 decoder AST#expression#Right . initSync 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 cryptoFramework AST#expression#Right . CryptoMode AST#member_expression#Right AST#expression#Right . DECRYPT_MODE AST#member_expression#Right AST#expression#Right , AST#expression#Left symKey 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 ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left decryptData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left decoder AST#expression#Right . doFinalSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left cipherText 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 decryptData AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
|
function decryptMessage(symKey: cryptoFramework.SymKey, cipherText: cryptoFramework.DataBlob) {
let decoder = cryptoFramework.createCipher('3DES192|ECB|PKCS7');
decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, null);
let decryptData = decoder.doFinalSync(cipherText);
return decryptData;
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/Security/CryptoArchitectureKit/EncryptionDecryption/EncryptionDecryptionGuidance3DES/entry/src/main/ets/pages/3des_ecb_encryption_decryption_synchronous.ets#L29-L34
|
87510abac97e2a741ed1f3993fda0764a076578b
|
gitee
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Media/ImageEdit/entry/src/main/ets/utils/MathUtils.ets
|
arkts
|
limitRectInRotated
|
Rotating, limit in rect.
@param rect
@param outerLines
|
static limitRectInRotated(rect: RectF, outerLines: Array<LineSegment>): void {
let copy = new RectF();
copy.set(rect.left, rect.top, rect.right, rect.bottom);
let diagonal1 = new LineSegment(new Point(copy.left, copy.top), new Point(copy.right, copy.bottom));
for (let line of outerLines) {
MathUtils.limitCornerIfLineIntersect(line, diagonal1, copy);
}
let diagonal2 = new LineSegment(new Point(copy.left, copy.bottom), new Point(copy.right, copy.top));
for (let line of outerLines) {
MathUtils.limitCornerIfLineIntersect(line, diagonal2, copy);
}
rect.set(copy.left, copy.top, copy.right, copy.bottom);
}
|
AST#method_declaration#Left static limitRectInRotated AST#parameter_list#Left ( AST#parameter#Left rect : AST#type_annotation#Left AST#primary_type#Left RectF AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left outerLines : 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 LineSegment AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 copy = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left RectF 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 copy 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 rect AST#expression#Right . left AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left rect AST#expression#Right . top AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left rect AST#expression#Right . right AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left rect AST#expression#Right . bottom 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 diagonal1 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left LineSegment 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#new_expression#Left new AST#expression#Left Point AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left copy AST#expression#Right . left AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left copy AST#expression#Right . top 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 Point AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left copy AST#expression#Right . right AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left copy AST#expression#Right . bottom 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( let line of AST#expression#Left outerLines 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 MathUtils AST#expression#Right . limitCornerIfLineIntersect AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left line AST#expression#Right , AST#expression#Left diagonal1 AST#expression#Right , AST#expression#Left copy AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left diagonal2 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left LineSegment 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#new_expression#Left new AST#expression#Left Point AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left copy AST#expression#Right . left AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left copy AST#expression#Right . bottom 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 Point AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left copy AST#expression#Right . right AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left copy AST#expression#Right . top 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( let line of AST#expression#Left outerLines 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 MathUtils AST#expression#Right . limitCornerIfLineIntersect AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left line AST#expression#Right , AST#expression#Left diagonal2 AST#expression#Right , AST#expression#Left copy AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left rect 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 copy AST#expression#Right . left AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left copy AST#expression#Right . top AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left copy AST#expression#Right . right AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left copy AST#expression#Right . bottom 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
|
static limitRectInRotated(rect: RectF, outerLines: Array<LineSegment>): void {
let copy = new RectF();
copy.set(rect.left, rect.top, rect.right, rect.bottom);
let diagonal1 = new LineSegment(new Point(copy.left, copy.top), new Point(copy.right, copy.bottom));
for (let line of outerLines) {
MathUtils.limitCornerIfLineIntersect(line, diagonal1, copy);
}
let diagonal2 = new LineSegment(new Point(copy.left, copy.bottom), new Point(copy.right, copy.top));
for (let line of outerLines) {
MathUtils.limitCornerIfLineIntersect(line, diagonal2, copy);
}
rect.set(copy.left, copy.top, copy.right, copy.bottom);
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Media/ImageEdit/entry/src/main/ets/utils/MathUtils.ets#L299-L312
|
732e9b947cee61f97083ee599b31ae17e4db46d5
|
gitee
|
salehelper/algorithm_arkts.git
|
61af15272038646775a4745fca98a48ba89e1f4e
|
entry/src/main/ets/sorting/MergeSort.ets
|
arkts
|
归并排序实现
|
export class MergeSort {
/**
* 归并排序算法
* @param arr 需要排序的数组
* @returns 排序后的数组
*/
public static sort(arr: number[]): number[] {
const result = [...arr];
MergeSort.mergeSort(result, 0, result.length - 1);
return result;
}
/**
* 归并排序的递归实现
* @param arr 需要排序的数组
* @param left 左边界
* @param right 右边界
*/
private static mergeSort(arr: number[], left: number, right: number): void {
if (left < right) {
const mid = Math.floor((left + right) / 2);
// 递归排序左半部分
MergeSort.mergeSort(arr, left, mid);
// 递归排序右半部分
MergeSort.mergeSort(arr, mid + 1, right);
// 合并两个有序数组
MergeSort.merge(arr, left, mid, right);
}
}
/**
* 合并两个有序数组
* @param arr 需要合并的数组
* @param left 左边界
* @param mid 中间位置
* @param right 右边界
*/
private static merge(arr: number[], left: number, mid: number, right: number): void {
// 创建临时数组
const temp: number[] = new Array(right - left + 1);
let i = left; // 左半部分起始位置
let j = mid + 1; // 右半部分起始位置
let k = 0; // 临时数组的索引
// 合并两个有序数组
while (i <= mid && j <= right) {
if (arr[i] <= arr[j]) {
temp[k++] = arr[i++];
} else {
temp[k++] = arr[j++];
}
}
// 复制左半部分剩余元素
while (i <= mid) {
temp[k++] = arr[i++];
}
|
AST#export_declaration#Left export AST#class_declaration#Left class MergeSort AST#class_body#Left { /**
* 归并排序算法
* @param arr 需要排序的数组
* @returns 排序后的数组
*/ AST#method_declaration#Left public static sort AST#parameter_list#Left ( AST#parameter#Left arr : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left result = AST#expression#Left AST#array_literal#Left [ ... AST#expression#Left arr 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left MergeSort AST#expression#Right . mergeSort AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left result AST#expression#Right , AST#expression#Left 0 AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left result 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#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 result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 归并排序的递归实现
* @param arr 需要排序的数组
* @param left 左边界
* @param right 右边界
*/ AST#method_declaration#Left private static mergeSort AST#parameter_list#Left ( AST#parameter#Left arr : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left left : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left left AST#expression#Right < AST#expression#Left right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left mid = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left left AST#expression#Right + AST#expression#Left right AST#expression#Right AST#binary_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#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 MergeSort AST#expression#Right . mergeSort AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left arr AST#expression#Right , AST#expression#Left left AST#expression#Right , AST#expression#Left mid 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 MergeSort AST#expression#Right . mergeSort AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left arr AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left mid AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left 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 MergeSort AST#expression#Right . merge AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left arr AST#expression#Right , AST#expression#Left left AST#expression#Right , AST#expression#Left mid AST#expression#Right , AST#expression#Left 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 arr 需要合并的数组
* @param left 左边界
* @param mid 中间位置
* @param right 右边界
*/ AST#property_declaration#Left private static merge AST#ERROR#Left AST#parameter_list#Left ( AST#parameter#Left arr : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left left : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left mid : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right { // 创建临时数组 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left temp : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Array AST#expression#Right AST#new_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 right AST#expression#Right - AST#expression#Left left AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#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 i = AST#expression#Left left 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 j = AST#expression#Left AST#binary_expression#Left AST#expression#Left mid AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 右半部分起始位置 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left k = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 临时数组的索引 // 合并两个有序数组 AST#statement#Left AST#while_statement#Left while ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right <= AST#expression#Left mid AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left j AST#expression#Right <= AST#expression#Left right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left arr AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right <= AST#expression#Left AST#subscript_expression#Left AST#expression#Left arr AST#expression#Right [ AST#expression#Left j AST#expression#Right ] AST#subscript_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#subscript_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left temp AST#expression#Right [ AST#expression#Left AST#update_expression#Left AST#expression#Left k AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left = arr AST#ERROR#Right [ AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left temp AST#expression#Right [ AST#expression#Left AST#update_expression#Left AST#expression#Left k AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left = arr AST#ERROR#Right [ AST#expression#Left AST#update_expression#Left AST#expression#Left j AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#while_statement#Right AST#statement#Right // 复制左半部分剩余元素 while ( AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right <= AST#expression#Left mid AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression#Left AST#subscript_expression#Left AST#expression#Left temp AST#expression#Right [ AST#expression#Left AST#update_expression#Left AST#expression#Left k AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left arr 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#subscript_expression#Right AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class MergeSort {
public static sort(arr: number[]): number[] {
const result = [...arr];
MergeSort.mergeSort(result, 0, result.length - 1);
return result;
}
private static mergeSort(arr: number[], left: number, right: number): void {
if (left < right) {
const mid = Math.floor((left + right) / 2);
MergeSort.mergeSort(arr, left, mid);
MergeSort.mergeSort(arr, mid + 1, right);
MergeSort.merge(arr, left, mid, right);
}
}
private static merge(arr: number[], left: number, mid: number, right: number): void {
const temp: number[] = new Array(right - left + 1);
let i = left;
let j = mid + 1;
let k = 0;
while (i <= mid && j <= right) {
if (arr[i] <= arr[j]) {
temp[k++] = arr[i++];
} else {
temp[k++] = arr[j++];
}
}
while (i <= mid) {
temp[k++] = arr[i++];
}
|
https://github.com/salehelper/algorithm_arkts.git/blob/61af15272038646775a4745fca98a48ba89e1f4e/entry/src/main/ets/sorting/MergeSort.ets#L4-L61
|
baaee2df55f2ad1c522743f9d9960338cf8ccde8
|
github
|
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/game/InteractiveGameService.ets
|
arkts
|
游戏状态枚举
|
export enum GameState {
NOT_STARTED = 'not_started',
PLAYING = 'playing',
PAUSED = 'paused',
COMPLETED = 'completed',
FAILED = 'failed'
}
|
AST#export_declaration#Left export AST#enum_declaration#Left enum GameState AST#enum_body#Left { AST#enum_member#Left NOT_STARTED = AST#expression#Left 'not_started' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left PLAYING = AST#expression#Left 'playing' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left PAUSED = AST#expression#Left 'paused' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left COMPLETED = AST#expression#Left 'completed' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left FAILED = AST#expression#Left 'failed' AST#expression#Right AST#enum_member#Right } AST#enum_body#Right AST#enum_declaration#Right AST#export_declaration#Right
|
export enum GameState {
NOT_STARTED = 'not_started',
PLAYING = 'playing',
PAUSED = 'paused',
COMPLETED = 'completed',
FAILED = 'failed'
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/game/InteractiveGameService.ets#L40-L46
|
f098053c9405158484d2e9389bd9533f66c86fbd
|
github
|
|
RicardoWesleyli/HarmonyNEXT_Examples.git
|
6a9cc1a06e3c7b126faa61ccf1b91ac6cea47670
|
Chapter6/entry/src/main/ets/pages/Index.ets
|
arkts
|
bgColorView
|
背景颜色代码块
|
@Builder
bgColorView(){
Column()
.width('100%')
.height('100%')
.linearGradient({
colors: [[0x007BFF, 0.0], [Color.White, 1.0]]
})
.expandSafeArea([SafeAreaType.SYSTEM])
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right bgColorView AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#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 . linearGradient ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left colors AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#array_literal#Left [ AST#expression#Left 0x007BFF AST#expression#Right , AST#expression#Left 0.0 AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right , AST#expression#Left 1.0 AST#expression#Right ] AST#array_literal#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . expandSafeArea ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left SafeAreaType AST#expression#Right . SYSTEM AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#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
bgColorView(){
Column()
.width('100%')
.height('100%')
.linearGradient({
colors: [[0x007BFF, 0.0], [Color.White, 1.0]]
})
.expandSafeArea([SafeAreaType.SYSTEM])
}
|
https://github.com/RicardoWesleyli/HarmonyNEXT_Examples.git/blob/6a9cc1a06e3c7b126faa61ccf1b91ac6cea47670/Chapter6/entry/src/main/ets/pages/Index.ets#L102-L111
|
cfa0fb24bb053121827bce996f7d66438fdd9c2a
|
github
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
ef_crypto/src/main/ets/crypto/encryption/SHA1.ets
|
arkts
|
rol
|
Bitwise rotate a 32-bit number to the left.
32位二进制数循环左移
|
rol(num: number, cnt: number) {
return (num << cnt) | (num >> (32 - cnt));
}
|
AST#method_declaration#Left rol AST#parameter_list#Left ( AST#parameter#Left num : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left cnt : 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#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left num AST#expression#Right << AST#expression#Left cnt 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 num AST#expression#Right >> AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 32 AST#expression#Right - AST#expression#Left cnt 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#parenthesized_expression#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
|
rol(num: number, cnt: number) {
return (num << cnt) | (num >> (32 - cnt));
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto/src/main/ets/crypto/encryption/SHA1.ets#L185-L189
|
54494a4d5b730b8ec61fdaa78fdcf7ff495ac0e8
|
gitee
|
Piagari/arkts_example.git
|
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
|
hmos_app-main/hmos_app-main/OfficeAttendance-master/commons/common_lib/src/main/ets/utils/RouterModule.ets
|
arkts
|
push
|
跳转到指定路由栈的指定路由页面
|
public static push(info: NavRouterInfo, animated?: boolean) {
try {
if (info.onPop) {
RouterModule._stack.pushPathByName(info.url, info.param, info.onPop, animated);
} else {
RouterModule._stack.pushPathByName(info.url, info.param, animated);
}
} catch (err) {
Logger.error(TAG, 'navigation stack push failed::' + JSON.stringify(err));
}
}
|
AST#method_declaration#Left public static push AST#parameter_list#Left ( AST#parameter#Left info : AST#type_annotation#Left AST#primary_type#Left NavRouterInfo AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left animated ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#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#member_expression#Left AST#expression#Left info AST#expression#Right . onPop 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 RouterModule AST#expression#Right . _stack AST#member_expression#Right AST#expression#Right . pushPathByName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left info AST#expression#Right . url AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left info AST#expression#Right . param AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left info AST#expression#Right . onPop AST#member_expression#Right AST#expression#Right , AST#expression#Left animated 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 RouterModule AST#expression#Right . _stack AST#member_expression#Right AST#expression#Right . pushPathByName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left info AST#expression#Right . url AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left info AST#expression#Right . param AST#member_expression#Right AST#expression#Right , AST#expression#Left animated AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'navigation stack push failed::' AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public static push(info: NavRouterInfo, animated?: boolean) {
try {
if (info.onPop) {
RouterModule._stack.pushPathByName(info.url, info.param, info.onPop, animated);
} else {
RouterModule._stack.pushPathByName(info.url, info.param, animated);
}
} catch (err) {
Logger.error(TAG, 'navigation stack push failed::' + JSON.stringify(err));
}
}
|
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/OfficeAttendance-master/commons/common_lib/src/main/ets/utils/RouterModule.ets#L14-L24
|
86d93359c0ef210d9281a15bce8c9de10e6e7f49
|
github
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/app/views/GridSegmentedPicker.ets
|
arkts
|
generateColumnsTemplate
|
生成网格列模板字符串
@returns 列模板字符串,如 "1fr 1fr 1fr"
|
private generateColumnsTemplate(): string {
// 如果尚未计算出列数或列数无效,返回默认一列模板
if (this.calculatedCols <= 0) {
return '1fr';
}
// 使用 repeat() 函数生成列模板,例如 repeat(3, 1fr) 表示三等分
return `repeat(${this.calculatedCols}, 1fr)`;
}
|
AST#method_declaration#Left private generateColumnsTemplate AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 如果尚未计算出列数或列数无效,返回默认一列模板 AST#statement#Left AST#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 . calculatedCols 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 '1fr' AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 使用 repeat() 函数生成列模板,例如 repeat(3, 1fr) 表示三等分 AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#template_literal#Left ` repeat( AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . calculatedCols AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , 1fr) ` AST#template_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private generateColumnsTemplate(): string {
if (this.calculatedCols <= 0) {
return '1fr';
}
return `repeat(${this.calculatedCols}, 1fr)`;
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/app/views/GridSegmentedPicker.ets#L127-L134
|
d8c931cb5edc17c5b478bb2b820134f289629889
|
github
|
openharmony/interface_sdk-js
|
c349adc73e2ec1f61f6fca489b5af059e3ed6999
|
api/@ohos.arkui.advanced.ToolBar.d.ets
|
arkts
|
Declare ToolBarModifier use in ToolBar
@syscap SystemCapability.ArkUI.ArkUI.Full
@atomicservice
@since 13
Declare ToolBarModifier use in ToolBar
@syscap SystemCapability.ArkUI.ArkUI.Full
@crossplatform
@atomicservice
@since 18
|
export declare class ToolBarModifier {
/**
* Sets the height of the toolBar.
*
* @param { LengthMetrics } height - toolBar's height.
* @returns { ToolBarModifier } returns the instance of the ToolBarModifier.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 13
*/
/**
* Sets the height of the toolBar.
*
* @param { LengthMetrics } height - toolBar's height.
* @returns { ToolBarModifier } returns the instance of the ToolBarModifier.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 18
*/
height(height: LengthMetrics): ToolBarModifier;
/**
* Sets the backgroundColor of the toolBar.
*
* @param { ResourceColor } backgroundColor - toolBar's backgroundColor.
* @returns { ToolBarModifier } returns the instance of the ToolBarModifier.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 13
*/
/**
* Sets the backgroundColor of the toolBar.
*
* @param { ResourceColor } backgroundColor - toolBar's backgroundColor.
* @returns { ToolBarModifier } returns the instance of the ToolBarModifier.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 18
*/
backgroundColor(backgroundColor: ResourceColor): ToolBarModifier;
/**
* Sets the left and right padding of the toolbar.
*
* @param { LengthMetrics } padding - left and right padding.
* @returns { ToolBarModifier } returns the instance of the ToolBarModifier.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 13
*/
/**
* Sets the left and right padding of the toolbar.
*
* @param { LengthMetrics } padding - left and right padding.
* @returns { ToolBarModifier } returns the instance of the ToolBarModifier.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 18
*/
padding(padding: LengthMetrics): ToolBarModifier;
/**
* Sets whether or not to display the press status effect.
*
* @param { boolean } stateEffect - press status effect.
* @returns { ToolBarModifier } returns the instance of the ToolBarModifier.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 13
*/
/**
* Sets whether or not to display the press status effect.
*
* @param { boolean } stateEffect - press status effect.
* @returns { ToolBarModifier } returns the instance of the ToolBarModifier.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 18
*/
stateEffect(stateEffect: boolean): ToolBarModifier;
}
|
AST#export_declaration#Left export AST#ERROR#Left declare AST#ERROR#Right AST#class_declaration#Left class ToolBarModifier AST#class_body#Left { /**
* Sets the height of the toolBar.
*
* @param { LengthMetrics } height - toolBar's height.
* @returns { ToolBarModifier } returns the instance of the ToolBarModifier.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 13
*/ /**
* Sets the height of the toolBar.
*
* @param { LengthMetrics } height - toolBar's height.
* @returns { ToolBarModifier } returns the instance of the ToolBarModifier.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 18
*/ AST#method_declaration#Left height AST#parameter_list#Left ( AST#parameter#Left height : AST#type_annotation#Left AST#primary_type#Left LengthMetrics AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left ToolBarModifier AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right /**
* Sets the backgroundColor of the toolBar.
*
* @param { ResourceColor } backgroundColor - toolBar's backgroundColor.
* @returns { ToolBarModifier } returns the instance of the ToolBarModifier.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 13
*/ /**
* Sets the backgroundColor of the toolBar.
*
* @param { ResourceColor } backgroundColor - toolBar's backgroundColor.
* @returns { ToolBarModifier } returns the instance of the ToolBarModifier.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 18
*/ AST#method_declaration#Left backgroundColor AST#parameter_list#Left ( AST#parameter#Left backgroundColor : AST#type_annotation#Left AST#primary_type#Left ResourceColor AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left ToolBarModifier AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right /**
* Sets the left and right padding of the toolbar.
*
* @param { LengthMetrics } padding - left and right padding.
* @returns { ToolBarModifier } returns the instance of the ToolBarModifier.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 13
*/ /**
* Sets the left and right padding of the toolbar.
*
* @param { LengthMetrics } padding - left and right padding.
* @returns { ToolBarModifier } returns the instance of the ToolBarModifier.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 18
*/ AST#method_declaration#Left padding AST#parameter_list#Left ( AST#parameter#Left padding : AST#type_annotation#Left AST#primary_type#Left LengthMetrics AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left ToolBarModifier AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right /**
* Sets whether or not to display the press status effect.
*
* @param { boolean } stateEffect - press status effect.
* @returns { ToolBarModifier } returns the instance of the ToolBarModifier.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 13
*/ /**
* Sets whether or not to display the press status effect.
*
* @param { boolean } stateEffect - press status effect.
* @returns { ToolBarModifier } returns the instance of the ToolBarModifier.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 18
*/ AST#method_declaration#Left stateEffect AST#parameter_list#Left ( AST#parameter#Left stateEffect : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left ToolBarModifier 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 declare class ToolBarModifier {
height(height: LengthMetrics): ToolBarModifier;
backgroundColor(backgroundColor: ResourceColor): ToolBarModifier;
padding(padding: LengthMetrics): ToolBarModifier;
stateEffect(stateEffect: boolean): ToolBarModifier;
}
|
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.arkui.advanced.ToolBar.d.ets#L416-L497
|
842f57b0832fe12a956f8a8c6009947e06efd58a
|
gitee
|
|
Piagari/arkts_example.git
|
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
|
hmos_app-main/hmos_app-main/MoneyTrack-master/commons/commonlib/src/main/ets/utils/router/Router.ets
|
arkts
|
replace
|
将指定路由栈的栈顶页面退出,将info指定的NavDestination页面信息入栈
|
public static replace(info: NavRouterInfo) {
try {
RouterModule._stack.replacePathByName(info.url, info.param);
} catch (err) {
Logger.error(
TAG,
'navigation stack replace failed::' + JSON.stringify(err),
);
}
}
|
AST#method_declaration#Left public static replace AST#parameter_list#Left ( AST#parameter#Left info : AST#type_annotation#Left AST#primary_type#Left NavRouterInfo AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left RouterModule AST#expression#Right . _stack AST#member_expression#Right AST#expression#Right . replacePathByName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left info AST#expression#Right . url AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left info AST#expression#Right . param AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'navigation stack replace failed::' 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 static replace(info: NavRouterInfo) {
try {
RouterModule._stack.replacePathByName(info.url, info.param);
} catch (err) {
Logger.error(
TAG,
'navigation stack replace failed::' + JSON.stringify(err),
);
}
}
|
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/MoneyTrack-master/commons/commonlib/src/main/ets/utils/router/Router.ets#L28-L37
|
3247edaed2de5a2fb66083d7a158a075cd7075fe
|
github
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/pipwindow/src/main/ets/model/AVPlayer.ets
|
arkts
|
getPause
|
暂停视频
|
getPause() {
if (this.isCreate) {
this.avPlayer.pause();
}
}
|
AST#method_declaration#Left getPause AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isCreate 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . avPlayer 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
|
getPause() {
if (this.isCreate) {
this.avPlayer.pause();
}
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/pipwindow/src/main/ets/model/AVPlayer.ets#L93-L97
|
b3389249851033f8a20af1a1a79c81de5b82eb85
|
gitee
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/DocsSample/ArkUISample/DialogProject/entry/src/main/ets/pages/opencustomdialog/openCustomDialog.ets
|
arkts
|
aboutToAppear
|
[End create_component_content]
|
aboutToAppear(): void {
PromptActionClass.setContext(this.ctx);
PromptActionClass.setContentNode(this.contentNode);
PromptActionClass.setOptions({ alignment: DialogAlignment.Top, offset: { dx: 0, dy: 50 } });
}
|
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 PromptActionClass AST#expression#Right . setContext 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 . ctx 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 PromptActionClass AST#expression#Right . setContentNode 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 . 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 PromptActionClass AST#expression#Right . setOptions 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 alignment AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left DialogAlignment AST#expression#Right . Top 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 AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left dx AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left dy AST#property_name#Right : AST#expression#Left 50 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
aboutToAppear(): void {
PromptActionClass.setContext(this.ctx);
PromptActionClass.setContentNode(this.contentNode);
PromptActionClass.setOptions({ alignment: DialogAlignment.Top, offset: { dx: 0, dy: 50 } });
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ArkUISample/DialogProject/entry/src/main/ets/pages/opencustomdialog/openCustomDialog.ets#L98-L102
|
3d251b50610d8afa91f35a02ea3136025c52cefe
|
gitee
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/models/datas/basedict/utils/BaseWordUtility.ets
|
arkts
|
getLengthOfStringWithoutKind
|
/ 查找去除kind之后的字符串长度
|
static getLengthOfStringWithoutKind(str: string): number {
const strPoint = BaseWordUtility.STR_POINT_HALF;
const indexNoFound = -1;
let strLength = 0;
if (str != null) {
strLength = str.length;
const index = str.indexOf(strPoint);
if (index !== indexNoFound) {
strLength = str.substring(index).length;
}
}
return strLength;
}
|
AST#method_declaration#Left static getLengthOfStringWithoutKind AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left strPoint = AST#expression#Left AST#member_expression#Left AST#expression#Left BaseWordUtility AST#expression#Right . STR_POINT_HALF 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 indexNoFound = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_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 strLength = AST#expression#Left 0 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 str 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#assignment_expression#Left strLength = AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . length 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 const AST#variable_declarator#Left index = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left strPoint 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 index AST#expression#Right !== AST#expression#Left indexNoFound 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 strLength = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . substring 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 . length 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#if_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 strLength AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static getLengthOfStringWithoutKind(str: string): number {
const strPoint = BaseWordUtility.STR_POINT_HALF;
const indexNoFound = -1;
let strLength = 0;
if (str != null) {
strLength = str.length;
const index = str.indexOf(strPoint);
if (index !== indexNoFound) {
strLength = str.substring(index).length;
}
}
return strLength;
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/datas/basedict/utils/BaseWordUtility.ets#L116-L129
|
57abb2fdb40b0f6ea6f52ed5427c818ec9f01c27
|
github
|
openharmony/graphic_graphic_2d
|
46a11e91c9709942196ad2a7afea2e0fcd1349f3
|
interfaces/kits/ani/ui_effect/ets/@ohos.graphics.uiEffect.ets
|
arkts
|
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.
|
export interface BrightnessBlenderParam {
cubicRate: number;
quadraticRate: number;
linearRate: number;
degree: number;
saturation: number;
positiveCoefficient: [number, number, number];
negativeCoefficient: [number, number, number];
fraction: number;
}
|
AST#export_declaration#Left export AST#interface_declaration#Left interface BrightnessBlenderParam AST#object_type#Left { AST#type_member#Left cubicRate : 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 quadraticRate : 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 linearRate : 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 degree : 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 saturation : 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 positiveCoefficient : AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ AST#type_annotation#Left AST#primary_type#Left number 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_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left negativeCoefficient : AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ AST#type_annotation#Left AST#primary_type#Left number 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_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left fraction : 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 BrightnessBlenderParam {
cubicRate: number;
quadraticRate: number;
linearRate: number;
degree: number;
saturation: number;
positiveCoefficient: [number, number, number];
negativeCoefficient: [number, number, number];
fraction: number;
}
|
https://github.com/openharmony/graphic_graphic_2d/blob/46a11e91c9709942196ad2a7afea2e0fcd1349f3/interfaces/kits/ani/ui_effect/ets/@ohos.graphics.uiEffect.ets#L16-L25
|
1922d6d864ba64e6901e25aaf37169122d7fdb28
|
gitee
|
|
wuyuanwuhui99/harmony-arkts-music-app-ui.git
|
fc75b993b76293666f9122f527ea3bc6caf7f75c
|
entry/src/main/ets/utils/PreferenceModel.ets
|
arkts
|
getPreferencesFromStorage
|
初始化Preferences首选项
|
async getPreferencesFromStorage() {
try {
preference = await dataPreferences.getPreferences(context, 'mystore')
} catch (err) {
console.error(err)
}
}
|
AST#method_declaration#Left async getPreferencesFromStorage 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left preference = 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 dataPreferences AST#expression#Right AST#await_expression#Right AST#expression#Right . getPreferences AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left 'mystore' 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 ( 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 err 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 getPreferencesFromStorage() {
try {
preference = await dataPreferences.getPreferences(context, 'mystore')
} catch (err) {
console.error(err)
}
}
|
https://github.com/wuyuanwuhui99/harmony-arkts-music-app-ui.git/blob/fc75b993b76293666f9122f527ea3bc6caf7f75c/entry/src/main/ets/utils/PreferenceModel.ets#L8-L14
|
09427513d1af8d86afa33923f25e0d94f9afc961
|
github
|
openharmony/interface_sdk-js
|
c349adc73e2ec1f61f6fca489b5af059e3ed6999
|
api/@ohos.atomicservice.AtomicServiceWeb.d.ets
|
arkts
|
Page end event at the end of web page loading.
@typedef OnPageEndEvent
@syscap SystemCapability.ArkUI.ArkUI.Full
@atomicservice
@since 12
|
export declare interface OnPageEndEvent {
/**
* The url of page.
*
* @type { string }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
url: string;
}
|
AST#export_declaration#Left export AST#ERROR#Left declare AST#ERROR#Right AST#interface_declaration#Left interface OnPageEndEvent AST#object_type#Left { /**
* The url of page.
*
* @type { string }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#type_member#Left url : 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 declare interface OnPageEndEvent {
url: string;
}
|
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.atomicservice.AtomicServiceWeb.d.ets#L284-L294
|
ab751d28b8e5a0d8ab72bdf3dc4a249ccd1a7813
|
gitee
|
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/pages/greetings/GreetingSendPage.ets
|
arkts
|
selectAISuggestion
|
选择AI建议
|
private selectAISuggestion(suggestion: string): void {
this.customContent = suggestion;
}
|
AST#method_declaration#Left private selectAISuggestion AST#parameter_list#Left ( AST#parameter#Left suggestion : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#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 . customContent AST#member_expression#Right = AST#expression#Left suggestion AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
private selectAISuggestion(suggestion: string): void {
this.customContent = suggestion;
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/greetings/GreetingSendPage.ets#L170-L172
|
a782bb0d4750912597ebcec51c21ffbbed6aa696
|
github
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Ability/StageAbilityDemo/entry/src/main/ets/common/constants/Constants.ets
|
arkts
|
The percentage of 50.
|
export const PERCENTAGE_50 = '50%';
|
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left PERCENTAGE_50 = AST#expression#Left '50%' AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
|
export const PERCENTAGE_50 = '50%';
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Ability/StageAbilityDemo/entry/src/main/ets/common/constants/Constants.ets#L50-L50
|
3eb246cc1e98a5b9d10bc78cabc2d91640447e83
|
gitee
|
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_web/src/main/ets/component/TextInputDialogView.ets
|
arkts
|
TextInputDialogBuilder
|
TextInputDialog
@param options
|
@Builder
export function TextInputDialogBuilder(options: InputOptions) {
TextInputDialogView({ options: options });
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function TextInputDialogBuilder AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left InputOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_custom_component_statement#Left TextInputDialogView ( AST#component_parameters#Left { AST#component_parameter#Left options : AST#expression#Left options AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right } AST#builder_function_body#Right AST#decorated_export_declaration#Right
|
@Builder
export function TextInputDialogBuilder(options: InputOptions) {
TextInputDialogView({ options: options });
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_web/src/main/ets/component/TextInputDialogView.ets#L31-L34
|
9b1f130232fc9fa8b1dc18d04ff2fed092a55b4c
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
harmonyos/src/main/ets/pages/ContactsPage.ets
|
arkts
|
exitSelectionMode
|
退出选择模式
|
private exitSelectionMode(): void {
this.isSelectionMode = false;
this.selectedContacts.clear();
}
|
AST#method_declaration#Left private exitSelectionMode 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 . isSelectionMode AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedContacts AST#member_expression#Right AST#expression#Right . clear AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
private exitSelectionMode(): void {
this.isSelectionMode = false;
this.selectedContacts.clear();
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/pages/ContactsPage.ets#L110-L113
|
cbe4a5559b39a8f446762133d90099866801a2e1
|
github
|
texiwustion/chinese-herbal-shopping--arkts.git
|
3f71338f3c6d88bc74342e0322867f3a0c2c17d1
|
entry/src/main/ets/views/CartPage.ets
|
arkts
|
calculateTotalPrice
|
计算订单总价的方法
|
calculateTotalPrice() {
return this.orders.reduce((sum, order) => {
console.info('订单: 状态 ', order.status === 'added')
return sum + (order.status === 'added' ? (order.herbal.price * order.quantity) : 0);
}, 0);
}
|
AST#method_declaration#Left calculateTotalPrice 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 this AST#expression#Right . orders AST#member_expression#Right AST#expression#Right . reduce 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 sum AST#parameter#Right , AST#parameter#Left order 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#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left order AST#expression#Right . status AST#member_expression#Right AST#expression#Right === AST#expression#Left 'added' 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#binary_expression#Left AST#expression#Left sum 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#member_expression#Left AST#expression#Left order AST#expression#Right . status AST#member_expression#Right AST#expression#Right === AST#expression#Left 'added' AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left order AST#expression#Right . herbal AST#member_expression#Right AST#expression#Right . price AST#member_expression#Right AST#expression#Right * AST#expression#Left order AST#expression#Right AST#binary_expression#Right AST#expression#Right . quantity AST#member_expression#Right AST#expression#Right ) AST#parenthesized_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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right , AST#expression#Left 0 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
|
calculateTotalPrice() {
return this.orders.reduce((sum, order) => {
console.info('订单: 状态 ', order.status === 'added')
return sum + (order.status === 'added' ? (order.herbal.price * order.quantity) : 0);
}, 0);
}
|
https://github.com/texiwustion/chinese-herbal-shopping--arkts.git/blob/3f71338f3c6d88bc74342e0322867f3a0c2c17d1/entry/src/main/ets/views/CartPage.ets#L16-L21
|
45d806cbf491367026e0094b6548baf458922fbb
|
github
|
ArkTS-CodeSearch: A Open-Source ArkTS Dataset for Code Retrieval
Paper | Evaluation Code | Fine-Tuned Model
This dataset collects function-level information from ArkTS (HarmonyOS Ark TypeScript) projects, including original functions, docstrings, abstract syntax tree (AST) representations, obfuscated versions, and source code metadata. It is suitable for tasks such as code analysis, code understanding, AST research, and code search.
ArkTS is a core programming language in the OpenHarmony ecosystem. This dataset was constructed from open-source repositories crawled from GitHub and Gitee, targeting code retrieval and code evaluation tasks.
Dataset Structure
The dataset contains three splits:
train: Training setvalidation: Validation settest: Test set
Each split is a JSON Lines (.jsonl) file, where each line is a JSON object representing a single function.
Features / Columns
| Field | Type | Description |
|---|---|---|
nwo |
string | Repository name |
sha |
string | Commit SHA |
path |
string | File path |
language |
string | Programming language |
identifier |
string | Function identifier / name |
docstring |
string | Function docstring |
function |
string | Original function source code |
ast_function |
string | AST representation of the function |
obf_function |
string | Obfuscated function source code |
url |
string | URL to the code in the repository |
function_sha |
string | Function-level SHA |
source |
string | Code source (GitHub / Gitee) |
Usage
from datasets import load_dataset
# Load the dataset
dataset = load_dataset("hreyulog/arkts-code-docstring")
# Inspect the first training example
print(dataset["train"][0])
# Check dataset features
print(dataset["train"].features)
Citation
If you use this dataset in your research, please cite the following paper:
@misc{he2026arktscodesearchopensourcearktsdataset,
title={ArkTS-CodeSearch: A Open-Source ArkTS Dataset for Code Retrieval},
author={Yulong He and Artem Ermakov and Sergey Kovalchuk and Artem Aliev and Dmitry Shalymov},
year={2026},
eprint={2602.05550},
archivePrefix={arXiv},
primaryClass={cs.SE},
url={https://arxiv.org/abs/2602.05550},
}
- Downloads last month
- 11