-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
79 lines (72 loc) · 2.14 KB
/
index.html
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
<!DOCTYPE html>
<head>
<title> Testing Electron Updater</title>
<style>
body{
box-sizing: border-box;
margin: 0;
padding: 20px;
font-family: sans-serif;
background-color: #eaeaea;
text-align: center;
}
#notification {
position: fixed;
bottom: 20px;
left: 20px;
width: 200px;
padding: 20px;
border-radius: 5px;
background-color: white;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}
.hidden {
display: none;
}
</style>
</head>
<body>
<h1>Testing Electron Updater</h1>
<p id = "app-version"></p>
<div id="notification" class="hidden">
<p id="message"></p>
<button id="close-button" onClick="closeNotification()">
Close
</button>
<button id="restart-button" onClick="restartApp()" class="hidden">
Restart
</button>
</div>
<script>
const {ipcRenderer} = require('electron');
const version = document.getElementById('app-version');
ipcRenderer.send('app_version');
ipcRenderer.on('app_version', (event, arg) => {
ipcRenderer.removeAllListeners('app_version');
version.innerText = 'Version ' + arg.version;
});
const notification = document.getElementById('notification');
const message = document.getElementById('message');
const restartButton = document.getElementById('restart-button');
ipcRenderer.on('update_available', () => {
ipcRenderer.removeAllListeners('update_available');
message.innerText = 'A new update is available. Downloading now...';
notification.classList.remove('hidden');
});
ipcRenderer.on('update_downloaded', () => {
ipcRenderer.removeAllListeners('update_downloaded');
message.innerText = 'Update Downloaded. It will be installed on restart. Restart now?';
restartButton.classList.remove('hidden');
notification.classList.remove('hidden');
});
function closeNotification() {
notification.classList.add('hidden');
}
function restartApp() {
ipcRenderer.send('restart_app');
}
ipcMain.on('restart_app', () => {
autoUpdater.quitAndInstall();
});
</script>
</body>