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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
import { webFrame } from 'electron';
import { render } from 'react-dom';
import { Provider } from 'mobx-react';
import { syncHistoryWithStore, RouterStore } from 'mobx-react-router';
import { hashHistory } from 'react-router';
import ServerApi from './api/server/ServerApi';
import LocalApi from './api/server/LocalApi';
import storeFactory from './stores';
import apiFactory from './api';
import actions from './actions';
import MenuFactory from './lib/Menu';
import TouchBarFactory from './lib/TouchBar';
import I18N from './I18n';
import Routes from './routes';
// Basic electron Setup
webFrame.setVisualZoomLevelLimits(1, 1);
window.addEventListener('load', () => {
const serverApi = new ServerApi();
const api = apiFactory(serverApi, new LocalApi());
const router = new RouterStore();
const stores = storeFactory(api, actions, router);
const history = syncHistoryWithStore(hashHistory, router);
const menu = new MenuFactory(stores, actions);
const touchBar = new TouchBarFactory(stores, actions);
window['ferdium'] = {
stores,
actions,
api,
menu,
touchBar,
features: {},
render() {
const preparedApp = (
<Provider stores={stores} actions={actions}>
<I18N>
<Routes history={history} />
</I18N>
</Provider>
);
render(preparedApp, document.querySelector('#root'));
},
};
window['ferdium'].render();
});
// Prevent back and forward mouse events for the app itself (not inside the recipe)
// TODO: send this request to the recipe.js
window.addEventListener('mouseup', e => {
if (e.button === 3 || e.button === 4) {
e.preventDefault()
e.stopPropagation()
}
});
// Prevent drag and drop into window from redirecting
window.addEventListener('dragover', event => event.preventDefault());
window.addEventListener('drop', event => event.preventDefault());
window.addEventListener('dragover', event => event.stopPropagation());
window.addEventListener('drop', event => event.stopPropagation());
|