refactor: move harmonyos project to harmony/ directory

This commit is contained in:
root
2026-04-28 16:32:04 +08:00
parent 2a42183aaa
commit e83151bd1e
120 changed files with 0 additions and 0 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
{"buildMode":"Debug"}

View File

@ -0,0 +1 @@
{"hspPkgNames":[],"compileEntries":["&entry/build/generated/r/ResourceTable&","&entry/src/main/ets/entryability/EntryAbility&","&entry/src/main/ets/pages/Index&"],"updateVersionInfo":{}}

View File

@ -0,0 +1 @@
{"resolveConflictMode":true}

View File

@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=ResourceTable.js.map

View File

@ -0,0 +1,30 @@
import type AbilityConstant from "@ohos:app.ability.AbilityConstant";
import UIAbility from "@ohos:app.ability.UIAbility";
import type Window from "@ohos:window";
import type Want from "@ohos:app.ability.Want";
export default class EntryAbility extends UIAbility {
onCreate(want: Want, param: AbilityConstant.LaunchParam): void {
console.info('EntryAbility onCreate');
}
onDestroy(): void {
console.info('EntryAbility onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage): void {
windowStage.loadContent('pages/Index', (err, data) => {
if (err.code) {
console.error('Failed to load content: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading content: ' + JSON.stringify(data));
});
}
onWindowStageDestroy(): void {
console.info('EntryAbility onWindowStageDestroy');
}
onForeground(): void {
console.info('EntryAbility onForeground');
}
onBackground(): void {
console.info('EntryAbility onBackground');
}
}

View File

@ -0,0 +1,222 @@
import relationalStore from "@ohos:data.relationalStore";
import type { Context } from "@ohos:abilityAccessCtrl";
interface TripletData {
subject: string;
relation: string;
object: string;
}
interface CriteriaData {
subject?: string;
target?: string;
relation?: string;
sessionId?: string;
}
interface NodeData {
id: number;
label: string;
type: string;
mentions: number;
}
interface EdgeData {
from: number;
to: number;
label: string;
weight: number;
}
interface GraphData {
nodes: NodeData[];
edges: EdgeData[];
}
interface RecallResult {
data: GraphData;
}
interface ChatMessage {
role: string;
content: string;
}
interface CleanupResult {
cleaned: number;
}
const STORE_CONFIG: relationalStore.StoreConfig = {
name: 'trulymem.db',
securityLevel: relationalStore.SecurityLevel.S1
};
export class GraphDatabase {
private store?: relationalStore.RdbStore;
private context?: Context;
async init(context: Context): Promise<void> {
this.context = context;
this.store = await relationalStore.getRdbStore(context, STORE_CONFIG);
await this.createTables();
}
private async createTables(): Promise<void> {
if (!this.store)
return;
await this.store.executeSql(`
CREATE TABLE IF NOT EXISTS nodes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL UNIQUE,
type TEXT DEFAULT 'concept',
mentions INTEGER DEFAULT 1,
created_at TEXT,
updated_at TEXT
)
`);
await this.store.executeSql(`
CREATE TABLE IF NOT EXISTS relations (
id INTEGER PRIMARY KEY AUTOINCREMENT,
subject_id INTEGER NOT NULL,
relation TEXT NOT NULL,
object_id INTEGER NOT NULL,
weight REAL DEFAULT 1.0,
created_at TEXT
)
`);
await this.store.executeSql(`
CREATE TABLE IF NOT EXISTS chat_records (
id INTEGER PRIMARY KEY AUTOINCREMENT,
role TEXT NOT NULL,
content TEXT NOT NULL,
tools TEXT,
created_at TEXT
)
`);
}
async commit(triplets: TripletData[]): Promise<void> {
if (!this.store)
return;
for (const triplet of triplets) {
const subjectId: number = await this.upsertNode(triplet.subject);
const objectId: number = await this.upsertNode(triplet.object);
const bucket: relationalStore.ValuesBucket = {
'subject_id': subjectId,
'relation': triplet.relation,
'object_id': objectId,
'created_at': new Date().toISOString()
};
await this.store.insert('relations', bucket);
}
}
private async upsertNode(name: string): Promise<number> {
if (!this.store)
return -1;
const predicates: relationalStore.RdbPredicates = new relationalStore.RdbPredicates('nodes');
predicates.equalTo('name', name);
const resultSet: relationalStore.ResultSet = await this.store.query(predicates, ['id']);
if (resultSet.goToNextRow()) {
const id: number = resultSet.getLong(resultSet.getColumnIndex('id'));
resultSet.close();
return id;
}
resultSet.close();
const bucket: relationalStore.ValuesBucket = {
'name': name,
'type': 'concept',
'created_at': new Date().toISOString(),
'updated_at': new Date().toISOString()
};
return await this.store.insert('nodes', bucket);
}
async recall(queryIntent: string, seedEntities?: string[]): Promise<RecallResult> {
if (!this.store) {
const empty: RecallResult = { data: { nodes: [], edges: [] } };
return empty;
}
const nodes: NodeData[] = await this.getAllNodes();
const edges: EdgeData[] = await this.getAllEdges();
const result: RecallResult = { data: { nodes, edges } };
return result;
}
async purge(criteria: CriteriaData): Promise<void> {
if (!this.store)
return;
const predicates: relationalStore.RdbPredicates = new relationalStore.RdbPredicates('nodes');
await this.store.delete(predicates);
}
async introspect(): Promise<RecallResult> {
const nodes: NodeData[] = await this.getAllNodes();
const edges: EdgeData[] = await this.getAllEdges();
const result: RecallResult = { data: { nodes, edges } };
return result;
}
async archive(days: number): Promise<void> {
// Archive old data - placeholder
}
async cleanup(dryRun: boolean): Promise<CleanupResult> {
const result: CleanupResult = { cleaned: 0 };
return result;
}
async saveChatMessage(role: string, content: string, tools?: string): Promise<void> {
if (!this.store)
return;
const bucket: relationalStore.ValuesBucket = {
'role': role,
'content': content,
'tools': tools || null,
'created_at': new Date().toISOString()
};
await this.store.insert('chat_records', bucket);
}
async getChatHistory(limit?: number): Promise<ChatMessage[]> {
if (!this.store)
return [];
const predicates: relationalStore.RdbPredicates = new relationalStore.RdbPredicates('chat_records');
predicates.orderByDesc('created_at');
if (limit) {
predicates.limitAs(limit);
}
const resultSet: relationalStore.ResultSet = await this.store.query(predicates, ['role', 'content']);
const messages: ChatMessage[] = [];
while (resultSet.goToNextRow()) {
const msg: ChatMessage = {
role: resultSet.getString(resultSet.getColumnIndex('role')),
content: resultSet.getString(resultSet.getColumnIndex('content'))
};
messages.push(msg);
}
resultSet.close();
return messages.reverse();
}
async clearChatHistory(): Promise<void> {
if (!this.store)
return;
const predicates: relationalStore.RdbPredicates = new relationalStore.RdbPredicates('chat_records');
await this.store.delete(predicates);
}
private async getAllNodes(): Promise<NodeData[]> {
if (!this.store)
return [];
const predicates: relationalStore.RdbPredicates = new relationalStore.RdbPredicates('nodes');
const resultSet: relationalStore.ResultSet = await this.store.query(predicates, ['id', 'name', 'type', 'mentions']);
const nodes: NodeData[] = [];
while (resultSet.goToNextRow()) {
const node: NodeData = {
id: resultSet.getLong(resultSet.getColumnIndex('id')),
label: resultSet.getString(resultSet.getColumnIndex('name')),
type: resultSet.getString(resultSet.getColumnIndex('type')),
mentions: resultSet.getLong(resultSet.getColumnIndex('mentions'))
};
nodes.push(node);
}
resultSet.close();
return nodes;
}
private async getAllEdges(): Promise<EdgeData[]> {
if (!this.store)
return [];
const predicates: relationalStore.RdbPredicates = new relationalStore.RdbPredicates('relations');
const resultSet: relationalStore.ResultSet = await this.store.query(predicates, ['subject_id', 'relation', 'object_id', 'weight']);
const edges: EdgeData[] = [];
while (resultSet.goToNextRow()) {
const edge: EdgeData = {
from: resultSet.getLong(resultSet.getColumnIndex('subject_id')),
to: resultSet.getLong(resultSet.getColumnIndex('object_id')),
label: resultSet.getString(resultSet.getColumnIndex('relation')),
weight: resultSet.getDouble(resultSet.getColumnIndex('weight'))
};
edges.push(edge);
}
resultSet.close();
return edges;
}
}

View File

@ -0,0 +1,205 @@
if (!("finalizeConstruction" in ViewPU.prototype)) {
Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { });
}
interface ChatPage_Params {
messages?: ChatMessage[];
inputText?: string;
db?: GraphDatabase;
scrollController?: Scroller;
}
import http from "@ohos:net.http";
import dataPreferences from "@ohos:data.preferences";
import type { GraphDatabase } from '../model/GraphDatabase';
interface ChatMessage {
role: string;
content: string;
}
export class ChatPage extends ViewPU {
constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
super(parent, __localStorage, elmtId, extraInfo);
if (typeof paramsLambda === "function") {
this.paramsGenerator_ = paramsLambda;
}
this.__messages = new ObservedPropertyObjectPU([], this, "messages");
this.__inputText = new ObservedPropertySimplePU('', this, "inputText");
this.__db = new SynchedPropertyObjectOneWayPU(params.db, this, "db");
this.scrollController = new Scroller();
this.setInitiallyProvidedValue(params);
this.finalizeConstruction();
}
setInitiallyProvidedValue(params: ChatPage_Params) {
if (params.messages !== undefined) {
this.messages = params.messages;
}
if (params.inputText !== undefined) {
this.inputText = params.inputText;
}
if (params.scrollController !== undefined) {
this.scrollController = params.scrollController;
}
}
updateStateVars(params: ChatPage_Params) {
this.__db.reset(params.db);
}
purgeVariableDependenciesOnElmtId(rmElmtId) {
this.__messages.purgeDependencyOnElmtId(rmElmtId);
this.__inputText.purgeDependencyOnElmtId(rmElmtId);
this.__db.purgeDependencyOnElmtId(rmElmtId);
}
aboutToBeDeleted() {
this.__messages.aboutToBeDeleted();
this.__inputText.aboutToBeDeleted();
this.__db.aboutToBeDeleted();
SubscriberManager.Get().delete(this.id__());
this.aboutToBeDeletedInternal();
}
private __messages: ObservedPropertyObjectPU<ChatMessage[]>;
get messages() {
return this.__messages.get();
}
set messages(newValue: ChatMessage[]) {
this.__messages.set(newValue);
}
private __inputText: ObservedPropertySimplePU<string>;
get inputText() {
return this.__inputText.get();
}
set inputText(newValue: string) {
this.__inputText.set(newValue);
}
private __db: SynchedPropertySimpleOneWayPU<GraphDatabase>;
get db() {
return this.__db.get();
}
set db(newValue: GraphDatabase) {
this.__db.set(newValue);
}
private scrollController: Scroller;
async aboutToAppear() {
this.messages = await this.db.getChatHistory(50);
}
async sendMessage() {
if (!this.inputText.trim())
return;
const userMessage: string = this.inputText;
this.inputText = '';
await this.db.saveChatMessage('user', userMessage);
const userMsg: ChatMessage = { role: 'user', content: userMessage };
this.messages = [...this.messages, userMsg];
const pref: dataPreferences.Preferences = await dataPreferences.getPreferences(getContext(this), 'trulymem_config');
const baseUrl: string = String(await pref.get('base_url', 'https://api.deepseek.com'));
const model: string = String(await pref.get('model', 'deepseek-chat'));
const apiKey: string = String(await pref.get('api_key', ''));
try {
const httpRequest: http.HttpRequest = http.createHttp();
const response: http.HttpResponse = await httpRequest.request(baseUrl + '/chat/completions', {
method: http.RequestMethod.POST,
header: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + apiKey
},
extraData: {
model: model,
messages: [{ role: 'user', content: userMessage }]
}
});
if (response.responseCode === 200) {
const data: object = JSON.parse(String(response.result));
const choicesArr: object[] = data['choices'] as object[];
if (choicesArr && choicesArr.length > 0) {
const firstChoice: object = choicesArr[0];
const msgObj: object = firstChoice['message'] as object;
const assistantMessage: string = String(msgObj['content']);
await this.db.saveChatMessage('assistant', assistantMessage);
const aiMsg: ChatMessage = { role: 'assistant', content: assistantMessage };
this.messages = [...this.messages, aiMsg];
}
}
}
catch (err) {
console.error('HTTP request failed: ' + JSON.stringify(err));
}
}
initialRender() {
this.observeComponentCreation2((elmtId, isInitialRender) => {
Column.create();
Column.width('100%');
Column.height('100%');
}, Column);
this.observeComponentCreation2((elmtId, isInitialRender) => {
List.create();
List.width('100%');
List.layoutWeight(1);
}, List);
this.observeComponentCreation2((elmtId, isInitialRender) => {
ForEach.create();
const forEachItemGenFunction = _item => {
const msg = _item;
{
const itemCreation = (elmtId, isInitialRender) => {
ViewStackProcessor.StartGetAccessRecordingFor(elmtId);
ListItem.create(deepRenderFunction, true);
if (!isInitialRender) {
ListItem.pop();
}
ViewStackProcessor.StopGetAccessRecording();
};
const itemCreation2 = (elmtId, isInitialRender) => {
ListItem.create(deepRenderFunction, true);
};
const deepRenderFunction = (elmtId, isInitialRender) => {
itemCreation(elmtId, isInitialRender);
this.observeComponentCreation2((elmtId, isInitialRender) => {
Column.create();
Column.padding(12);
Column.backgroundColor(msg.role === 'user' ? '#E3F2FD' : '#F5F5F5');
Column.borderRadius(8);
Column.margin({ left: 8, right: 8, bottom: 8 });
}, Column);
this.observeComponentCreation2((elmtId, isInitialRender) => {
Text.create(msg.role);
Text.fontSize(12);
Text.fontColor('#666');
Text.width('100%');
}, Text);
Text.pop();
this.observeComponentCreation2((elmtId, isInitialRender) => {
Text.create(msg.content);
Text.fontSize(16);
Text.width('100%');
Text.margin({ top: 4 });
}, Text);
Text.pop();
Column.pop();
ListItem.pop();
};
this.observeComponentCreation2(itemCreation2, ListItem);
ListItem.pop();
}
};
this.forEachUpdateFunction(elmtId, this.messages, forEachItemGenFunction);
}, ForEach);
ForEach.pop();
List.pop();
this.observeComponentCreation2((elmtId, isInitialRender) => {
Row.create();
Row.width('100%');
Row.padding(8);
}, Row);
this.observeComponentCreation2((elmtId, isInitialRender) => {
TextArea.create({ text: this.inputText, placeholder: '输入消息...' });
TextArea.layoutWeight(1);
TextArea.onChange((v: string) => { this.inputText = v; });
}, TextArea);
this.observeComponentCreation2((elmtId, isInitialRender) => {
Button.createWithLabel('发送');
Button.onClick(() => this.sendMessage());
}, Button);
Button.pop();
Row.pop();
Column.pop();
}
rerender() {
this.updateDirtyElements();
}
}

