From 61c95b1ce5b44a27e8aec985fedd2f41ed62290b Mon Sep 17 00:00:00 2001 From: gaoshuaixing Date: Wed, 3 Feb 2021 10:37:35 +0800 Subject: [PATCH] 1 --- .gitignore | 1 + electron/autoUpdater.js | 86 ++++++++++++++++++++--------------------- electron/setup.js | 4 +- main.js | 5 ++- package.json | 1 - 5 files changed, 49 insertions(+), 48 deletions(-) diff --git a/.gitignore b/.gitignore index 15bd035..9912b76 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ out/ logs/ run/ .idea/ +package-lock.json diff --git a/electron/autoUpdater.js b/electron/autoUpdater.js index 96e6f2a..fba0c00 100644 --- a/electron/autoUpdater.js +++ b/electron/autoUpdater.js @@ -1,50 +1,50 @@ -'use strict'; +// 'use strict'; -const updater = require("electron-updater"); -const autoUpdater = updater.autoUpdater; -const config = require('./config'); -const path = require('path'); -const {app} = require('electron'); +// const updater = require("electron-updater"); +// const autoUpdater = updater.autoUpdater; +// const config = require('./config'); +// const path = require('path'); +// const {app} = require('electron'); -exports.setup = function () { - const pkgInfo = require(path.join(app.getAppPath(), 'package.json')); - ELog.info('[autoUpdater] [setup] current version: ', pkgInfo.version); - const updateConfig = config.get('autoUpdate'); - autoUpdater.setFeedURL(updateConfig.options); +// exports.setup = function () { +// const pkgInfo = require(path.join(app.getAppPath(), 'package.json')); +// ELog.info('[autoUpdater] [setup] current version: ', pkgInfo.version); +// const updateConfig = config.get('autoUpdate'); +// autoUpdater.setFeedURL(updateConfig.options); - autoUpdater.on('checking-for-update', () => { - sendStatusToWindow('Checking for update...'); - }) - autoUpdater.on('update-available', (info) => { - sendStatusToWindow('Update available.'); - }) - autoUpdater.on('update-not-available', (info) => { - sendStatusToWindow('Update not available.'); - }) - autoUpdater.on('error', (err) => { - sendStatusToWindow('Error in auto-updater. ' + err); - }) - autoUpdater.on('download-progress', (progressObj) => { - let log_message = "Download speed: " + progressObj.bytesPerSecond; - log_message = log_message + ' - Downloaded ' + progressObj.percent + '%'; - log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')'; - sendStatusToWindow(log_message); - }) - autoUpdater.on('update-downloaded', (info) => { - sendStatusToWindow('Update downloaded'); - // quit and update - autoUpdater.quitAndInstall(); - }); +// autoUpdater.on('checking-for-update', () => { +// sendStatusToWindow('Checking for update...'); +// }) +// autoUpdater.on('update-available', (info) => { +// sendStatusToWindow('Update available.'); +// }) +// autoUpdater.on('update-not-available', (info) => { +// sendStatusToWindow('Update not available.'); +// }) +// autoUpdater.on('error', (err) => { +// sendStatusToWindow('Error in auto-updater. ' + err); +// }) +// autoUpdater.on('download-progress', (progressObj) => { +// let log_message = "Download speed: " + progressObj.bytesPerSecond; +// log_message = log_message + ' - Downloaded ' + progressObj.percent + '%'; +// log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')'; +// sendStatusToWindow(log_message); +// }) +// autoUpdater.on('update-downloaded', (info) => { +// sendStatusToWindow('Update downloaded'); +// // quit and update +// autoUpdater.quitAndInstall(); +// }); -}; +// }; -exports.checkUpdate = function () { - autoUpdater.checkForUpdatesAndNotify(); -} +// exports.checkUpdate = function () { +// autoUpdater.checkForUpdatesAndNotify(); +// } -function sendStatusToWindow(text) { - ELog.info(text); - MAIN_WINDOW.webContents.send('message', text); -} +// function sendStatusToWindow(text) { +// ELog.info(text); +// MAIN_WINDOW.webContents.send('message', text); +// } -exports = module.exports; \ No newline at end of file +// exports = module.exports; \ No newline at end of file diff --git a/electron/setup.js b/electron/setup.js index 7bcf6cc..7a28170 100644 --- a/electron/setup.js +++ b/electron/setup.js @@ -3,13 +3,13 @@ global.ELog = require('electron-log'); const storage = require('./storage'); const config = require('./config'); -const autoUpdater = require('./autoUpdater'); +// const autoUpdater = require('./autoUpdater'); const api = require('./api'); module.exports = () => { storage.setup(); logger(); - autoUpdater.setup(); + // autoUpdater.setup(); api.setup(); } diff --git a/main.js b/main.js index f091f9a..708c347 100644 --- a/main.js +++ b/main.js @@ -4,7 +4,7 @@ const eggLauncher = require('./electron/lanucher') const setup = require('./electron/setup') const electronConfig = require('./electron/config') const storage = require('./electron/storage') -const autoUpdater = require('./electron/autoUpdater') +// const autoUpdater = require('./electron/autoUpdater') // main window global.MAIN_WINDOW = null @@ -77,7 +77,8 @@ async function createWindow () { // check update const updateConfig = electronConfig.get('autoUpdate') if (updateConfig.enable) { - autoUpdater.checkUpdate() + // windows可以开启;macOs 需要签名验证 + //autoUpdater.checkUpdate() } return MAIN_WINDOW diff --git a/package.json b/package.json index 643b4a8..364446d 100755 --- a/package.json +++ b/package.json @@ -109,7 +109,6 @@ "egg-view-ejs": "^2.0.0", "electron-is": "^3.0.0", "electron-log": "^4.2.2", - "electron-updater": "^4.3.5", "get-port": "^5.1.1", "glob": "^7.1.6", "lodash": "^4.17.11",