diff --git a/src/preload/index.js b/src/preload/index.js index a0636a8..3fd54b1 100644 --- a/src/preload/index.js +++ b/src/preload/index.js @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -import { contextBridge, nativeImage } from 'electron' +import { contextBridge } from 'electron' import { electronAPI } from '@electron-toolkit/preload' // Custom APIs for renderer @@ -24,7 +24,6 @@ const api = {} // just add to the DOM global. if (process.contextIsolated) { try { - contextBridge.exposeInMainWorld('nativeImage', nativeImage) contextBridge.exposeInMainWorld('electron', electronAPI) contextBridge.exposeInMainWorld('api', api) } catch (error) { @@ -33,5 +32,4 @@ if (process.contextIsolated) { } else { window.electron = electronAPI window.api = api - window.nativeImage = nativeImage } diff --git a/src/renderer/src/components/utils.js b/src/renderer/src/components/utils.js index 027503d..95e2253 100644 --- a/src/renderer/src/components/utils.js +++ b/src/renderer/src/components/utils.js @@ -1,8 +1,9 @@ import { Client, Authenticator } from 'pimi-launcher-core' import path from 'path' import process from 'process' + async function launch(version, setProgress, setDownload, setGameStarted, setStarted) { - const appdata = process.platform === 'win32' ? process.env.APPDATA : process.env.HOME + const appdata = process.platform === 'win32' ? process.env['APPDATA'] : process.env['HOME'] const launcher = new Client() let opts = { @@ -21,6 +22,8 @@ async function launch(version, setProgress, setDownload, setGameStarted, setStar } } + launcher.launch(opts) + launcher.on('progress', (e) => setProgress(e)) launcher.on('download', (e) => setDownload(e)) launcher.on('debug', (e) => console.log(e)) @@ -31,7 +34,6 @@ async function launch(version, setProgress, setDownload, setGameStarted, setStar setGameStarted(false) setStarted(false) }) - await launcher.launch(opts) } export { launch } diff --git a/src/renderer/src/pages/Main.jsx b/src/renderer/src/pages/Main.jsx index 6164416..6b3da17 100644 --- a/src/renderer/src/pages/Main.jsx +++ b/src/renderer/src/pages/Main.jsx @@ -55,7 +55,7 @@ function Main() { > {versions.map((version, index) => { return ( - ) @@ -71,21 +71,24 @@ function Main() { launch(version, setProgress, setDownload, setGameStarted, setStarted) setStarted(true) }} + disabled={started} /> {started && gameStarted && ( <> -
Minecraft launches...
+
Minecraft launches...
)} {started && !gameStarted && ( <> -
Downloading{'.'.repeat(progress.task % 3)}
-
+
Downloading{'.'.repeat(progress.task % 3)}
+
{download || 'please wait'} {`(${progress.type})` || ''}
-
{((progress.task / progress.total) * 100 || 0).toFixed(2)}%
+
+ {((progress.task / progress.total) * 100 || 0).toFixed(2)}% +
)}