Compare commits
2 Commits
10a4c540dd
...
0a664d1f64
Author | SHA1 | Date | |
---|---|---|---|
0a664d1f64 | |||
232043d686 |
41
app.js
41
app.js
@ -1,4 +1,4 @@
|
|||||||
const { app, BrowserWindow, ipcMain, dialog } = require('electron');
|
const { app, BrowserWindow, ipcMain, dialog, Tray, Menu } = require('electron');
|
||||||
const { setupTitlebar, attachTitlebarToWindow } = require('custom-electron-titlebar/main');
|
const { setupTitlebar, attachTitlebarToWindow } = require('custom-electron-titlebar/main');
|
||||||
const windowManager = require('./ui/windowManager');
|
const windowManager = require('./ui/windowManager');
|
||||||
const osuUtil = require('./osuUtil');
|
const osuUtil = require('./osuUtil');
|
||||||
@ -9,6 +9,7 @@ const rpc = require('./discordPresence');
|
|||||||
const windowName = require('get-window-by-name');
|
const windowName = require('get-window-by-name');
|
||||||
const terminalUtil = require('./terminalUtil');
|
const terminalUtil = require('./terminalUtil');
|
||||||
const osUtil = require('./osUtil');
|
const osUtil = require('./osUtil');
|
||||||
|
const appInfo = require('./appInfo');
|
||||||
|
|
||||||
let tempOsuPath;
|
let tempOsuPath;
|
||||||
let osuWindowInfo;
|
let osuWindowInfo;
|
||||||
@ -119,10 +120,37 @@ const run = () => {
|
|||||||
|
|
||||||
|
|
||||||
let mainWindow;
|
let mainWindow;
|
||||||
|
let tray = null
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
|
|
||||||
|
tray = new Tray('./assets/logo.png');
|
||||||
|
const trayMenuTemplate = [
|
||||||
|
{
|
||||||
|
label: `EZPPLauncher ${appInfo.appVersion}`,
|
||||||
|
enabled: false
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
label: "Show/Hide",
|
||||||
|
click: function () {
|
||||||
|
if (mainWindow.isVisible()) mainWindow.hide();
|
||||||
|
else mainWindow.show();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
label: 'Exit',
|
||||||
|
click: function () {
|
||||||
|
app.exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
let trayMenu = Menu.buildFromTemplate(trayMenuTemplate)
|
||||||
|
tray.setContextMenu(trayMenu)
|
||||||
|
|
||||||
mainWindow = createWindow();
|
mainWindow = createWindow();
|
||||||
mainWindow.on('show', async () => {
|
mainWindow.once('show', async () => {
|
||||||
await updateConfigVars(mainWindow);
|
await updateConfigVars(mainWindow);
|
||||||
await tryLogin(mainWindow);
|
await tryLogin(mainWindow);
|
||||||
await doUpdateCheck(mainWindow);
|
await doUpdateCheck(mainWindow);
|
||||||
@ -187,10 +215,10 @@ const run = () => {
|
|||||||
}
|
}
|
||||||
rpc.updateState("Launching osu!...");
|
rpc.updateState("Launching osu!...");
|
||||||
isIngame = true;
|
isIngame = true;
|
||||||
mainWindow.hide();
|
if (mainWindow.isVisible()) mainWindow.hide();
|
||||||
const result = await osuUtil.startOsuWithDevServer(tempOsuPath, "ez-pp.farm", async () => {
|
const result = await osuUtil.startOsuWithDevServer(tempOsuPath, "ez-pp.farm", async () => {
|
||||||
isIngame = false;
|
isIngame = false;
|
||||||
mainWindow.show();
|
if (!mainWindow.isVisible()) mainWindow.show();
|
||||||
await doUpdateCheck(mainWindow);
|
await doUpdateCheck(mainWindow);
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
@ -287,8 +315,11 @@ async function tryLogin(window) {
|
|||||||
user: loginResponse.user
|
user: loginResponse.user
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
await config.remove("username");
|
||||||
|
await config.remove("password");
|
||||||
window.webContents.send('account_update', {
|
window.webContents.send('account_update', {
|
||||||
type: "login-failed"
|
type: "login-failed",
|
||||||
|
message: loginResponse.message
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
const axios = require('axios').default;
|
const axios = require('axios').default;
|
||||||
|
|
||||||
const loginCheckEndpoint = 'https://ez-pp.farm/login/check';
|
const loginCheckEndpoint = 'https://ez-pp.farm/login/check';
|
||||||
|
let retries = 0;
|
||||||
|
|
||||||
const performLogin = async (username, password) => {
|
const performLogin = async (username, password) => {
|
||||||
const result = await axios.post(loginCheckEndpoint, { username, password });
|
const result = await axios.post(loginCheckEndpoint, { username, password });
|
||||||
|
const code = result.data.code ?? 404;
|
||||||
|
if (code === 200 || code === 403) {
|
||||||
|
retries = 0;
|
||||||
return result.data;
|
return result.data;
|
||||||
|
} else {
|
||||||
|
if (retries++ >= 5) return { code: 403, message: "Login failed." }
|
||||||
|
return await performLogin(username, password);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { performLogin };
|
module.exports = { performLogin };
|
@ -1,62 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<title>EZPPLauncher</title>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
||||||
<link rel="icon" type="image/png" href="../assets/logo.png" />
|
|
||||||
<link href="../assets/mdb.min.css" rel="stylesheet" />
|
|
||||||
<style>
|
|
||||||
* {
|
|
||||||
user-select: none;
|
|
||||||
-webkit-user-select: none;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body class="fixed-sn mdb-skin-custom" data-spy="scroll" data-target="#scrollspy" data-offset="15"
|
|
||||||
oncontextmenu="return false;">
|
|
||||||
<main>
|
|
||||||
<div class="noselect">
|
|
||||||
<div class="position-relative overflow-hidden p-3 p-md-5 m-md-3 text-center text-lg-end d-flex align-items-center justify-content-center"
|
|
||||||
style="border-radius: 0.5em;">
|
|
||||||
<div class="position-relative overflow-hidden p-3 p-md-5 m-md-3">
|
|
||||||
<div class="container py-2 h-100">
|
|
||||||
<div class="row d-flex justify-content-center align-items-center h-100">
|
|
||||||
<div class="col col-xl-10">
|
|
||||||
<div class="card" style="border-radius: 1rem;">
|
|
||||||
<div class="row g-0">
|
|
||||||
<div class="card-body p-4 p-lg-5 text-black">
|
|
||||||
<div class="d-flex align-items-center mb-2 pb-1 text-white">
|
|
||||||
<span class="h1 fw-bold mb-0">EZPPLauncher</span>
|
|
||||||
</div>
|
|
||||||
<h5 class="fw-lighter fs-5 mb-3 pb-3 text-white text-start"
|
|
||||||
style="letter-spacing: 1px;">
|
|
||||||
Launch osu! with connection to the EZPPFarm server
|
|
||||||
</h5>
|
|
||||||
<div class="pt-1 mb-4">
|
|
||||||
<button id="launch-btn" class="btn btn-primary btn-lg btn-block"
|
|
||||||
type="button" style="background-color:#d6016f" disabled>Looking for
|
|
||||||
updates...</button>
|
|
||||||
</div>
|
|
||||||
<button class="btn btn-dark btn-sm float-start" id="account-btn" disabled>
|
|
||||||
set account
|
|
||||||
</button>
|
|
||||||
<button class="btn btn-dark btn-sm float-end" id="folder-btn">
|
|
||||||
set osu! directory
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
</body>
|
|
||||||
<script type="text/javascript" src="../assets/mdb.min.js"></script>
|
|
||||||
|
|
||||||
</html>
|
|
@ -152,6 +152,16 @@ window.addEventListener('DOMContentLoaded', () => {
|
|||||||
|
|
||||||
ipcRenderer.on('account_update', (event, data) => {
|
ipcRenderer.on('account_update', (event, data) => {
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
|
case "login-failed":
|
||||||
|
console.log(data);
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Uh oh!',
|
||||||
|
text: data.message,
|
||||||
|
icon: 'error',
|
||||||
|
confirmButtonText: 'Okay'
|
||||||
|
});
|
||||||
|
changePage("launch");
|
||||||
|
break;
|
||||||
case "not-loggedin":
|
case "not-loggedin":
|
||||||
changePage("launch");
|
changePage("launch");
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user