Skip to content

Commit

Permalink
feat(desktop): auto updater
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Oct 22, 2021
1 parent b2c7a22 commit 23e7872
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 7 deletions.
14 changes: 9 additions & 5 deletions desktop/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { app, BrowserWindow, protocol, globalShortcut } = require('electron')
const { autoUpdater } = require('electron-updater')
const { join } = require('path')

const isDev = process.env.NODE_ENV === 'development'
Expand Down Expand Up @@ -30,22 +31,25 @@ function createWindow () {
icon: join(__dirname, '../render/logo-desktop.png')
})

// and load the index.html of the app.
mainWindow.loadURL(WinURL)
mainWindow.on('close', function (event: any) {
if (!willQuitApp) {
// event.preventDefault()
// mainWindow?.hide()
if (!willQuitApp && !isDev) {
event.preventDefault()
mainWindow?.hide()
}
})
// Emitted when the window is closed.

mainWindow.on('closed', function () {
mainWindow = null
})
mainWindow.once('ready-to-show', () => {
autoUpdater.checkForUpdatesAndNotify()
mainWindow?.show()
})

mainWindow.on('update-downloaded', () => {
autoUpdater.quitAndInstall()
})
/*
mainWindow.webContents.on('will-navigate', function (event: any, newUrl: string) {
console.log(newUrl);
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
"desktop:set": "wait-on tcp:3000 && electron . --watch",
"desktop:dev": "concurrently -k \"cross-env BROWSER=none yarn dev\" \"yarn desktop:set\"",
"desktop:start": "cross-env NODE_ENV=development electron dist/main/index.js",
"desktop:build": "desktop:release && electron-builder",
"desktop:view": "yarn desktop:build && yarn desktop:dev",
"desktop:build": "yarn desktop:release && electron-builder",
"desktop:minimal": "yarn desktop:release && electron-builder --windows",
"desktop:view": "yarn desktop:minimal && yarn desktop:dev",
"desktop:release": "cross-env NODE_ENV=production tsc desktop/index.ts --moduleResolution Node --removeComments -t esnext --outDir dist/main && yarn build",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore --fix src && yarn format",
"format": "prettier src/**/*.{vue,css,ts} --write",
Expand All @@ -42,6 +43,8 @@
"autoprefixer": "10.3.4",
"date-fns": "2.25.0",
"dropbox": "10.13.0",
"electron-log": "^4.4.1",
"electron-updater": "^4.3.9",
"is-electron": "^2.2.0",
"keyboardjs": "2.6.4",
"mitt": "^3.0.0",
Expand Down
42 changes: 42 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,11 @@
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.4.0.tgz#900b13362610ccd3570fb6eefb911a6732973d00"
integrity sha512-WHRsy5nMpjXfU9B0LqOqPT06EI2+8Xv5NERy0pLxJLbU98q7uhcGogQzfX+rXpU7S5mgHsLxHrLCufZcV/P8TQ==

"@types/semver@^7.3.5":
version "7.3.9"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.9.tgz#152c6c20a7688c30b967ec1841d31ace569863fc"
integrity sha512-L/TMpyURfBkf+o/526Zb6kd/tchUP3iBDEPjqjb+U2MAJhVRxxrmr2fwpe08E7QsV7YLcpq0tUaQ9O9x97ZIxQ==

"@types/stack-utils@^2.0.0":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.1.tgz#20f18294f797f2209b5f65c8e3b5c8e8261d127c"
Expand Down Expand Up @@ -1963,6 +1968,14 @@ buffer@^5.1.0, buffer@^5.4.3:
base64-js "^1.3.1"
ieee754 "^1.1.13"

builder-util-runtime@8.7.5:
version "8.7.5"
resolved "https://registry.yarnpkg.com/builder-util-runtime/-/builder-util-runtime-8.7.5.tgz#fbe59e274818885e0d2e358d5b7017c34ae6b0f5"
integrity sha512-fgUFHKtMNjdvH6PDRFntdIGUPgwZ69sXsAqEulCtoiqgWes5agrMq/Ud274zjJRTbckYh2PHh8/1CpFc6dpsbQ==
dependencies:
debug "^4.3.2"
sax "^1.2.4"

builder-util-runtime@8.8.1:
version "8.8.1"
resolved "https://registry.yarnpkg.com/builder-util-runtime/-/builder-util-runtime-8.8.1.tgz#d6e2b5f27723a7606f381e52a3000dadb1d6e4a9"
Expand Down Expand Up @@ -2992,6 +3005,11 @@ electron-dev-runner@^1.0.1:
shelljs "^0.8.4"
typescript "^4.2.3"

electron-log@^4.4.1:
version "4.4.1"
resolved "https://registry.yarnpkg.com/electron-log/-/electron-log-4.4.1.tgz#28ebeb474eccba2ebf194a96c40d6328e5353e4d"
integrity sha512-nK/DwxPLtwWbggPCm27eMQhYHc3gzoZ+cokBK99diO4WsZJKrv5l44EUW8mRfWpmC8ZubnMyp6GTUIJyTc9AJA==

electron-osx-sign@^0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/electron-osx-sign/-/electron-osx-sign-0.5.0.tgz#fc258c5e896859904bbe3d01da06902c04b51c3a"
Expand Down Expand Up @@ -3027,6 +3045,20 @@ electron-to-chromium@^1.3.846:
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.850.tgz#c56c72abfeab051b4b328beb894461c5912d0456"
integrity sha512-ZzkDcdzePeF4dhoGZQT77V2CyJOpwfTZEOg4h0x6R/jQhGt/rIRpbRyVreWLtD7B/WsVxo91URm2WxMKR9JQZA==

electron-updater@^4.3.9:
version "4.3.9"
resolved "https://registry.yarnpkg.com/electron-updater/-/electron-updater-4.3.9.tgz#247c660bafad7c07935e1b81acd3e9a5fd733154"
integrity sha512-LCNfedSwZfS4Hza+pDyPR05LqHtGorCStaBgVpRnfKxOlZcvpYEX0AbMeH5XUtbtGRoH2V8osbbf2qKPNb7AsA==
dependencies:
"@types/semver" "^7.3.5"
builder-util-runtime "8.7.5"
fs-extra "^10.0.0"
js-yaml "^4.1.0"
lazy-val "^1.0.4"
lodash.escaperegexp "^4.1.2"
lodash.isequal "^4.5.0"
semver "^7.3.5"

electron@15.2.0:
version "15.2.0"
resolved "https://registry.yarnpkg.com/electron/-/electron-15.2.0.tgz#3068099d1e5c625d1708487de519c59d7c0a8e6e"
Expand Down Expand Up @@ -5264,6 +5296,16 @@ lodash.clonedeep@^4.5.0:
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=

lodash.escaperegexp@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz#64762c48618082518ac3df4ccf5d5886dae20347"
integrity sha1-ZHYsSGGAglGKw99Mz11YhtriA0c=

lodash.isequal@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
integrity sha1-QVxEePK8wwEgwizhDtMib30+GOA=

lodash.ismatch@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz#756cb5150ca3ba6f11085a78849645f188f85f37"
Expand Down

0 comments on commit 23e7872

Please sign in to comment.