2017-12-21 18:32:51 +01:00
|
|
|
import store from 'store';
|
|
|
|
import { remote } from 'electron';
|
2017-12-21 23:09:30 +01:00
|
|
|
import Path from 'path';
|
2017-12-21 18:32:51 +01:00
|
|
|
import y18n from 'y18n';
|
2018-03-08 00:03:45 +01:00
|
|
|
import isDev from 'electron-is-dev';
|
2017-02-20 19:56:15 +01:00
|
|
|
|
2017-12-21 18:32:51 +01:00
|
|
|
const env = process.env.NODE_ENV || 'production';
|
|
|
|
const i18n = y18n({
|
2017-12-21 23:09:30 +01:00
|
|
|
directory: Path.join(remote.app.getAppPath(), '/../static/locales').replace(/\\/g, '\\\\'),
|
2017-06-20 14:08:52 +02:00
|
|
|
updateFiles: false,
|
2017-12-21 18:32:51 +01:00
|
|
|
locale: 'en',
|
2017-06-06 06:21:55 +02:00
|
|
|
});
|
2017-12-13 22:36:30 +01:00
|
|
|
|
2017-04-07 07:15:22 +02:00
|
|
|
const logs = [];
|
|
|
|
const app = {
|
2017-12-13 22:36:30 +01:00
|
|
|
env,
|
|
|
|
store,
|
|
|
|
i18n,
|
|
|
|
logs,
|
|
|
|
log(message) {
|
2017-06-20 14:08:52 +02:00
|
|
|
logs.push(message);
|
|
|
|
},
|
2017-06-06 06:21:55 +02:00
|
|
|
};
|
2016-11-22 21:19:08 +01:00
|
|
|
|
2018-03-22 19:52:07 +01:00
|
|
|
// Workaround for https://github.com/electron-userland/electron-webpack/issues/52
|
|
|
|
if (!isDev) {
|
|
|
|
window.staticResourcesPath = Path.join(remote.app.getAppPath(), '../static').replace(
|
|
|
|
/\\/g,
|
|
|
|
'\\\\'
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
window.staticResourcesPath = '';
|
|
|
|
}
|
|
|
|
|
2017-12-21 18:32:51 +01:00
|
|
|
// eslint-disable-next-line no-underscore-dangle
|
2017-12-21 23:09:30 +01:00
|
|
|
global.__ = i18n.__;
|
2017-12-21 18:32:51 +01:00
|
|
|
// eslint-disable-next-line no-underscore-dangle
|
2017-12-21 23:09:30 +01:00
|
|
|
global.__n = i18n.__n;
|
|
|
|
global.app = app;
|
|
|
|
|
|
|
|
export default app;
|