View File

@ -0,0 +1,65 @@
if (!("finalizeConstruction" in ViewPU.prototype)) {
Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { });
}
interface GraphPage_Params {
controller?: web_webview.WebviewController;
db?: GraphDatabase;
}
import web_webview from "@ohos:web.webview";
import type { GraphDatabase } from '../model/GraphDatabase';
export class GraphPage extends ViewPU {
constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
super(parent, __localStorage, elmtId, extraInfo);
if (typeof paramsLambda === "function") {
this.paramsGenerator_ = paramsLambda;
}
this.controller = new web_webview.WebviewController();
this.__db = new SynchedPropertyObjectOneWayPU(params.db, this, "db");
this.setInitiallyProvidedValue(params);
this.finalizeConstruction();
}
setInitiallyProvidedValue(params: GraphPage_Params) {
if (params.controller !== undefined) {
this.controller = params.controller;
}
}
updateStateVars(params: GraphPage_Params) {
this.__db.reset(params.db);
}
purgeVariableDependenciesOnElmtId(rmElmtId) {
this.__db.purgeDependencyOnElmtId(rmElmtId);
}
aboutToBeDeleted() {
this.__db.aboutToBeDeleted();
SubscriberManager.Get().delete(this.id__());
this.aboutToBeDeletedInternal();
}
private controller: web_webview.WebviewController;
private __db: SynchedPropertySimpleOneWayPU<GraphDatabase>;
get db() {
return this.__db.get();
}
set db(newValue: GraphDatabase) {
this.__db.set(newValue);
}
initialRender() {
this.observeComponentCreation2((elmtId, isInitialRender) => {
Column.create();
Column.width('100%');
Column.height('100%');
Column.onAppear(() => {
this.controller.refresh();
});
}, Column);
this.observeComponentCreation2((elmtId, isInitialRender) => {
Web.create({ src: { "id": 0, "type": 30000, params: ['graph.html'], "bundleName": "com.trulymem.app", "moduleName": "entry" }, controller: this.controller });
Web.javaScriptAccess(true);
Web.width('100%');
Web.height('100%');
}, Web);
Column.pop();
}
rerender() {
this.updateDirtyElements();
}
}

