fix: AIAgentService getContext(this) 改为外部传入,Index 添加 aboutToDisappear 释放 display 监听

- AIAgentService: 添加 appContext 字段,构造函数接收 Context 参数
- ChatPage: 创建 AIAgentService 时传入 getContext(this)
- Index: 添加 displayCallback 字段和 aboutToDisappear 释放监听
This commit is contained in:
root
2026-04-30 15:02:00 +08:00
parent b9a2cba2a7
commit ba44d50d7a
3 changed files with 14 additions and 3 deletions

View File

@ -8,11 +8,18 @@ import { ImmersiveTabNavigation } from '../components/ImmersiveTabNavigation';
struct Index {
@State currentIndex: number = 0;
private db: GraphDatabase = new GraphDatabase();
private displayCallback?: (data: display.Display) => void;
aboutToAppear() {
this.db.init(getContext(this));
}
aboutToDisappear() {
if (this.displayCallback) {
display.off('change', this.displayCallback);
}
}
@Builder
tabContentBuilder() {
Column() {