|
| 1 | +<!doctype html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <meta name="viewport" content="width=device-width,initial-scale=1"> |
| 6 | + <title>Updater Demo</title> |
| 7 | + <style> |
| 8 | + :root { color-scheme: light dark; } |
| 9 | + body { |
| 10 | + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; |
| 11 | + padding: 24px; |
| 12 | + margin: 0; |
| 13 | + display: flex; |
| 14 | + flex-direction: column; |
| 15 | + align-items: center; |
| 16 | + justify-content: center; |
| 17 | + min-height: 100vh; |
| 18 | + box-sizing: border-box; |
| 19 | + color: #1d1d1f; |
| 20 | + background: #ffffff; |
| 21 | + } |
| 22 | + @media (prefers-color-scheme: dark) { |
| 23 | + body { background: #1e1e1e; color: #f5f5f7; } |
| 24 | + } |
| 25 | + .badge { |
| 26 | + font-size: 14px; |
| 27 | + letter-spacing: 0.08em; |
| 28 | + text-transform: uppercase; |
| 29 | + color: #6e6e73; |
| 30 | + margin-bottom: 8px; |
| 31 | + } |
| 32 | + .version { |
| 33 | + font-size: clamp(64px, 18vw, 144px); |
| 34 | + font-weight: 700; |
| 35 | + letter-spacing: -0.04em; |
| 36 | + line-height: 1; |
| 37 | + margin: 0 0 24px; |
| 38 | + font-variant-numeric: tabular-nums; |
| 39 | + } |
| 40 | + .hint { |
| 41 | + font-size: 14px; |
| 42 | + color: #6e6e73; |
| 43 | + max-width: 480px; |
| 44 | + text-align: center; |
| 45 | + margin: 0 0 24px; |
| 46 | + } |
| 47 | + .status { |
| 48 | + width: min(560px, 100%); |
| 49 | + padding: 12px 14px; |
| 50 | + background: rgba(0,0,0,0.06); |
| 51 | + border-radius: 8px; |
| 52 | + font-family: ui-monospace, SFMono-Regular, Menlo, monospace; |
| 53 | + font-size: 12px; |
| 54 | + white-space: pre-wrap; |
| 55 | + max-height: 12em; |
| 56 | + overflow-y: auto; |
| 57 | + } |
| 58 | + @media (prefers-color-scheme: dark) { |
| 59 | + .status { background: rgba(255,255,255,0.06); } |
| 60 | + } |
| 61 | + </style> |
| 62 | +</head> |
| 63 | +<body> |
| 64 | + <div class="badge">running version</div> |
| 65 | + <p class="version" id="version">—</p> |
| 66 | + <p class="hint">Use <strong>App → Check for Updates…</strong> to swap this |
| 67 | + binary for the latest release on |
| 68 | + <code>wailsapp/updater-demo</code> and restart.</p> |
| 69 | + <div class="status" id="status">waiting…</div> |
| 70 | + |
| 71 | + <script type="module"> |
| 72 | + const params = new URLSearchParams(location.search); |
| 73 | + document.getElementById("version").textContent = "v" + (params.get("v") || "?"); |
| 74 | + |
| 75 | + const status = document.getElementById("status"); |
| 76 | + function log(line) { |
| 77 | + const t = new Date().toISOString().slice(11, 19); |
| 78 | + status.textContent = `[${t}] ${line}\n` + status.textContent; |
| 79 | + } |
| 80 | + const wails = window.wails; |
| 81 | + if (wails && wails.Events) { |
| 82 | + wails.Events.On("updater:check-started", () => log("check started")); |
| 83 | + wails.Events.On("updater:update-available", (e) => log(`available: v${(e.data ?? e).version}`)); |
| 84 | + wails.Events.On("updater:no-update", () => log("up to date")); |
| 85 | + wails.Events.On("updater:download-progress", (e) => { |
| 86 | + const p = e.data ?? e; |
| 87 | + if (p.total > 0) log(`downloading: ${p.written}/${p.total}`); |
| 88 | + else log(`downloading: ${p.written} bytes`); |
| 89 | + }); |
| 90 | + wails.Events.On("updater:update-ready", () => log("ready — restart to apply")); |
| 91 | + wails.Events.On("updater:error", (e) => log(`error: ${(e.data ?? e).message}`)); |
| 92 | + } |
| 93 | + </script> |
| 94 | +</body> |
| 95 | +</html> |
0 commit comments