mirror of
https://github.com/artegoser/pimi-launcher.git
synced 2024-11-22 03:16:21 +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
|
||||
// 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'
|
||||
|
||||
// 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
|
||||
}
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -55,7 +55,7 @@ function Main() {
|
|||
>
|
||||
{versions.map((version, index) => {
|
||||
return (
|
||||
<option key={index} value={index} className="text-1xl font-bold underline">
|
||||
<option key={index} value={index} className="text-1xl font-bold">
|
||||
{version.id}
|
||||
</option>
|
||||
)
|
||||
|
@ -71,21 +71,24 @@ function Main() {
|
|||
launch(version, setProgress, setDownload, setGameStarted, setStarted)
|
||||
setStarted(true)
|
||||
}}
|
||||
disabled={started}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{started && gameStarted && (
|
||||
<>
|
||||
<div>Minecraft launches...</div>
|
||||
<div className="text-2xl font-bold">Minecraft launches...</div>
|
||||
</>
|
||||
)}
|
||||
{started && !gameStarted && (
|
||||
<>
|
||||
<div>Downloading{'.'.repeat(progress.task % 3)}</div>
|
||||
<div>
|
||||
<div className="text-2xl font-bold">Downloading{'.'.repeat(progress.task % 3)}</div>
|
||||
<div className="break-words text-2xl font-bold">
|
||||
{download || 'please wait'} {`(${progress.type})` || ''}
|
||||
</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>
|
||||
|
|
Loading…
Add table
Reference in a new issue