View File

@ -0,0 +1,119 @@
if (!("finalizeConstruction" in ViewPU.prototype)) {
Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { });
}
interface Index_Params {
currentIndex?: number;
db?: GraphDatabase;
}
import { MainPage } from "@normalized:N&&&entry/src/main/ets/pages/MainPage&";
import { SettingsPage } from "@normalized:N&&&entry/src/main/ets/pages/SettingsPage&";
import { GraphDatabase } from "@normalized:N&&&entry/src/main/ets/model/GraphDatabase&";
class Index extends ViewPU {
constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
super(parent, __localStorage, elmtId, extraInfo);
if (typeof paramsLambda === "function") {
this.paramsGenerator_ = paramsLambda;
}
this.__currentIndex = new ObservedPropertySimplePU(0, this, "currentIndex");
this.db = new GraphDatabase();
this.setInitiallyProvidedValue(params);
this.finalizeConstruction();
}
setInitiallyProvidedValue(params: Index_Params) {
if (params.currentIndex !== undefined) {
this.currentIndex = params.currentIndex;
}
if (params.db !== undefined) {
this.db = params.db;
}
}
updateStateVars(params: Index_Params) {
}
purgeVariableDependenciesOnElmtId(rmElmtId) {
this.__currentIndex.purgeDependencyOnElmtId(rmElmtId);
}
aboutToBeDeleted() {
this.__currentIndex.aboutToBeDeleted();
SubscriberManager.Get().delete(this.id__());
this.aboutToBeDeletedInternal();
}
private __currentIndex: ObservedPropertySimplePU<number>;
get currentIndex() {
return this.__currentIndex.get();
}
set currentIndex(newValue: number) {
this.__currentIndex.set(newValue);
}
private db: GraphDatabase;
aboutToAppear() {
this.db.init(getContext(this));
}
initialRender() {
this.observeComponentCreation2((elmtId, isInitialRender) => {
Column.create();
Column.width('100%');
Column.height('100%');
}, Column);
this.observeComponentCreation2((elmtId, isInitialRender) => {
Tabs.create({ index: this.currentIndex, barPosition: BarPosition.End });
Tabs.width('100%');
Tabs.height('100%');
Tabs.onChange((index: number) => { this.currentIndex = index; });
}, Tabs);
this.observeComponentCreation2((elmtId, isInitialRender) => {
TabContent.create(() => {
{
this.observeComponentCreation2((elmtId, isInitialRender) => {
if (isInitialRender) {
let componentCall = new MainPage(this, { db: this.db }, undefined, elmtId, () => { }, { page: "entry/src/main/ets/pages/Index.ets", line: 19, col: 21 });
ViewPU.create(componentCall);
let paramsLambda = () => {
return {
db: this.db
};
};
componentCall.paramsGenerator_ = paramsLambda;
}
else {
this.updateStateVarsOfChildByElmtId(elmtId, {
db: this.db
});
}
}, { name: "MainPage" });
}
});
TabContent.tabBar('🌌 TrulyMEM');
}, TabContent);
TabContent.pop();
this.observeComponentCreation2((elmtId, isInitialRender) => {
TabContent.create(() => {
{
this.observeComponentCreation2((elmtId, isInitialRender) => {
if (isInitialRender) {
let componentCall = new SettingsPage(this, {}, undefined, elmtId, () => { }, { page: "entry/src/main/ets/pages/Index.ets", line: 24, col: 21 });
ViewPU.create(componentCall);
let paramsLambda = () => {
return {};
};
componentCall.paramsGenerator_ = paramsLambda;
}
else {
this.updateStateVarsOfChildByElmtId(elmtId, {});
}
}, { name: "SettingsPage" });
}
});
TabContent.tabBar('⚙ 设置');
}, TabContent);
TabContent.pop();
Tabs.pop();
Column.pop();
}
rerender() {
this.updateDirtyElements();
}
static getEntryName(): string {
return "Index";
}
}
registerNamedRoute(() => new Index(undefined, {}), "", { bundleName: "com.trulymem.app", moduleName: "entry", pagePath: "pages/Index", pageFullPath: "entry/src/main/ets/pages/Index", integratedHsp: "false", moduleType: "followWithHap" });

View File

@ -0,0 +1,97 @@
if (!("finalizeConstruction" in ViewPU.prototype)) {
Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { });
}
interface MainPage_Params {
db?: GraphDatabase;
}
import type { GraphDatabase } from '../model/GraphDatabase';
import { GraphPage } from "@normalized:N&&&entry/src/main/ets/pages/GraphPage&";
import { ChatPage } from "@normalized:N&&&entry/src/main/ets/pages/ChatPage&";
export class MainPage extends ViewPU {
constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
super(parent, __localStorage, elmtId, extraInfo);
if (typeof paramsLambda === "function") {
this.paramsGenerator_ = paramsLambda;
}
this.__db = new SynchedPropertyObjectOneWayPU(params.db, this, "db");
this.setInitiallyProvidedValue(params);
this.finalizeConstruction();
}
setInitiallyProvidedValue(params: MainPage_Params) {
}
updateStateVars(params: MainPage_Params) {
this.__db.reset(params.db);
}
purgeVariableDependenciesOnElmtId(rmElmtId) {
this.__db.purgeDependencyOnElmtId(rmElmtId);
}
aboutToBeDeleted() {
this.__db.aboutToBeDeleted();
SubscriberManager.Get().delete(this.id__());
this.aboutToBeDeletedInternal();
}
private __db: SynchedPropertySimpleOneWayPU<GraphDatabase>;
get db() {
return this.__db.get();
}
set db(newValue: GraphDatabase) {
this.__db.set(newValue);
}
initialRender() {
this.observeComponentCreation2((elmtId, isInitialRender) => {
GridRow.create({ columns: { sm: 1, md: 2, lg: 2 }, gutter: { x: 8, y: 8 } });
GridRow.width('100%');
GridRow.height('100%');
}, GridRow);
this.observeComponentCreation2((elmtId, isInitialRender) => {
GridCol.create({ span: { sm: 1, md: 1, lg: 1 } });
}, GridCol);
{
this.observeComponentCreation2((elmtId, isInitialRender) => {
if (isInitialRender) {
let componentCall = new GraphPage(this, { db: this.db }, undefined, elmtId, () => { }, { page: "entry/src/main/ets/pages/MainPage.ets", line: 12, col: 17 });
ViewPU.create(componentCall);
let paramsLambda = () => {
return {
db: this.db
};
};
componentCall.paramsGenerator_ = paramsLambda;
}
else {
this.updateStateVarsOfChildByElmtId(elmtId, {
db: this.db
});
}
}, { name: "GraphPage" });
}
GridCol.pop();
this.observeComponentCreation2((elmtId, isInitialRender) => {
GridCol.create({ span: { sm: 1, md: 1, lg: 1 } });
}, GridCol);
{
this.observeComponentCreation2((elmtId, isInitialRender) => {
if (isInitialRender) {
let componentCall = new ChatPage(this, { db: this.db }, undefined, elmtId, () => { }, { page: "entry/src/main/ets/pages/MainPage.ets", line: 15, col: 17 });
ViewPU.create(componentCall);
let paramsLambda = () => {
return {
db: this.db
};
};
componentCall.paramsGenerator_ = paramsLambda;
}
else {
this.updateStateVarsOfChildByElmtId(elmtId, {
db: this.db
});
}
}, { name: "ChatPage" });
}
GridCol.pop();
GridRow.pop();
}
rerender() {
this.updateDirtyElements();
}
}

