feat: show homepage visitor number

This commit is contained in:
illusia committed 2026-09-22 00:09:33 +08:00
1 parent 8ed3e788be
commit 6539479d10
4 files changed
+58 -4

No files matched your search

+13
View File
@@ -377,6 +377,19 @@ export class WebSpeakDatabase {
).run(key, value);
}
nextVisitorNumber(): number {
let nextNumber = 1;
this.transaction(() => {
const currentValue = this.getMeta("visitor_count");
const current = currentValue ? Number.parseInt(currentValue, 10) : 0;
nextNumber = Number.isSafeInteger(current) && current >= 0 && current < Number.MAX_SAFE_INTEGER
? current + 1
: 1;
this.setMeta("visitor_count", String(nextNumber));
});
return nextNumber;
}
addAudit(event: string, details: Record<string, unknown> = {}): void {
this.insertAudit(event, details, new Date().toISOString());
}