Stop inspecting game log content in web terminal

This commit is contained in:
npc0-hue
2026-09-04 14:40:09 +08:00
parent ba36668668
commit 8dad79011a
5 changed files with 38 additions and 146 deletions
+2 -3
View File
@@ -3,9 +3,8 @@ import { describe, expect, it } from "vitest";
import { formatTerminalLogTime, formatTerminalServerTime } from "./logTime";
describe("formatTerminalLogTime", () => {
it("uses the SCUM log clock instead of the browser timezone", () => {
expect(formatTerminalLogTime("2026-08-24T01:23:44Z", "[2026.08.23-17.23.44][418]LogSCUM: Global Stats"))
.toBe("17:23:44");
it("uses only the server event timestamp", () => {
expect(formatTerminalLogTime("2026-08-24T01:23:44Z")).toMatch(/^\d{2}:\d{2}:\d{2}(?:\s*[AP]M)?$/);
});
it("falls back to the event timestamp for generic logs", () => {
+1 -8
View File
@@ -1,11 +1,4 @@
const scumLogTimestampPattern = /\[?(\d{4})\.(\d{2})\.(\d{2})-(\d{2})\.(\d{2})\.(\d{2})(?:[.:]\d{1,3})?\]?/;
export function formatTerminalLogTime(timestamp: string, line?: string): string {
const embedded = line?.match(scumLogTimestampPattern);
if (embedded) {
return `${embedded[4]}:${embedded[5]}:${embedded[6]}`;
}
export function formatTerminalLogTime(timestamp: string): string {
const date = new Date(timestamp);
return Number.isNaN(date.getTime()) ? "时间未知" : date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", second: "2-digit" });
}