mirror of
https://github.com/artegoser/pimi-launcher.git
synced 2024-11-22 11:26:22 +03:00
fix: get appdata
This commit is contained in:
parent
73abb1c352
commit
a429bcf6c9
3 changed files with 13 additions and 10 deletions
|
@ -13,7 +13,7 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import { contextBridge, nativeImage } from 'electron'
|
import { contextBridge } from 'electron'
|
||||||
import { electronAPI } from '@electron-toolkit/preload'
|
import { electronAPI } from '@electron-toolkit/preload'
|
||||||
|
|
||||||
// Custom APIs for renderer
|
// Custom APIs for renderer
|
||||||
|
@ -24,7 +24,6 @@ const api = {}
|
||||||
// just add to the DOM global.
|
// just add to the DOM global.
|
||||||
if (process.contextIsolated) {
|
if (process.contextIsolated) {
|
||||||
try {
|
try {
|
||||||
contextBridge.exposeInMainWorld('nativeImage', nativeImage)
|
|
||||||
contextBridge.exposeInMainWorld('electron', electronAPI)
|
contextBridge.exposeInMainWorld('electron', electronAPI)
|
||||||
contextBridge.exposeInMainWorld('api', api)
|
contextBridge.exposeInMainWorld('api', api)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -33,5 +32,4 @@ if (process.contextIsolated) {
|
||||||
} else {
|
} else {
|
||||||
window.electron = electronAPI
|
window.electron = electronAPI
|
||||||
window.api = api
|
window.api = api
|
||||||
window.nativeImage = nativeImage
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import { Client, Authenticator } from 'pimi-launcher-core'
|
import { Client, Authenticator } from 'pimi-launcher-core'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import process from 'process'
|
import process from 'process'
|
||||||
|
|
||||||
async function launch(version, setProgress, setDownload, setGameStarted, setStarted) {
|
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()
|
const launcher = new Client()
|
||||||
|
|
||||||
let opts = {
|
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('progress', (e) => setProgress(e))
|
||||||
launcher.on('download', (e) => setDownload(e))
|
launcher.on('download', (e) => setDownload(e))
|
||||||
launcher.on('debug', (e) => console.log(e))
|
launcher.on('debug', (e) => console.log(e))
|
||||||
|
@ -31,7 +34,6 @@ async function launch(version, setProgress, setDownload, setGameStarted, setStar
|
||||||
setGameStarted(false)
|
setGameStarted(false)
|
||||||
setStarted(false)
|
setStarted(false)
|
||||||
})
|
})
|
||||||
await launcher.launch(opts)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { launch }
|
export { launch }
|
||||||
|
|
|
@ -55,7 +55,7 @@ function Main() {
|
||||||
>
|
>
|
||||||
{versions.map((version, index) => {
|
{versions.map((version, index) => {
|
||||||
return (
|
return (
|
||||||
<option key={index} value={index} className="text-1xl font-bold underline">
|
<option key={index} value={index} className="text-1xl font-bold">
|
||||||
{version.id}
|
{version.id}
|
||||||
</option>
|
</option>
|
||||||
)
|
)
|
||||||
|
@ -71,21 +71,24 @@ function Main() {
|
||||||
launch(version, setProgress, setDownload, setGameStarted, setStarted)
|
launch(version, setProgress, setDownload, setGameStarted, setStarted)
|
||||||
setStarted(true)
|
setStarted(true)
|
||||||
}}
|
}}
|
||||||
|
disabled={started}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{started && gameStarted && (
|
{started && gameStarted && (
|
||||||
<>
|
<>
|
||||||
<div>Minecraft launches...</div>
|
<div className="text-2xl font-bold">Minecraft launches...</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{started && !gameStarted && (
|
{started && !gameStarted && (
|
||||||
<>
|
<>
|
||||||
<div>Downloading{'.'.repeat(progress.task % 3)}</div>
|
<div className="text-2xl font-bold">Downloading{'.'.repeat(progress.task % 3)}</div>
|
||||||
<div>
|
<div className="break-words text-2xl font-bold">
|
||||||
{download || 'please wait'} {`(${progress.type})` || ''}
|
{download || 'please wait'} {`(${progress.type})` || ''}
|
||||||
</div>
|
</div>
|
||||||
<div>{((progress.task / progress.total) * 100 || 0).toFixed(2)}%</div>
|
<div className="text-2xl font-bold">
|
||||||
|
{((progress.task / progress.total) * 100 || 0).toFixed(2)}%
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue