feat(wip): 顯示消息的時間

This commit is contained in:
CrescentLeaf
2025-09-30 21:56:18 +08:00
parent 706a340407
commit 1fec2bba06
3 changed files with 13 additions and 6 deletions

View File

@@ -2,4 +2,5 @@ export default class Message {
declare id: number
declare text: string
declare user_id: string
declare time: string
}

View File

@@ -2,6 +2,7 @@ export default class MessageBean {
declare id: number
declare text: string
declare user_id?: string
declare time: string
[key: string]: unknown
}

View File

@@ -27,7 +27,8 @@ export default class MessagesManager {
CREATE TABLE IF NOT EXISTS ${this.getTableName()} (
/* 序号, MessageId */ id INTEGER PRIMARY KEY AUTOINCREMENT,
/* 消息文本 */ text TEXT NOT NULL,
/* 发送者 */ user_id TEXT NOT NULL
/* 发送者 */ user_id TEXT NOT NULL,
/* 發送時間 */ time INT8 NOT NULL
);
`)
}
@@ -36,17 +37,21 @@ export default class MessagesManager {
}
addMessage({
text,
user_id
user_id,
time
}: {
text: string,
user_id?: string
user_id?: string,
time?: number
}) {
return MessagesManager.database.prepare(`INSERT INTO ${this.getTableName()} (
text,
user_id
) VALUES (?, ?);`).run(
user_id,
time
) VALUES (?, ?, ?);`).run(
text,
user_id || null
user_id || null,
time || Date.now()
).lastInsertRowid
}
addSystemMessage(text: string) {