fix: 提升Windows分发包启动兼容性

This commit is contained in:
yu committed 2026-10-27 16:43:28 +08:00
1 parent 5de47ee420
commit cb68af5a0f
3 files changed
+92 -5

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
import { app } from "electron";
import fs from "node:fs";
import path from "node:path";
export function logMain(event: string, detail: unknown = ""): void {
try {
const directory = path.join(app.getPath("userData"), "logs");
fs.mkdirSync(directory, { recursive: true });
const content = typeof detail === "string" ? detail : JSON.stringify(detail);
fs.appendFileSync(path.join(directory, "startup.log"), `${new Date().toISOString()} [${event}] ${content}\r\n`, "utf8");
} catch {
// Logging must never prevent the app from starting.
}
}