Skip to content

Commit

Permalink
setup for electron + gh pages 1 branch, and add stubs for API
Browse files Browse the repository at this point in the history
  • Loading branch information
wigginno committed Aug 22, 2024
1 parent 5b6deba commit 03cc3d6
Show file tree
Hide file tree
Showing 9 changed files with 2,557 additions and 71 deletions.
3 changes: 3 additions & 0 deletions global-shim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if (typeof global === 'undefined') {
var global = window;
}
60 changes: 60 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const { app, BrowserWindow } = require('electron');
const path = require('path');

let mainWindow;

async function createWindow() {
const isDev = (await import('electron-is-dev')).default;

mainWindow = new BrowserWindow({
width: 1200,
height: 900,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
}
});

const url = isDev
? 'http://localhost:9328'
: `file://${path.join(__dirname, 'dist/index.html')}`;

console.log('Loading URL:', url);

mainWindow.loadURL(url).catch(err => {
console.error('Failed to load URL:', err);
});

mainWindow.on('closed', () => {
mainWindow = null;
});

if (isDev) {
try {
const { default: installExtension, REACT_DEVELOPER_TOOLS } = require('electron-extension-installer');
await installExtension(REACT_DEVELOPER_TOOLS, {
loadExtensionOptions: {
allowFileAccess: true,
},
});
} catch (e) {
console.error('Failed to install extension:', e);
}
}
}

app.on("ready", async () => {
createWindow();
});

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});

app.on('activate', () => {
if (mainWindow === null) {
createWindow();
}
});
Loading

0 comments on commit 03cc3d6

Please sign in to comment.