Initial scaffold for Aether Native V3 Electron Launcher
This commit is contained in:
76
src/main/index.ts
Normal file
76
src/main/index.ts
Normal 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;
|
||||
});
|
||||
Reference in New Issue
Block a user