Skip to content

Commit 5347b61

Browse files
committed
添加了对依赖的检测提示
1 parent 369aab3 commit 5347b61

File tree

2 files changed

+73
-15
lines changed

2 files changed

+73
-15
lines changed

env.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,20 @@ const killGameProcess = () => {
171171
})
172172
}
173173

174-
/**
175-
* Opens the IsaacSocketUtility by executing the IsaacSocket.exe file.
176-
*
177-
* @param {void} none - no parameters
178-
* @return {void} none - no return value
179-
*/
174+
180175
const openIsaacSocketUtility = () => {
181-
cp.execFile("./dependencies/IsaacSocketUtility/IsaacSocket.exe", ["-silent"]);
176+
return new Promise((resolve,reject)=>{
177+
if(!fs.existsSync("./dependencies/IsaacSocketUtility/IsaacSocket.exe")){
178+
console.log("IsaacSocket.exe not found");
179+
reject();
180+
}
181+
cp.execFile("./dependencies/IsaacSocketUtility/IsaacSocket.exe", ["-silent"], (error) => {
182+
if (error) {
183+
reject(error)
184+
}
185+
resolve();
186+
});
187+
})
182188
}
183189

184190
module.exports = {

main.js

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { getAllModsMetadata,
77
getRequiredModsVersionInfo,
88
patchMods,
99
getGameDirectorySync,
10-
// waitForGameLaunch,
10+
// waitForGameLaunch,
1111
killGameProcess,
1212
openIsaacSocketUtility } = require("./env");
1313

@@ -63,11 +63,47 @@ const isPortTaken = (port) => {
6363
}
6464
initServer(PORT);
6565
win = createMainWindow();
66+
67+
let gameDir;
68+
try {
69+
gameDir = await getGameDirectorySync();
70+
}
71+
catch (e) {
72+
dialog.showMessageBoxSync({
73+
title: "错误",
74+
message: `无法获取游戏目录,请检查IsaacBoxUtility.exe是否被杀毒软件删除或限制访问`,
75+
type: "error"
76+
})
77+
return;
78+
}
79+
80+
let mods;
81+
try {
82+
mods = await getAllModsMetadata(gameDir);
83+
} catch (e) {
84+
dialog.showMessageBoxSync({
85+
title: "错误",
86+
message: `无法获取MOD信息`,
87+
type: "error"
88+
})
89+
return;
90+
}
91+
92+
let requiredMods;
93+
try {
94+
requiredMods = await getRequiredModsVersionInfo(mods);
95+
} catch (e) {
96+
dialog.showMessageBoxSync({
97+
title: "错误",
98+
message: `无法获取所需MOD信息`,
99+
type: "error"
100+
})
101+
return;
102+
}
103+
104+
let isPatched;
66105
try {
67-
const gameDir = await getGameDirectorySync();
68-
const mods = await getAllModsMetadata(gameDir);
69-
const requiredMods = await getRequiredModsVersionInfo(mods);
70-
const isPatched = await patchMods(gameDir, requiredMods)
106+
isPatched = await patchMods(gameDir, requiredMods)
71107
if (isPatched) {
72108
await killGameProcess();
73109
dialog.showMessageBox({
@@ -76,9 +112,25 @@ const isPortTaken = (port) => {
76112
message: "所需MOD已经为您安装完成,请您手动重新启动游戏"
77113
})
78114
}
79-
openIsaacSocketUtility();
80-
} catch (error) {
81-
console.log(error);
115+
} catch (e) {
116+
dialog.showMessageBoxSync({
117+
title: "错误",
118+
message: `无法安装所需MOD`,
119+
type: "error"
120+
})
121+
return;
122+
}
123+
124+
try {
125+
await openIsaacSocketUtility();
126+
}
127+
catch (e) {
128+
dialog.showMessageBoxSync({
129+
title: "错误",
130+
message: `无法打开IsaacSocket连接工具,请检查.NET环境是否安装,IsaacSocketUtility.exe是否被杀毒软件删除或限制访问,IsaacBoxUtility.exe,或者请以管理员权限打开。`,
131+
type: "error"
132+
})
133+
return;
82134
}
83135
})();
84136

0 commit comments

Comments
 (0)