forked from ElectronNET/Electron.NET
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathIndex.cshtml
More file actions
60 lines (53 loc) · 2.75 KB
/
Copy pathIndex.cshtml
File metadata and controls
60 lines (53 loc) · 2.75 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
<template class="task-template">
<section id="update-section" class="section js-section u-category-update">
<header class="section-header">
<div class="section-wrapper">
<h1>
<svg class="section-icon"><use xlink:href="assets/img/icons.svg#icon-update"></use></svg>
Update
</h1>
<h3>The <code>Electron.AutoUpdater</code> allows you to automatically update your application.</h3>
<p>To publish your updates you just need simple file hosting, it does not require a dedicated server.</p>
<p>You find the sample source code in <code>Controllers\UpdateController.cs</code>.</p>
</div>
</header>
<div class="demo">
<div class="demo-wrapper">
<button id="tray-demo-toggle" class="js-container-target demo-toggle-button">
Auto Update this App
<div class="demo-meta u-avoid-clicks">Supports: Win, macOS, Linux | Process: Main</div>
</button>
<div class="demo-box">
<div class="demo-controls">
<button class="demo-button" id="btn-update">View Demo</button>
<span class="demo-response" id="demo-reply"></span>
</div>
<p>The demo button call the <code>Electron.AutoUpdater.CheckForUpdatesAndNotifyAsync()</code> in the main process.</p>
<p>This will immediately download an update, then install in the background when the app quits.</p>
<h5>Main Process (C#)</h5>
<pre><code class="csharp">Electron.IpcMain.On("auto-update", async (args) =>
{
var currentVersion = await Electron.App.GetVersionAsync();
var updateCheckResult = await Electron.AutoUpdater.CheckForUpdatesAndNotifyAsync();
var availableVersion = updateCheckResult.UpdateInfo.Version;
string information = $"Current version: {currentVersion} - available version: {availableVersion}";
var mainWindow = Electron.WindowManager.BrowserWindows.First();
Electron.IpcMain.Send(mainWindow, "auto-update-reply", information);
});
</code></pre>
</div>
</div>
</div>
<script>
(function(){
const { ipcRenderer } = require("electron");
document.getElementById("btn-update").addEventListener("click", () => {
ipcRenderer.send("auto-update");
});
ipcRenderer.on('auto-update-reply', (event, message) => {
document.getElementById('demo-reply').innerHTML = message;
});
}());
</script>
</section>
</template>