Upload via GUI (18 Dateien)
This commit is contained in:
+78
-4
@@ -16,6 +16,8 @@ const launcher = require('./launcher');
|
||||
const loaders = require('./loaders');
|
||||
const forge = require('./forge');
|
||||
const auth = require('./auth');
|
||||
const updater = require('./updater');
|
||||
const icons = require('./icons');
|
||||
|
||||
// undici als globales fetch verwenden -> ermöglicht Proxy via setGlobalDispatcher
|
||||
const undici = require('undici');
|
||||
@@ -78,10 +80,10 @@ function windowIcon() {
|
||||
|
||||
function createWindow() {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 1100,
|
||||
height: 720,
|
||||
minWidth: 880,
|
||||
minHeight: 560,
|
||||
width: 1200,
|
||||
height: 820,
|
||||
minWidth: 940,
|
||||
minHeight: 640,
|
||||
backgroundColor: '#1b1e24',
|
||||
title: 'AeroMC',
|
||||
icon: windowIcon(),
|
||||
@@ -108,6 +110,24 @@ app.whenReady().then(() => {
|
||||
applyProxy(store.getSettings());
|
||||
createWindow();
|
||||
|
||||
// echte Minecraft-Icons einmalig aus den eigenen Spieldateien holen
|
||||
setTimeout(() => {
|
||||
try {
|
||||
const { shared, out } = iconDirs();
|
||||
if (!fs.existsSync(out) || fs.readdirSync(out).length === 0) icons.extractIcons(shared, out);
|
||||
} catch { /* noch keine Version heruntergeladen */ }
|
||||
}, 1500);
|
||||
|
||||
// automatisch auf Updates prüfen (kurz nach dem Start)
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
const info = await updater.checkForUpdate(app.getVersion());
|
||||
if (info.available && mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('update:available', info);
|
||||
}
|
||||
} catch { /* offline o. Ä. – still ignorieren */ }
|
||||
}, 4000);
|
||||
|
||||
// Anmelde-Dienste automatisch überwachen (sofort + alle 2 Minuten)
|
||||
setTimeout(() => checkAuthServices(), 2500);
|
||||
setInterval(() => checkAuthServices(), 120000);
|
||||
@@ -514,6 +534,9 @@ ipcMain.handle('instances:launch', async (_e, id, accountId) => {
|
||||
preLaunchCommand: inst.preLaunchCommand || settings.globalPreLaunch || '',
|
||||
postExitCommand: inst.postExitCommand || settings.globalPostExit || '',
|
||||
wrapperCommand: settings.wrapperCommand || '',
|
||||
mcMaximized: !!settings.mcMaximized,
|
||||
mcWidth: settings.mcWidth || 854,
|
||||
mcHeight: settings.mcHeight || 480,
|
||||
auth: null,
|
||||
};
|
||||
|
||||
@@ -606,6 +629,57 @@ ipcMain.handle('app:openExternal', (_e, url) => {
|
||||
return true;
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// IPC – echte Minecraft-Icons (aus den eigenen Spieldateien)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function iconDirs() {
|
||||
const ud = app.getPath('userData');
|
||||
const parent = path.dirname(ud);
|
||||
// auch im Datenordner vor der Umbenennung suchen
|
||||
const candidates = [path.join(ud, 'shared')];
|
||||
for (const alt of ['viper-network', 'Viper-Network', 'aeromc', 'AeroMC']) {
|
||||
const p = path.join(parent, alt, 'shared');
|
||||
if (!candidates.includes(p)) candidates.push(p);
|
||||
}
|
||||
return { shared: candidates, out: path.join(ud, 'icons') };
|
||||
}
|
||||
|
||||
ipcMain.handle('icons:list', () => {
|
||||
const { out } = iconDirs();
|
||||
return icons.listIcons(out);
|
||||
});
|
||||
|
||||
ipcMain.handle('icons:extract', () => {
|
||||
const { shared, out } = iconDirs();
|
||||
const res = icons.extractIcons(shared, out);
|
||||
if (!res.ok) return { ok: false, reason: res.reason };
|
||||
return { ok: true, version: res.version, count: res.count, icons: icons.listIcons(out) };
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// IPC – Automatische Updates
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
ipcMain.handle('update:check', async () => {
|
||||
try { return await updater.checkForUpdate(app.getVersion()); }
|
||||
catch (err) { return { available: false, error: err.message }; }
|
||||
});
|
||||
|
||||
// Ein Klick: herunterladen, prüfen, Installer starten und Launcher beenden
|
||||
ipcMain.handle('update:install', async (_e, asset) => {
|
||||
try {
|
||||
const file = await updater.downloadAndInstall(asset, (p) => {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) mainWindow.webContents.send('update:progress', p);
|
||||
});
|
||||
updater.runInstaller(file.path);
|
||||
setTimeout(() => app.quit(), 1200); // Installer übernimmt, Launcher schließt sich
|
||||
return { ok: true, path: file.path };
|
||||
} catch (err) {
|
||||
return { ok: false, message: err.message };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('app:info', () => ({
|
||||
version: app.getVersion(),
|
||||
electron: process.versions.electron,
|
||||
|
||||
Reference in New Issue
Block a user