Files: c6d1abe2035f17f456b7dac57fdbc88a3a10eff0 / index.js
2155 bytesRaw
1 | process.on('uncaughtException', function (err) { |
2 | console.log(err) |
3 | process.exit() |
4 | }) |
5 | |
6 | var electron = require('electron') |
7 | var openWindow = require('./lib/window') |
8 | |
9 | var Path = require('path') |
10 | var defaultMenu = require('electron-default-menu') |
11 | var Menu = electron.Menu |
12 | var extend = require('xtend') |
13 | var ssbKeys = require('ssb-keys') |
14 | |
15 | var windows = { |
16 | dialogs: new Set() |
17 | } |
18 | |
19 | var ssbConfig = require('./config') |
20 | |
21 | electron.app.on('ready', () => { |
22 | setupContext(() => { |
23 | Menu.setApplicationMenu(Menu.buildFromTemplate(defaultMenu(electron.app, electron.shell))) |
24 | openMainWindow() |
25 | }) |
26 | |
27 | electron.app.on('activate', function (e) { |
28 | openMainWindow() |
29 | }) |
30 | |
31 | electron.ipcMain.on('open-background-devtools', function (ev, config) { |
32 | if (windows.background) { |
33 | windows.background.webContents.openDevTools({detach: true}) |
34 | } |
35 | }) |
36 | }) |
37 | |
38 | function openMainWindow () { |
39 | if (!windows.main) { |
40 | windows.main = openWindow(ssbConfig, Path.join(__dirname, 'main-window.js'), { |
41 | minWidth: 800, |
42 | width: 1024, |
43 | height: 768, |
44 | titleBarStyle: 'hidden-inset', |
45 | title: 'Patchwork', |
46 | show: true, |
47 | backgroundColor: '#EEE', |
48 | webPreferences: { |
49 | experimentalFeatures: true |
50 | }, |
51 | icon: './ferment-logo.png' |
52 | }) |
53 | windows.main.setSheetOffset(40) |
54 | windows.main.on('closed', function () { |
55 | windows.main = null |
56 | if (process.platform != 'darwin') electron.app.quit() |
57 | }) |
58 | } |
59 | } |
60 | |
61 | function setupContext (cb) { |
62 | if (ssbConfig.server === false) { |
63 | cb && cb() |
64 | } else { |
65 | electron.ipcMain.once('server-started', function (ev) { |
66 | cb && cb() |
67 | }) |
68 | windows.background = openWindow(ssbConfig, Path.join(__dirname, 'server-process.js'), { |
69 | connect: false, |
70 | center: true, |
71 | fullscreen: false, |
72 | fullscreenable: false, |
73 | height: 150, |
74 | maximizable: false, |
75 | minimizable: false, |
76 | resizable: false, |
77 | show: false, |
78 | skipTaskbar: true, |
79 | title: 'patchwork-server', |
80 | useContentSize: true, |
81 | width: 150 |
82 | }) |
83 | // windows.background.on('close', (ev) => { |
84 | // ev.preventDefault() |
85 | // windows.background.hide() |
86 | // }) |
87 | } |
88 | } |
89 |
Built with git-ssb-web