View File

@ -0,0 +1,152 @@
if (!("finalizeConstruction" in ViewPU.prototype)) {
Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { });
}
interface SettingsPage_Params {
baseUrl?: string;
model?: string;
apiKey?: string;
pref?: dataPreferences.Preferences;
}
import dataPreferences from "@ohos:data.preferences";
export class SettingsPage extends ViewPU {
constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
super(parent, __localStorage, elmtId, extraInfo);
if (typeof paramsLambda === "function") {
this.paramsGenerator_ = paramsLambda;
}
this.__baseUrl = new ObservedPropertySimplePU('', this, "baseUrl");
this.__model = new ObservedPropertySimplePU('', this, "model");
this.__apiKey = new ObservedPropertySimplePU('', this, "apiKey");
this.pref = undefined;
this.setInitiallyProvidedValue(params);
this.finalizeConstruction();
}
setInitiallyProvidedValue(params: SettingsPage_Params) {
if (params.baseUrl !== undefined) {
this.baseUrl = params.baseUrl;
}
if (params.model !== undefined) {
this.model = params.model;
}
if (params.apiKey !== undefined) {
this.apiKey = params.apiKey;
}
if (params.pref !== undefined) {
this.pref = params.pref;
}
}
updateStateVars(params: SettingsPage_Params) {
}
purgeVariableDependenciesOnElmtId(rmElmtId) {
this.__baseUrl.purgeDependencyOnElmtId(rmElmtId);
this.__model.purgeDependencyOnElmtId(rmElmtId);
this.__apiKey.purgeDependencyOnElmtId(rmElmtId);
}
aboutToBeDeleted() {
this.__baseUrl.aboutToBeDeleted();
this.__model.aboutToBeDeleted();
this.__apiKey.aboutToBeDeleted();
SubscriberManager.Get().delete(this.id__());
this.aboutToBeDeletedInternal();
}
private __baseUrl: ObservedPropertySimplePU<string>;
get baseUrl() {
return this.__baseUrl.get();
}
set baseUrl(newValue: string) {
this.__baseUrl.set(newValue);
}
private __model: ObservedPropertySimplePU<string>;
get model() {
return this.__model.get();
}
set model(newValue: string) {
this.__model.set(newValue);
}
private __apiKey: ObservedPropertySimplePU<string>;
get apiKey() {
return this.__apiKey.get();
}
set apiKey(newValue: string) {
this.__apiKey.set(newValue);
}
private pref?: dataPreferences.Preferences;
async aboutToAppear() {
const ctx = getContext(this);
this.pref = await dataPreferences.getPreferences(ctx, 'trulymem_config');
this.baseUrl = String(await this.pref.get('base_url', 'https://api.deepseek.com'));
this.model = String(await this.pref.get('model', 'deepseek-chat'));
this.apiKey = String(await this.pref.get('api_key', ''));
}
async onBaseUrlChange(value: string) {
this.baseUrl = value;
await this.pref?.put('base_url', value);
await this.pref?.flush();
}
async onModelChange(value: string) {
this.model = value;
await this.pref?.put('model', value);
await this.pref?.flush();
}
async onApiKeyChange(value: string) {
this.apiKey = value;
await this.pref?.put('api_key', value);
await this.pref?.flush();
}
initialRender() {
this.observeComponentCreation2((elmtId, isInitialRender) => {
Column.create();
Column.width('100%');
Column.height('100%');
Column.padding(16);
}, Column);
this.observeComponentCreation2((elmtId, isInitialRender) => {
Text.create('API 配置');
Text.fontSize(24);
Text.fontWeight(FontWeight.Bold);
Text.margin({ top: 20, bottom: 16 });
}, Text);
Text.pop();
this.observeComponentCreation2((elmtId, isInitialRender) => {
Text.create('Base URL');
Text.fontSize(14);
Text.width('100%');
Text.margin({ left: 16 });
}, Text);
Text.pop();
this.observeComponentCreation2((elmtId, isInitialRender) => {
TextInput.create({ placeholder: 'https://api.deepseek.com', text: this.baseUrl });
TextInput.onChange((v: string) => { this.onBaseUrlChange(v); });
TextInput.margin({ left: 16, right: 16, bottom: 12 });
}, TextInput);
this.observeComponentCreation2((elmtId, isInitialRender) => {
Text.create('Model ID');
Text.fontSize(14);
Text.width('100%');
Text.margin({ left: 16 });
}, Text);
Text.pop();
this.observeComponentCreation2((elmtId, isInitialRender) => {
TextInput.create({ placeholder: 'deepseek-chat', text: this.model });
TextInput.onChange((v: string) => { this.onModelChange(v); });
TextInput.margin({ left: 16, right: 16, bottom: 12 });
}, TextInput);
this.observeComponentCreation2((elmtId, isInitialRender) => {
Text.create('API Key');
Text.fontSize(14);
Text.width('100%');
Text.margin({ left: 16 });
}, Text);
Text.pop();
this.observeComponentCreation2((elmtId, isInitialRender) => {
TextInput.create({ placeholder: 'sk-...', text: this.apiKey });
TextInput.type(InputType.Password);
TextInput.onChange((v: string) => { this.onApiKeyChange(v); });
TextInput.margin({ left: 16, right: 16, bottom: 12 });
}, TextInput);
Column.pop();
}
rerender() {
this.updateDirtyElements();
}
}

