From 50707bcfbc3fabe3ae9058f03eadf7a18d5952c6 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sun, 26 May 2024 20:27:20 +1000 Subject: [PATCH] Fix macos loading issue --- client/main.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/client/main.js b/client/main.js index d2a5374..25e4da3 100644 --- a/client/main.js +++ b/client/main.js @@ -17,16 +17,28 @@ const map = { const server = http.createServer((req, res) => { // extract URL path - let pathname1 = `./${ url.parse( path.join( - electron.app.isPackaged ? "resources/app/dist" : "dist", + electron.app.isPackaged + ? path.join(electron.app.getAppPath(), "dist") + : "dist", req.url ) ).pathname }`; - // Try again for macos + pathname1 = fs.existsSync(pathname1) + ? pathname1 + : fs.existsSync(path.resolve(__dirname, pathname1)) + ? path.resolve(__dirname, pathname1) + : `./${ + url.parse( + path.join( + electron.app.isPackaged ? "resource/app/dist" : "dist", + req.url + ) + ).pathname + }`; let pathname = fs.existsSync(pathname1) ? pathname1 : path.resolve(__dirname, pathname1);