lbry-desktop/src/renderer/app.js

42 lines
926 B
JavaScript
Raw Normal View History

import store from 'store';
import { remote } from 'electron';
import path from 'path';
import y18n from 'y18n';
const env = process.env.NODE_ENV || 'production';
const config = {
...import(`./config/${env}`),
};
const i18n = y18n({
directory: path.join(remote.app.getAppPath(), '/../static/locales').replace(/\\/g, '\\\\'),
2017-06-20 14:08:52 +02:00
updateFiles: false,
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,
config,
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
// Workaround for https://github.com/electron-userland/electron-webpack/issues/52
if (env !== 'development') {
window.staticResourcesPath = path
.join(remote.app.getAppPath(), '../static')
.replace(/\\/g, '\\\\');
} else {
window.staticResourcesPath = '';
}
// eslint-disable-next-line no-underscore-dangle
window.__ = i18n.__;
// eslint-disable-next-line no-underscore-dangle
window.__n = i18n.__n;
window.app = app;