Skip to content

Commit

Permalink
Adding updater
Browse files Browse the repository at this point in the history
  • Loading branch information
romslf committed Sep 9, 2021
1 parent 77a0950 commit 4c68fd3
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 11 deletions.
5 changes: 4 additions & 1 deletion components/header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@
</b-menu>
</div>
</b-sidebar>
<div class="columns is-vcentered">
<b-button @click="open = true" icon-left="bars"></b-button>
<b-button @click="open_settings = true" icon-left="cog" class="is-pulled-right"></b-button>
<img :src="require('@/assets/isolated-layout.svg')" style="width: 60px; height: 60px; margin-left: auto; margin-right: auto; display:block;"/>
<b-button @click="open_settings = true" icon-left="cog" class="is-pulled-left"></b-button>
</div>
</section>
</div>

Expand Down
51 changes: 48 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
** Nuxt
*/
const { autoUpdater } = require("electron-updater");
const http = require('http')
const { Nuxt, Builder } = require('nuxt')
let config = require('./nuxt.config.js')
Expand Down Expand Up @@ -29,15 +30,55 @@ const electron = require('electron')
const path = require('path')
const app = electron.app
const newWin = () => {
const options = {
type: "question",
buttons: ["No, thanks", "Yes, please"],
defaultId: 1,
title: "Question",
message: "Do you want to do this?"
};

autoUpdater.on("update-available", () => {
if (process.platform === "win32" || process.platform === "win64") {
options.title = "Update";
options.message = "Update available, download it ?";
dialog.showMessageBox(null, options, (response) => {
if (response === 1) {
autoUpdater.downloadUpdate();
autoUpdater.on("update-downloaded", () => {
autoUpdater.quitAndInstall();
});
}
});
} else {
options.title = "Update";
options.message = "Update available, download it ?";
dialog.showMessageBox(null, options, (response) => {
if (response === 1) {
let child = new BrowserWindow({ modal: false, show: false });
child.loadURL("https://github.com/romslf/system-companion/releases/latest");
child.once("ready-to-show", () => {
child.show();
});
}
});
}
});

autoUpdater.on("error", (err) => {
console.log(err);
});

win = new electron.BrowserWindow({
icon: path.join(__dirname, 'static/icons/win-icon.ico'),
webPreferences: {
nodeIntegration: true,
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true,
}
},
autoHideMenuBar: true
})
win.maximize()
//win.maximize()
win.on('closed', () => win = null)
if (config.dev) {
// Install vue dev tool and open chrome dev tools
Expand All @@ -54,6 +95,10 @@ const newWin = () => {
}
pollServer()
} else { return win.loadURL(_NUXT_URL_) }
//this._create();
autoUpdater.autoDownload = false;
console.log("Checking updates ...")
autoUpdater.checkForUpdates();
}
app.on('ready', newWin)
app.on('window-all-closed', () => app.quit())
Expand Down
115 changes: 113 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
"version": "1.0.0",
"description": "Nuxt + Electron",
"author": "romslf@pm.me",
"private": true,
"private": false,
"repository": {
"type" : "git",
"url" : "https://github.com/romslf/system-companion.git"
},
"main": "main.js",
"build": {
"appId": "",
Expand All @@ -17,14 +21,16 @@
},
"scripts": {
"dev": "cross-env NODE_ENV=DEV electron .",
"build": "nuxt build && electron-builder --config builder.config.js",
"build": "nuxt build && electron-builder --config builder.config.js --publish never",
"deploy": "nuxt build && electron-builder --config builder.config.js --publish always",
"lint": "node_modules/.bin/eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter ./src",
"lint:fix": "npm run lint -- --fix"
},
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.4",
"buefy": "^0.9.10",
"electron-data-storage": "^1.1.2",
"electron-updater": "^4.3.9",
"node-sass": "^6.0.1",
"nuxt": "^1.4.0",
"sass": "^1.39.0",
Expand Down
3 changes: 0 additions & 3 deletions pages/docker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@
Starting command: {{ props.row.command }}
</ul>
</div>
<footer class="card-footer">
<b-button class="is-danger center" outlined rounded icon-right="trash">Kill</b-button>
</footer>
</div>
</article>
</template>
Expand Down

0 comments on commit 4c68fd3

Please sign in to comment.