-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathelectron.js
More file actions
123 lines (104 loc) · 3.37 KB
/
electron.js
File metadata and controls
123 lines (104 loc) · 3.37 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
var BrowserWindow = require('browser-window');
var app = require('app');
var path = require('path');
var cp = require('child_process');
var mainWindow = null;
var handleSquirrelEvent = function () {
if (process.platform != 'win32') {
return false;
}
function executeSquirrelCommand(args, done) {
var updateDotExe = path.resolve(path.dirname(process.execPath),
'..', 'update.exe');
var child = cp.spawn(updateDotExe, args, {
detached: true
});
child.on('close', function (code) {
done();
});
};
function install(done) {
var target = path.basename(process.execPath);
executeSquirrelCommand(["--createShortcut", target], done);
};
function uninstall(done) {
var target = path.basename(process.execPath);
executeSquirrelCommand(["--removeShortcut", target], done);
};
var squirrelEvent = process.argv[1];
switch (squirrelEvent) {
case '--squirrel-install':
install(app.quit);
return true;
case '--squirrel-updated':
install(app.quit);
return true;
case '--squirrel-obsolete':
app.quit();
return true;
case '--squirrel-uninstall':
uninstall(app.quit);
return true;
}
return false;
};
var checkForGitHubRelease = function () {
var gh_releases = require('electron-gh-releases');
var options = {
repo: 'azure-storage/deco',
currentVersion: app.getVersion()
}
var update = new gh_releases(options, function (auto_updater) {
auto_updater.on('update-downloaded', function (e, rNotes, rName, rDate, uUrl, quitAndUpdate) {
var dialog = require('dialog');
dialog.showMessageBox({
type: 'info',
buttons: ['Hooray!'],
title: 'Update Downloaded',
message: 'We found and downdloaded a new version of the Azure Storage Explorer! Once you close this dialog, Azure Storage Explorer will automatically update and restart.'
});
// Install the update
quitAndUpdate();
});
});
// Check for updates
update.check(function (err, status) {
if (!err && status) {
update.download();
}
});
};
app.on('window-all-closed', function onWindowAllClosed() {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('ready', function onReady() {
if (handleSquirrelEvent()) {
return;
}
// Check for update - enable only when properly tested
// checkForGitHubRelease();
mainWindow = new BrowserWindow({
title: 'Azure Storage Explorer',
width: 1100,
height: 750,
min_width: 800,
min_height: 600,
});
delete mainWindow.module;
if (process.platform !== 'darwin' && process.platform.indexOf('win') === -1) {
mainWindow.icon = __dirname + '/icon/ase.png';
}
if (process.env.ELECTRON_ENV === 'development') {
// Dev Tools are included, but if you're in deep trouble,
// use the line below to programmtically open them:
// mainWindow.openDevTools();
mainWindow.loadUrl('http://localhost:5000');
} else {
mainWindow.loadUrl('file://' + __dirname + '/dist/index.html');
}
mainWindow.on('closed', function onClosed() {
mainWindow = null;
});
});