mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-01-09 18:45:38 +00:00
182eaa4329
* Basic webpack build started. * Get build working with electron-packager. Not fully satisfied, might investigate electron-builder. * Custom title bar * Rewrite all webpack configs to use common function. Organize webpack utils. Split into multiple dist folders. * Replace electron build with electron-builder. Leave around packager for a bit. * Check in progress on updater. * Update modal flow. * Fix tscheck. * Adjust publish info. * Arbitrary version bump. * Bump version again. * 5.0.2 bump fix autodownload. * 5.0.2 bump again, readd dmg * 5.0.3 bump * Turn auto update back off. Log errors. Revert versions. * Add os-specific builds. Improve update failure. * Open external links in browser in electron. * Remove custom title bar temporarily. * Add info about the update download to the modal. * Turn off development changes. * Take the postBuild sorting script and move it into a webpack config. * Initial conversion to typescript and electron-webpack. * Switch from electron-webpack back to custom config, clean up unused code, typify electron bridge. * Better typing for bridge. * Remove unnecessary file. * Reminify. * Add shared folder resolving to jest config. * Add enum to electron events
87 lines
2.1 KiB
TypeScript
87 lines
2.1 KiB
TypeScript
import { app, BrowserWindow, Menu } from 'electron';
|
|
import * as path from 'path';
|
|
import updater from './updater';
|
|
import MENU from './menu';
|
|
|
|
const isDevelopment = process.env.NODE_ENV !== 'production';
|
|
|
|
// Global reference to mainWindow
|
|
// Necessary to prevent window from being garbage collected
|
|
let mainWindow;
|
|
|
|
function createMainWindow() {
|
|
// Construct new BrowserWindow
|
|
const window = new BrowserWindow({
|
|
title: 'MyEtherWallet',
|
|
backgroundColor: '#fbfbfb',
|
|
width: 1220,
|
|
height: 800,
|
|
minWidth: 320,
|
|
minHeight: 400,
|
|
// TODO - Implement styles for custom title bar in components/ui/TitleBar.scss
|
|
// frame: false,
|
|
// titleBarStyle: 'hidden',
|
|
webPreferences: {
|
|
devTools: true,
|
|
nodeIntegration: false,
|
|
preload: path.resolve(__dirname, 'preload.js')
|
|
}
|
|
});
|
|
|
|
const url = isDevelopment
|
|
? `http://localhost:${process.env.HTTPS ? 3443 : 3000}`
|
|
: `file://${__dirname}/index.html`;
|
|
window.loadURL(url);
|
|
|
|
window.on('closed', () => {
|
|
mainWindow = null;
|
|
});
|
|
|
|
window.webContents.on('devtools-opened', () => {
|
|
window.focus();
|
|
setImmediate(() => {
|
|
window.focus();
|
|
});
|
|
});
|
|
|
|
if (isDevelopment) {
|
|
window.webContents.on('did-fail-load', () => {
|
|
setTimeout(() => {
|
|
if (window && window.webContents) {
|
|
window.webContents.reload();
|
|
}
|
|
}, 500);
|
|
});
|
|
}
|
|
|
|
Menu.setApplicationMenu(Menu.buildFromTemplate(MENU));
|
|
|
|
return window;
|
|
}
|
|
|
|
// Quit application when all windows are closed
|
|
app.on('window-all-closed', () => {
|
|
// On macOS it is common for applications to stay open
|
|
// until the user explicitly quits
|
|
if (process.platform !== 'darwin') {
|
|
app.quit();
|
|
}
|
|
});
|
|
|
|
app.on('activate', () => {
|
|
// On macOS it is common to re-create a window
|
|
// even after all windows have been closed
|
|
if (mainWindow === null) {
|
|
mainWindow = createMainWindow();
|
|
updater(app, mainWindow);
|
|
}
|
|
});
|
|
|
|
// Create main BrowserWindow when electron is ready
|
|
app.on('ready', () => {
|
|
mainWindow = createMainWindow();
|
|
mainWindow.webContents.on('did-finish-load', () => {
|
|
updater(app, mainWindow);
|
|
});
|
|
});
|