-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
48 lines (39 loc) · 1.17 KB
/
index.js
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
const { app, BrowserWindow, ipcMain, Tray, Menu, MenuItem, shell } = require('electron');
const path = require('path')
const local = require('local-npm');
const os = require('os');
const assetsDir = path.resolve(__dirname, 'assets');
const server = local({
directory: path.resolve(os.homedir(), '.local-npm'),
port: 5678,
pouchPort: 3040,
logLevel: 'error',
remote: 'https://registry.npmjs.org',
remoteSkim: 'https://replicate.npmjs.com',
url: 'http://127.0.0.1:5080',
syncInterval: 60000
}, () => {
console.log('listening!');
});
let tray;
app.on('ready', () => {
tray = new Tray(path.resolve(assetsDir, 'cloudTemplate.png'));
var requests = 0;
var sync = 0;
function getMenu() {
return Menu.buildFromTemplate([
{label: 'http://localhost:5678', click: function() { shell.openExternal('http://localhost:5678/_browse') } },
{label: `requests: ${requests}`, type: 'normal'},
{label: `sync: ${sync}`, type: 'normal'}
]);
}
process.on('request', (args) => {
++requests;
})
process.on('sync', (args) => {
sync = args[1];
})
tray.on('click', function() {
tray.popUpContextMenu(getMenu())
})
});