MCPcopy
hub / github.com/SPlayer-Dev/SPlayer / initSingleLock

Function initSingleLock

electron/main/utils/single-lock.ts:10–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8 * @returns 如果当前实例获得了锁,返回 true;否则返回 false
9 */
10export const initSingleLock = (): boolean => {
11 const gotTheLock = app.requestSingleInstanceLock();
12 // 如果未获得锁,退出当前实例
13 if (!gotTheLock) {
14 app.quit();
15 systemLog.warn("❌ 已有一个实例正在运行");
16 return false;
17 }
18 // 当第二个实例启动时触发
19 else {
20 app.on("second-instance", (_, commandLine) => {
21 if (!processProtocolFromCommand(commandLine)) {
22 systemLog.warn("❌ 第二个实例将要启动");
23 } else {
24 systemLog.info("🚀 第二个实例将要启动,通过 Custom Protocol");
25 }
26 mainWindow.getWin()?.show();
27 });
28 }
29 return true;
30};

Callers 1

constructorMethod · 0.90

Calls 2

getWinMethod · 0.45

Tested by

no test coverage detected