返回 DeepSeek-Reasonix
singleInstance.ts
根目录 / desktop / electron / src / main / singleInstance.ts
1 import { mkdirSync, realpathSync } from "node:fs";
2 import { join } from "node:path";
3
4 export interface InstanceHost {
5 setPath(name: "userData", path: string): void;
6 requestSingleInstanceLock(): boolean;
7 }
8
9 // Electron keys its process singleton by userData at lock acquisition. Resolve
10 // symlinks after creating the profile so aliases of one home share one lock.
11 export function claimShellInstance(host: InstanceHost, dataHome: string, dev: boolean): boolean {
12 const profile = join(dataHome, "desktop-shell");
13 mkdirSync(profile, { recursive: true });
14 host.setPath("userData", realpathSync.native(profile));
15 return dev || host.requestSingleInstanceLock();
16 }
17
17 lines TYPESCRIPT