gaoshuaixing 4 anni fa
parent
commit
61c95b1ce5
5 ha cambiato i file con 49 aggiunte e 48 eliminazioni
  1. 1 0
      .gitignore
  2. 43 43
      electron/autoUpdater.js
  3. 2 2
      electron/setup.js
  4. 3 2
      main.js
  5. 0 1
      package.json

+ 1 - 0
.gitignore

@@ -3,3 +3,4 @@ out/
 logs/
 run/
 .idea/
+package-lock.json

+ 43 - 43
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;
+// exports = module.exports;

+ 2 - 2
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();
 }
 

+ 3 - 2
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

+ 0 - 1
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",