feat(wip): 顯示消息的時間
This commit is contained in:
@@ -2,4 +2,5 @@ export default class Message {
|
|||||||
declare id: number
|
declare id: number
|
||||||
declare text: string
|
declare text: string
|
||||||
declare user_id: string
|
declare user_id: string
|
||||||
|
declare time: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ export default class MessageBean {
|
|||||||
declare id: number
|
declare id: number
|
||||||
declare text: string
|
declare text: string
|
||||||
declare user_id?: string
|
declare user_id?: string
|
||||||
|
declare time: string
|
||||||
|
|
||||||
[key: string]: unknown
|
[key: string]: unknown
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ export default class MessagesManager {
|
|||||||
CREATE TABLE IF NOT EXISTS ${this.getTableName()} (
|
CREATE TABLE IF NOT EXISTS ${this.getTableName()} (
|
||||||
/* 序号, MessageId */ id INTEGER PRIMARY KEY AUTOINCREMENT,
|
/* 序号, MessageId */ id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
/* 消息文本 */ text TEXT NOT NULL,
|
/* 消息文本 */ 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({
|
addMessage({
|
||||||
text,
|
text,
|
||||||
user_id
|
user_id,
|
||||||
|
time
|
||||||
}: {
|
}: {
|
||||||
text: string,
|
text: string,
|
||||||
user_id?: string
|
user_id?: string,
|
||||||
|
time?: number
|
||||||
}) {
|
}) {
|
||||||
return MessagesManager.database.prepare(`INSERT INTO ${this.getTableName()} (
|
return MessagesManager.database.prepare(`INSERT INTO ${this.getTableName()} (
|
||||||
text,
|
text,
|
||||||
user_id
|
user_id,
|
||||||
) VALUES (?, ?);`).run(
|
time
|
||||||
|
) VALUES (?, ?, ?);`).run(
|
||||||
text,
|
text,
|
||||||
user_id || null
|
user_id || null,
|
||||||
|
time || Date.now()
|
||||||
).lastInsertRowid
|
).lastInsertRowid
|
||||||
}
|
}
|
||||||
addSystemMessage(text: string) {
|
addSystemMessage(text: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user