Skip to content

Commit

Permalink
fix auto update
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed May 1, 2023
1 parent 00c4ce8 commit 0eb592c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 41 deletions.
74 changes: 34 additions & 40 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const { app, BrowserWindow, ipcMain } = require('electron');
const electron = require('electron')
const { app, BrowserWindow, ipcMain, ipcRenderer } = require("electron");
const fs = require('fs');
const path = require('path');
const { autoUpdater } = require("electron-updater");
const { autoUpdater, AppUpdater } = require("electron-updater");

autoUpdater.autoDownload = true;
autoUpdater.autoInstallOnAppQuit = true;
Expand All @@ -16,68 +18,60 @@ function createWindow() {
webPreferences: {
nodeIntegration: true
}
});
})

win.loadFile('./html/index.html')

const splash = new BrowserWindow({
var splash = new BrowserWindow({
width: 528,
height: 322,
transparent: true,
frame: false,
alwaysOnTop: true,
show: true
webPreferences: {
nodeIntegration: true
}
});

splash.loadFile('./html/splash.html');
splash.center();

win.loadFile('./html/index.html');
setTimeout(function () {
splash.close();
win.show();
}, 10000);

win.once('ready-to-show', () => {
if (!autoUpdater.downloadProgress) {
splash.hide();
win.show();
}
autoUpdater.on("download-progress", (progressObj) => {
splash.webContents.send('download-progress', progressObj);
});
}

app.whenReady().then(() => {
createWindow()

autoUpdater.checkForUpdates();
console.log(`Checking for updates. Current version ${app.getVersion()}`);
})

autoUpdater.on("update-available", (info) => {
console.log(`Update available. Current version ${app.getVersion()}`);
splash.webContents.send('update-message', 'An update is available. Downloading now...');
});

autoUpdater.on("update-not-available", (info) => {
console.log(`No update available. Current version ${app.getVersion()}`);
});

autoUpdater.on("download-progress", (progressObj) => {
splash.webContents.send('update-message', `Downloading update... ${progressObj.percent}%`);
});

autoUpdater.on("update-downloaded", (info) => {
console.log(`Update downloaded. Current version ${app.getVersion()}`);
splash.webContents.send('update-message', 'Update downloaded. Installing now...');
autoUpdater.quitAndInstall();
});
autoUpdater.on("update-available", (info) => {
console.log(`Update available. Current version ${app.getVersion()}`);
});

}
autoUpdater.on("update-not-available", (info) => {
console.log(`No update available. Current version ${app.getVersion()}`);
});

app.whenReady().then(() => {
createWindow();
autoUpdater.on("update-downloaded", (info) => {
console.log(`Update downloaded. Current version ${app.getVersion()}`);
});

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
});
})

app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
createWindow()
}
});

ipcMain.on('get-app-version', (event) => {
event.returnValue = app.getVersion();
});
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "horanghill",
"version": "0.4.5",
"version": "0.4.6",
"description": "#Best #Editor #Ever",
"homepage": "http://horanghill.great-site.net/",
"main": "js/main.js",
Expand Down

0 comments on commit 0eb592c

Please sign in to comment.