Compare commits
7 Commits
0a664d1f64
...
1.1.4
Author | SHA1 | Date | |
---|---|---|---|
769a88521e | |||
f5287b6378 | |||
dd6866f680 | |||
cb1a05d58c | |||
fdfedab77f | |||
fc284e08f0 | |||
361db1df17 |
24
app.js
24
app.js
@@ -1,15 +1,17 @@
|
|||||||
const { app, BrowserWindow, ipcMain, dialog, Tray, Menu } = require('electron');
|
const { app, BrowserWindow, ipcMain, dialog, Tray, Menu } = require('electron');
|
||||||
const { setupTitlebar, attachTitlebarToWindow } = require('custom-electron-titlebar/main');
|
const { setupTitlebar } = require('custom-electron-titlebar/main');
|
||||||
const windowManager = require('./ui/windowManager');
|
const windowManager = require('./ui/windowManager');
|
||||||
const osuUtil = require('./osuUtil');
|
const osuUtil = require('./osuUtil');
|
||||||
const ezppUtil = require('./ezppUtil');
|
const ezppUtil = require('./ezppUtil');
|
||||||
const config = require('./config');
|
const config = require('./config');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
const rpc = require('./discordPresence');
|
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');
|
const appInfo = require('./appInfo');
|
||||||
|
const { DownloaderHelper } = require('node-downloader-helper');
|
||||||
|
|
||||||
let tempOsuPath;
|
let tempOsuPath;
|
||||||
let osuWindowInfo;
|
let osuWindowInfo;
|
||||||
@@ -121,9 +123,15 @@ const run = () => {
|
|||||||
|
|
||||||
let mainWindow;
|
let mainWindow;
|
||||||
let tray = null
|
let tray = null
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(async () => {
|
||||||
|
const logoFile = path.join(config.configFolder, "logo.png");
|
||||||
tray = new Tray('./assets/logo.png');
|
if (!fs.existsSync(logoFile)) {
|
||||||
|
const logoDownload = new DownloaderHelper("https://ez-pp.farm/assets/img/icon.png", config.configFolder, {
|
||||||
|
fileName: "logo.png",
|
||||||
|
})
|
||||||
|
await logoDownload.start();
|
||||||
|
}
|
||||||
|
tray = new Tray(logoFile);
|
||||||
const trayMenuTemplate = [
|
const trayMenuTemplate = [
|
||||||
{
|
{
|
||||||
label: `EZPPLauncher ${appInfo.appVersion}`,
|
label: `EZPPLauncher ${appInfo.appVersion}`,
|
||||||
@@ -313,7 +321,7 @@ async function tryLogin(window) {
|
|||||||
window.webContents.send('account_update', {
|
window.webContents.send('account_update', {
|
||||||
type: "loggedin",
|
type: "loggedin",
|
||||||
user: loginResponse.user
|
user: loginResponse.user
|
||||||
})
|
});
|
||||||
} else {
|
} else {
|
||||||
await config.remove("username");
|
await config.remove("username");
|
||||||
await config.remove("password");
|
await config.remove("password");
|
||||||
@@ -327,6 +335,11 @@ async function tryLogin(window) {
|
|||||||
type: "not-loggedin"
|
type: "not-loggedin"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const checkUpdate = await appInfo.hasUpdate();
|
||||||
|
if (checkUpdate) {
|
||||||
|
window.webContents.send('launcher_update', checkUpdate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function doUpdateCheck(window) {
|
async function doUpdateCheck(window) {
|
||||||
@@ -371,7 +384,6 @@ function createWindow() {
|
|||||||
|
|
||||||
win.loadFile('./html/index.html');
|
win.loadFile('./html/index.html');
|
||||||
|
|
||||||
attachTitlebarToWindow(win);
|
|
||||||
win.webContents.setWindowOpenHandler(() => "deny");
|
win.webContents.setWindowOpenHandler(() => "deny");
|
||||||
win.webContents.on('did-finish-load', function () {
|
win.webContents.on('did-finish-load', function () {
|
||||||
if (win.webContents.getZoomFactor() != 0.9)
|
if (win.webContents.getZoomFactor() != 0.9)
|
||||||
|
22
appInfo.js
22
appInfo.js
@@ -1,4 +1,20 @@
|
|||||||
const appName = "EZPPLauncher"
|
const { default: axios } = require("axios");
|
||||||
const appVersion = "1.1.2";
|
const { compareVersions } = require("compare-versions");
|
||||||
|
|
||||||
module.exports = { appName, appVersion };
|
const appName = "EZPPLauncher"
|
||||||
|
const appVersion = "1.1.4";
|
||||||
|
|
||||||
|
const hasUpdate = async () => {
|
||||||
|
const releaseInfo = await axios.get(`https://git.ez-pp.farm/api/v1/repos/EZPPFarm/${appName}/releases/latest`);
|
||||||
|
if (releaseInfo.status !== 200) return false;
|
||||||
|
const latestReleaseVersion = releaseInfo.data.tag_name;
|
||||||
|
const updateAvailable = compareVersions(latestReleaseVersion, appVersion);
|
||||||
|
if(updateAvailable > 0)
|
||||||
|
return {
|
||||||
|
version: latestReleaseVersion,
|
||||||
|
url: releaseInfo.data.html_url,
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { appName, appVersion, hasUpdate };
|
@@ -68,4 +68,4 @@ async function remove(key) {
|
|||||||
await fs.promises.writeFile(configLocation, arr.join('\n'));
|
await fs.promises.writeFile(configLocation, arr.join('\n'));
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { get, set, remove }
|
module.exports = { get, set, remove, configFolder }
|
@@ -1,7 +1,5 @@
|
|||||||
const appInfo = require('./appInfo.js');
|
const appInfo = require('./appInfo.js');
|
||||||
const DiscordAutoRPC = require("discord-auto-rpc");
|
const DiscordAutoRPC = require("discord-auto-rpc");
|
||||||
const { app } = require('electron');
|
|
||||||
const DiscordRPC = require("discord-rpc").default;
|
|
||||||
const clientId = "1032772293220384808";
|
const clientId = "1032772293220384808";
|
||||||
let client = undefined;
|
let client = undefined;
|
||||||
let lastState = "Idle in Launcher...";
|
let lastState = "Idle in Launcher...";
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ezpplauncher",
|
"name": "ezpplauncher",
|
||||||
"version": "1.1.2",
|
"version": "1.1.4",
|
||||||
"main": "app.js",
|
"main": "app.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "HorizonCode",
|
"author": "HorizonCode",
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
"runAfterFinish": true
|
"runAfterFinish": true
|
||||||
},
|
},
|
||||||
"portable": {
|
"portable": {
|
||||||
"artifactName": "EZPPLauncher.exe"
|
"artifactName": "ezpplauncher-${version}.exe"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"frontend": {
|
"frontend": {
|
||||||
@@ -46,6 +46,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.27.2",
|
"axios": "^0.27.2",
|
||||||
|
"compare-versions": "^6.0.0-rc.1",
|
||||||
"custom-electron-titlebar": "^4.1.1",
|
"custom-electron-titlebar": "^4.1.1",
|
||||||
"discord-auto-rpc": "^1.0.17",
|
"discord-auto-rpc": "^1.0.17",
|
||||||
"discord-rpc": "^4.0.1",
|
"discord-rpc": "^4.0.1",
|
||||||
|
@@ -1,16 +1,16 @@
|
|||||||
const { ipcRenderer } = require('electron');
|
const { ipcRenderer, shell } = require('electron');
|
||||||
const { Titlebar, Color } = require('custom-electron-titlebar');
|
const { Titlebar, TitlebarColor } = require('custom-electron-titlebar');
|
||||||
const appInfo = require('../appInfo');
|
const appInfo = require('../appInfo');
|
||||||
let titlebar;
|
|
||||||
let currentPage = "loading";
|
let currentPage = "loading";
|
||||||
let loggedIn = false;
|
let loggedIn = false;
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', () => {
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
titlebar = new Titlebar({
|
const titlebar = new Titlebar({
|
||||||
backgroundColor: Color.fromHex("#24283B"),
|
backgroundColor: TitlebarColor.fromHex("#24283B"),
|
||||||
itemBackgroundColor: Color.fromHex("#121212"),
|
itemBackgroundColor: TitlebarColor.fromHex("#121212"),
|
||||||
menu: null,
|
menu: null,
|
||||||
maximizable: false
|
enableMnemonics: false,
|
||||||
|
maximizable: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
titlebar.updateTitle(`${appInfo.appName} ${appInfo.appVersion}`);
|
titlebar.updateTitle(`${appInfo.appName} ${appInfo.appVersion}`);
|
||||||
@@ -150,10 +150,23 @@ window.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ipcRenderer.on('launcher_update', async (event, data) => {
|
||||||
|
const res = await Swal.fire({
|
||||||
|
title: 'Update available!',
|
||||||
|
text: `Version ${data.version} has been released!`,
|
||||||
|
icon: 'info',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: 'Download',
|
||||||
|
cancelButtonText: 'Remind me later',
|
||||||
|
});
|
||||||
|
if (res.isConfirmed) {
|
||||||
|
shell.openExternal(data.url);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
ipcRenderer.on('account_update', (event, data) => {
|
ipcRenderer.on('account_update', (event, data) => {
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case "login-failed":
|
case "login-failed":
|
||||||
console.log(data);
|
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: 'Uh oh!',
|
title: 'Uh oh!',
|
||||||
text: data.message,
|
text: data.message,
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const appInfo = require('../appInfo');
|
const appInfo = require('../appInfo');
|
||||||
const { BrowserWindow } = require('electron');
|
const { BrowserWindow, Menu } = require('electron');
|
||||||
const { attachTitlebarToWindow } = require('custom-electron-titlebar/main');
|
const { attachTitlebarToWindow } = require('custom-electron-titlebar/main');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@@ -26,6 +26,10 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
icon: './assets/logo.png'
|
icon: './assets/logo.png'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const menu = Menu.buildFromTemplate([])
|
||||||
|
Menu.setApplicationMenu(menu);
|
||||||
|
|
||||||
window.hide();
|
window.hide();
|
||||||
|
|
||||||
window.webContents.once("did-finish-load", function (event, input) {
|
window.webContents.once("did-finish-load", function (event, input) {
|
||||||
@@ -33,6 +37,7 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
window.webContents.setUserAgent(`${appInfo.appName} ${appInfo.appVersion}`);
|
window.webContents.setUserAgent(`${appInfo.appName} ${appInfo.appVersion}`);
|
||||||
|
|
||||||
attachTitlebarToWindow(window);
|
attachTitlebarToWindow(window);
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
|
Reference in New Issue
Block a user