View File

@ -0,0 +1,8 @@
/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/build/default/generated/r/default/ResourceTable.js;&entry/build/generated/r/ResourceTable&;esm;entry|entry|1.0.0|build/default/generated/r/default/ResourceTable.js;entry;false;ts
/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/entryability/EntryAbility.ts;&entry/src/main/ets/entryability/EntryAbility&;esm;entry|entry|1.0.0|src/main/ets/entryability/EntryAbility.ts;entry;false;ets
/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/Index.ts;&entry/src/main/ets/pages/Index&;esm;entry|entry|1.0.0|src/main/ets/pages/Index.ts;entry;false;ets
/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/MainPage.ts;&entry/src/main/ets/pages/MainPage&;esm;entry|entry|1.0.0|src/main/ets/pages/MainPage.ts;entry;false;ets
/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/model/GraphDatabase.ts;&entry/src/main/ets/model/GraphDatabase&;esm;entry|entry|1.0.0|src/main/ets/model/GraphDatabase.ts;entry;false;ets
/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/SettingsPage.ts;&entry/src/main/ets/pages/SettingsPage&;esm;entry|entry|1.0.0|src/main/ets/pages/SettingsPage.ts;entry;false;ets
/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/GraphPage.ts;&entry/src/main/ets/pages/GraphPage&;esm;entry|entry|1.0.0|src/main/ets/pages/GraphPage.ts;entry;false;ets
/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/ChatPage.ts;&entry/src/main/ets/pages/ChatPage&;esm;entry|entry|1.0.0|src/main/ets/pages/ChatPage.ts;entry;false;ets

View File

@ -0,0 +1,9 @@
/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/build/default/generated/r/default/ResourceTable.js;/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/build/default/generated/r/default/ResourceTable.protoBin
/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/entryability/EntryAbility.ts;/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/entryability/EntryAbility.protoBin
/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/Index.ts;/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/Index.protoBin
/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/MainPage.ts;/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/MainPage.protoBin
/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/model/GraphDatabase.ts;/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/model/GraphDatabase.protoBin
/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/SettingsPage.ts;/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/SettingsPage.protoBin
/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/GraphPage.ts;/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/GraphPage.protoBin
/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/ChatPage.ts;/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/ChatPage.protoBin
/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/npmEntries.txt;/home/program/TrulyMEM-TrueHumanMEM/harmonyos/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/npmEntries.protoBin

View File

@ -0,0 +1,7 @@
@system.app:@native.system.app
@ohos.app:@native.ohos.app
@system.router:@native.system.router
@system.curves:@native.system.curves
@ohos.curves:@native.ohos.curves
@system.matrix4:@native.system.matrix4
@ohos.matrix4:@native.ohos.matrix4

File diff suppressed because one or more lines are too long