Так что я довольно новичок в электронном программировании, и я пытаюсь заставить мое электронное приложение посмотреть на мои релизы github и определить, является ли мой локальный файл более новым / более старым, чем последняя версия файла в моем репозитории github.В настоящее время я в настоящее время использую версию 0.0.2-alpha, надеясь, что мое состояние кнопки изменится на «Обновление готово», однако, похоже, что моя последняя версия 0.0.3-alpha в моих версиях github отсутствует.Код подписан для OSX, и у меня есть вся информация о токене.См. Код ниже:
Main.js
const {app, BrowserWindow, ipcMain} = require('electron');
const {autoUpdater} = require("electron-updater");
let win; // this wills store the window object
function createDefaultWindow() {
win = new BrowserWindow({width: 900, height: 680});
win.loadURL(`file://${__dirname}/index.html`);
win.on('closed', () => app.quit());
return win;
}
// when the update is ready, notify the BrowserWindow
autoUpdater.on('update-downloaded', (info) => {
win.webContents.send('updateReady')
});
app.on('ready', function() {
createDefaultWindow();
autoUpdater.checkForUpdates();
});
ipcMain.on("quitAndInstall", (event, arg) => {
autoUpdater.quitAndInstall();
})
Index.html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
<!---<script type="text/javascript" src="login.js"></script>-->
<meta charset="UTF-8">
<title>Temp Launcher 0.0.2-alpha</title>
</head>
<body>
<script>
// You can also require other files to run in this process
require('./renderer.js')
</script>
<script>
const ipcRenderer = require('electron').ipcRenderer;
// wait for an updateReady message
ipcRenderer.on('updateReady', function(event, text) {
// changes the text of the button
var container = document.getElementById('ready');
container.innerHTML = "new version ready!";
alert('update ready!');
})
</script>
<div id="content">
<h1 style="text-align:center;">Temp Launcher</h1>
<h3 style="text-align: center;">Version: <span id="version">v0.0.2-alpha</span></h3>
<br />
<br />
<!-- the button onClick sends a quitAndInstall message to the electron main process -->
<button id="ready" onClick="ipcRenderer.send('quitAndInstall')">no updates ready</button>
<div id="messages" style="color:cyan">Messages</div>
<div class="w3-light-grey">
<div class="w3-blue" style="height:24px;width:0%" id="progressBar"></div>
</div>
<div id="bottom-updater-bar">
<div id="sidenavbar">
<a href="#item1" id="sidenavbaritems">ITEM 1</a>
</div>
UPDATER
</div>
Renderer.js
const { ipcRenderer } = require('electron');
const select = selector => document.querySelector(selector)
let container = select('#messages')
let progressBar = select('#progressBar')
let version = select('#version')
ipcRenderer.on('message', (event, text) => {
let message = document.createElement('div')
message.innerHTML = text
container.appendChild(message)
})
ipcRenderer.on('version', (event, text) => {
version.innerText = text
})
ipcRenderer.on('download-progress', (event, text) => {
progressBar.style.width = `${text}%`
})
Я не уверен, что я делаю неправильно, потому что, насколько я могу судить, это сработало для других.Любая помощь приветствуется.Спасибо.