Skip to content

Commit 4c68fd3

Browse files
committed
Adding updater
1 parent 77a0950 commit 4c68fd3

File tree

5 files changed

+173
-11
lines changed

5 files changed

+173
-11
lines changed

components/header.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@
5151
</b-menu>
5252
</div>
5353
</b-sidebar>
54+
<div class="columns is-vcentered">
5455
<b-button @click="open = true" icon-left="bars"></b-button>
55-
<b-button @click="open_settings = true" icon-left="cog" class="is-pulled-right"></b-button>
56+
<img :src="require('@/assets/isolated-layout.svg')" style="width: 60px; height: 60px; margin-left: auto; margin-right: auto; display:block;"/>
57+
<b-button @click="open_settings = true" icon-left="cog" class="is-pulled-left"></b-button>
58+
</div>
5659
</section>
5760
</div>
5861

main.js

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
** Nuxt
33
*/
4+
const { autoUpdater } = require("electron-updater");
45
const http = require('http')
56
const { Nuxt, Builder } = require('nuxt')
67
let config = require('./nuxt.config.js')
@@ -29,15 +30,55 @@ const electron = require('electron')
2930
const path = require('path')
3031
const app = electron.app
3132
const newWin = () => {
33+
const options = {
34+
type: "question",
35+
buttons: ["No, thanks", "Yes, please"],
36+
defaultId: 1,
37+
title: "Question",
38+
message: "Do you want to do this?"
39+
};
40+
41+
autoUpdater.on("update-available", () => {
42+
if (process.platform === "win32" || process.platform === "win64") {
43+
options.title = "Update";
44+
options.message = "Update available, download it ?";
45+
dialog.showMessageBox(null, options, (response) => {
46+
if (response === 1) {
47+
autoUpdater.downloadUpdate();
48+
autoUpdater.on("update-downloaded", () => {
49+
autoUpdater.quitAndInstall();
50+
});
51+
}
52+
});
53+
} else {
54+
options.title = "Update";
55+
options.message = "Update available, download it ?";
56+
dialog.showMessageBox(null, options, (response) => {
57+
if (response === 1) {
58+
let child = new BrowserWindow({ modal: false, show: false });
59+
child.loadURL("https://github.com/romslf/system-companion/releases/latest");
60+
child.once("ready-to-show", () => {
61+
child.show();
62+
});
63+
}
64+
});
65+
}
66+
});
67+
68+
autoUpdater.on("error", (err) => {
69+
console.log(err);
70+
});
71+
3272
win = new electron.BrowserWindow({
3373
icon: path.join(__dirname, 'static/icons/win-icon.ico'),
3474
webPreferences: {
35-
nodeIntegration: true,
75+
nodeIntegration: true,
3676
contextIsolation: false,
3777
enableRemoteModule: true,
38-
}
78+
},
79+
autoHideMenuBar: true
3980
})
40-
win.maximize()
81+
//win.maximize()
4182
win.on('closed', () => win = null)
4283
if (config.dev) {
4384
// Install vue dev tool and open chrome dev tools
@@ -54,6 +95,10 @@ const newWin = () => {
5495
}
5596
pollServer()
5697
} else { return win.loadURL(_NUXT_URL_) }
98+
//this._create();
99+
autoUpdater.autoDownload = false;
100+
console.log("Checking updates ...")
101+
autoUpdater.checkForUpdates();
57102
}
58103
app.on('ready', newWin)
59104
app.on('window-all-closed', () => app.quit())

package-lock.json

Lines changed: 113 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
"version": "1.0.0",
44
"description": "Nuxt + Electron",
55
"author": "romslf@pm.me",
6-
"private": true,
6+
"private": false,
7+
"repository": {
8+
"type" : "git",
9+
"url" : "https://github.com/romslf/system-companion.git"
10+
},
711
"main": "main.js",
812
"build": {
913
"appId": "",
@@ -17,14 +21,16 @@
1721
},
1822
"scripts": {
1923
"dev": "cross-env NODE_ENV=DEV electron .",
20-
"build": "nuxt build && electron-builder --config builder.config.js",
24+
"build": "nuxt build && electron-builder --config builder.config.js --publish never",
25+
"deploy": "nuxt build && electron-builder --config builder.config.js --publish always",
2126
"lint": "node_modules/.bin/eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter ./src",
2227
"lint:fix": "npm run lint -- --fix"
2328
},
2429
"dependencies": {
2530
"@fortawesome/fontawesome-free": "^5.15.4",
2631
"buefy": "^0.9.10",
2732
"electron-data-storage": "^1.1.2",
33+
"electron-updater": "^4.3.9",
2834
"node-sass": "^6.0.1",
2935
"nuxt": "^1.4.0",
3036
"sass": "^1.39.0",

pages/docker.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@
118118
Starting command: {{ props.row.command }}
119119
</ul>
120120
</div>
121-
<footer class="card-footer">
122-
<b-button class="is-danger center" outlined rounded icon-right="trash">Kill</b-button>
123-
</footer>
124121
</div>
125122
</article>
126123
</template>

0 commit comments

Comments
 (0)