index.js
1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// This file does async imports of the heavy JSX, especially app.jsx, to avoid blocking the first render.
// The main index.html just contains a loading/splash screen which will display while this import loads.
import {ipcRenderer} from 'electron';
import ReactDOM from 'react-dom';
ipcRenderer.on('ready-to-show', () => {
// Start without any element in focus, otherwise the first link starts with focus and shows an orange box.
// We shouldn't disable that box or the focus behavior in case someone wants or needs to navigate that way.
// This seems like a hack... maybe there's some better way to do avoid any element starting with focus?
document.activeElement.blur();
});
const route = new URLSearchParams(window.location.search).get('route') || 'app';
let routeModulePromise;
switch (route) {
case 'loading':
routeModulePromise = import('./loading.jsx');
break;
case 'app':
routeModulePromise = import('./app.jsx');
break;
case 'about':
routeModulePromise = import('./about.jsx');
break;
case 'license':
routeModulePromise = import('./license.jsx');
break;
case 'privacy':
routeModulePromise = import('./privacy.jsx');
break;
}
routeModulePromise.then(routeModule => {
const appTarget = document.getElementById('app');
const routeElement = routeModule.default;
ReactDOM.render(routeElement, appTarget);
});