Initial scaffold for Aether Native V3 Electron Launcher

This commit is contained in:
Scott Idem
2026-01-23 13:54:20 -05:00
parent fdbd12b64f
commit 0497f5767b
44 changed files with 537 additions and 7294 deletions

76
src/main/index.ts Normal file
View File

@@ -0,0 +1,76 @@
import { app, BrowserWindow, ipcMain } from 'electron';
import * as path from 'path';
import { loadSeedConfig } from './config_loader';
import { fetchFullConfig } from './api_client';
import { SeedConfig } from '../shared/types';
let mainWindow: BrowserWindow | null = null;
let cachedSeed: SeedConfig | null = null;
let cachedFullConfig: any = null;
async function createWindow() {
// 1. Initial Load of Configs
cachedSeed = await loadSeedConfig();
if (cachedSeed) {
cachedFullConfig = await fetchFullConfig(cachedSeed);
}
mainWindow = new BrowserWindow({
width: 1400,
height: 900,
title: 'OSIT Aether Launcher (Native)',
webPreferences: {
preload: path.join(__dirname, '../preload/index.js'),
contextIsolation: true,
nodeIntegration: false,
},
});
// Prioritize demo.localhost for local development
const devUrl = 'http://demo.localhost:5173';
// Fallback URL if local is offline
const fallbackUrl = 'https://dev-demo.oneskyit.com/';
console.log(`Loading UI from: ${devUrl}`);
mainWindow.loadURL(devUrl).catch(() => {
console.warn(`Failed to load ${devUrl}. Falling back to ${fallbackUrl}`);
mainWindow?.loadURL(fallbackUrl);
});
mainWindow.on('closed', () => {
mainWindow = null;
});
}
app.on('ready', createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (mainWindow === null) {
createWindow();
}
});
// IPC Handlers
ipcMain.handle('get-seed-config', async () => {
return cachedSeed || await loadSeedConfig();
});
ipcMain.handle('get-device-config', async () => {
if (cachedFullConfig) return cachedFullConfig;
if (cachedSeed) {
cachedFullConfig = await fetchFullConfig(cachedSeed);
return cachedFullConfig;
}
return null;
});
ipcMain.handle('get-jwt', async () => {
return null;
});