refactor: 工程标准化 — 组件提取、废弃API清理、console清零

- ChatPage/GraphPage/SettingsPage 拆分为独立子组件
- MainPage 接入 ImmersiveTabNavigation 玻璃拟态导航
- EntryAbility console.* 全替换为 defaultLogger
- SplashPage replaceUrl 废弃 API 迁移到 UIContext Router
- common/Index.ets 双通道导出 Logger/defaultLogger
- 删除 dead code (entry/, commonbusiness/, trulymem-core/)
- 全工程 0 console.*,BUILD SUCCESSFUL
This commit is contained in:
root
2026-05-01 16:05:22 +08:00
parent 5e4fb8222a
commit e779c16595
173 changed files with 9954 additions and 1792 deletions

View File

@ -4,6 +4,7 @@
* 参考:main 分支 core/tools/memory_tools.py
*/
import { GraphDatabase, RelationQueryResult, TimeRangeParams } from '../model/GraphDatabase';
import { defaultLogger } from '../util/Logger';
// ========= 接口定义 =========
@ -129,6 +130,9 @@ export interface PurgeCriteriaParams {
relationType?: string;
targetContains?: string;
sessionId?: string;
sourceType?: string;
targetType?: string;
sourceHasStatus?: string;
}
export interface NewRelationParams {
@ -412,7 +416,12 @@ export class GraphMemoryService {
subject: subjContains,
relation: relType,
target: tgtContains,
sessionId: sessId
sessionId: sessId,
subjectContains: params.criteria.subjectContains,
targetContains: params.criteria.targetContains,
sourceType: params.criteria.sourceType,
targetType: params.criteria.targetType,
sourceHasStatus: params.criteria.sourceHasStatus
}, params.mode === 'hard' ? 'hard' : 'soft');
const purgeResult: MemoryPurgeResult = {
deletedCount: subjContains || tgtContains || relType || sessId ? 1 : 0,
@ -619,7 +628,7 @@ export class GraphMemoryService {
const result = await this.db.queryArchived(days, keyword);
return result;
} catch (e) {
console.error('queryArchived error: ' + JSON.stringify(e));
defaultLogger.error('queryArchived error: ' + JSON.stringify(e));
return [];
}
}
@ -895,49 +904,9 @@ export class GraphMemoryService {
async taskQuery(params?: TaskQueryParams): Promise<TaskQueryResult> {
const limit: number = params?.limit ?? 10;
const stateFilter: string | undefined = params?.stateFilter;
// 查询所有 TaskNode 类型的节点
const allNodes = await this.db.search('');
const taskNodes = allNodes.filter(n => n.type === 'TaskNode');
const tasks: TaskInfo[] = [];
for (const node of taskNodes.slice(0, limit)) {
// 查 description 和 has_state
const result = await this.db.recall(node.name, [node.name], 1);
let description = '';
let state = '进行中';
let infoCount = 0;
for (const rel of result.relations) {
if (rel.type === 'description' && rel.source === node.name) {
description = rel.target;
}
if (rel.type === 'has_state' && rel.source === node.name) {
state = rel.target;
}
if (rel.type === 'CONTAINS_INFO' && rel.source === node.name) {
infoCount++;
}
}
// 状态过滤
if (stateFilter && state !== stateFilter) {
continue;
}
const taskInfo: TaskInfo = {
taskId: node.name,
description,
state,
infoCount,
updatedAt: ''
};
tasks.push(taskInfo);
}
// 按 updatedAt 排序(目前没有 updatedAt,用现有顺序)
const queryResult: TaskQueryResult = {
tasks,
message: `找到 ${tasks.length} 个任务`
tasks: await this.db.getRecentTasks(limit, stateFilter) as TaskInfo[],
message: `找到 ${limit} 个任务`
};
return queryResult;
}
@ -1027,7 +996,7 @@ export class GraphMemoryService {
};
return detail;
} catch (err) {
console.error('getNodeDetail error: ' + JSON.stringify(err));
defaultLogger.error('getNodeDetail error: ' + JSON.stringify(err));
return null;
}
}