fix: 提升Windows分发包启动兼容性
This commit is contained in:
1 parent
5de47ee420
commit
cb68af5a0f
3 files changed
+92
-5
No files matched your search
@@ -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.
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user