-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7278faa
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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> |