~dricottone/noticable

ref: ef0b3a690cfd0421bbed57a058445814a5fc348c noticable/main.js -rw-r--r-- 814 bytes
ef0b3a69Dominic Ricottone functional markdown rendering 3 years ago
                                                                                
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
const { app, BrowserWindow } = require('electron');
const shortcut = require('electron-localshortcut');
const path = require('path');

app.on('ready', () => {
  const win = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      contextIsolation: true,
      nodeIntegration: false,
      preload: path.join(__dirname, 'preload.js')
    }
  });

  win.loadFile(path.join(__dirname, 'index.html'));

  shortcut.register(win, 'CmdOrCtrl+S', () => {
    console.log("[main] triggering 'request-render-markdown'...")
    win.webContents.send('request-render-markdown', '');
  });
});

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit();
  }
});

app.on('activate', () => {
  if (BrowserWindow.getAllWindows().length === 0) {
    createWindow();
  }
});