-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathupdater-dialog.html
More file actions
143 lines (143 loc) · 5.18 KB
/
updater-dialog.html
File metadata and controls
143 lines (143 loc) · 5.18 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Updater</title>
<style>
#log {
scrollbar-width: thin;
scrollbar-color: #3d3d3d #141414;
}
#log::-webkit-scrollbar {
width: 8px;
height: 8px;
}
#log::-webkit-scrollbar-track {
background: #141414;
border-radius: 4px;
}
#log::-webkit-scrollbar-thumb {
background: #3d3d3d;
border-radius: 4px;
border: 1px solid #1f1f1f;
}
#log::-webkit-scrollbar-thumb:hover {
background: #505050;
}
#log::-webkit-scrollbar-corner {
background: #0d0d0d;
}
#install:disabled {
opacity: 0.45;
cursor: not-allowed;
}
</style>
</head>
<body
style="
font-family: Segoe UI, Arial, sans-serif;
box-sizing: border-box;
padding: 12px 14px 10px;
background: #111;
color: #eee;
margin: 0;
"
>
<div id="cv" style="font-size: 12px; color: #aaa; margin-bottom: 6px"></div>
<div id="t" style="font-size: 14px; margin-bottom: 8px; line-height: 1.35">Checking for updates...</div>
<div id="progressWrap" style="display: none; margin-bottom: 8px">
<div style="height: 14px; background: #333; border-radius: 7px; overflow: hidden">
<div
id="b"
style="height: 100%; width: 0%; min-width: 0; background: #2ea043; transition: width 0.12s ease-out"
></div>
</div>
</div>
<div id="logWrap" style="margin-bottom: 8px">
<div style="font-size: 10px; color: #888; margin-bottom: 4px">Activity log</div>
<pre
id="log"
style="
margin: 0;
max-height: 90px;
overflow-y: auto;
overflow-x: auto;
background: #0d0d0d;
border: 1px solid #333;
border-radius: 4px;
padding: 6px 8px;
font: 11px/1.35 Consolas, 'Cascadia Mono', monospace;
color: #c9d1d9;
white-space: pre-wrap;
word-break: break-all;
"
></pre>
</div>
<div id="actionsWrap" style="display: none; flex-direction: row; justify-content: flex-end">
<button id="install" disabled style="padding: 5px 10px">Update with reload</button>
</div>
<script>
(function () {
try {
const { ipcRenderer } = require("electron");
function applyUpdaterUi(data) {
const t = document.getElementById("t");
const progressWrap = document.getElementById("progressWrap");
const actionsWrap = document.getElementById("actionsWrap");
const b = document.getElementById("b");
const i = document.getElementById("install");
if (t) t.textContent = data.text;
if (progressWrap) progressWrap.style.display = data.showProgress ? "block" : "none";
if (actionsWrap) actionsWrap.style.display = data.showActions ? "flex" : "none";
if (b) {
const w = Math.max(0, Math.min(100, Math.round(Number(data.percent) || 0)));
b.style.width = w + "%";
b.style.minWidth = w > 0 ? "2px" : "0";
}
if (i) i.disabled = !data.installEnabled;
}
function appendLogLine(line) {
const el = document.getElementById("log");
if (!el) return;
el.textContent += (el.textContent ? "\n" : "") + line;
const parts = el.textContent.split("\n");
if (parts.length > 220) el.textContent = parts.slice(-220).join("\n");
el.scrollTop = el.scrollHeight;
}
ipcRenderer.on("updater-ui", (_e, data) => applyUpdaterUi(data));
ipcRenderer.on("updater-log-init", (_e, lines) => {
const el = document.getElementById("log");
if (!el) return;
el.textContent = Array.isArray(lines) ? lines.join("\n") : "";
el.scrollTop = el.scrollHeight;
});
ipcRenderer.on("updater-log", (_e, line) =>
appendLogLine(typeof line === "string" ? line : String(line)),
);
const installBtn = document.getElementById("install");
if (installBtn) {
installBtn.addEventListener("click", async () => {
appendLogLine("[ui] Update with reload clicked — sending to main process…");
try {
const r = await ipcRenderer.invoke("updater-install-now");
if (r && r.ok === false) {
appendLogLine("[ui] Main refused: " + (r.err || "unknown"));
}
} catch (e) {
const msg = e && e.message ? e.message : String(e);
appendLogLine("[ui] IPC invoke failed: " + msg + " (trying legacy send)");
ipcRenderer.send("updater-install-click");
}
});
} else {
ipcRenderer.send("updater-renderer-error", "install button #install missing");
}
} catch (err) {
try {
require("electron").ipcRenderer.send("updater-renderer-error", String(err && err.message ? err.message : err));
} catch (_) {}
}
})();
</script>
</body>
</html>