OSDN Git Service

remove unuse data
authorZhiting Lin <zlin035@uottawa.ca>
Tue, 27 Mar 2018 09:14:04 +0000 (17:14 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Tue, 27 Mar 2018 09:14:04 +0000 (17:14 +0800)
auto-updater.js [deleted file]
main.js

diff --git a/auto-updater.js b/auto-updater.js
deleted file mode 100755 (executable)
index 69accbb..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-const {app, autoUpdater, Menu} = require('electron')
-const ChildProcess = require('child_process')
-const path = require('path')
-
-let state = 'checking'
-
-exports.initialize = () => {
-  if (process.mas) return
-
-  autoUpdater.on('checking-for-update', () => {
-    state = 'checking'
-    exports.updateMenu()
-  })
-
-  autoUpdater.on('update-available', () => {
-    state = 'checking'
-    exports.updateMenu()
-  })
-
-  autoUpdater.on('update-downloaded', () => {
-    state = 'installed'
-    exports.updateMenu()
-  })
-
-  autoUpdater.on('update-not-available', () => {
-    state = 'no-update'
-    exports.updateMenu()
-  })
-
-  autoUpdater.on('error', () => {
-    state = 'no-update'
-    exports.updateMenu()
-  })
-
-  autoUpdater.setFeedURL(`https://electron-api-demos.githubapp.com/updates?version=${app.getVersion()}`)
-  autoUpdater.checkForUpdates()
-}
-
-exports.updateMenu = () => {
-  if (process.mas) return
-
-  const menu = Menu.getApplicationMenu()
-  if (!menu) return
-
-  menu.items.forEach(item => {
-    if (item.submenu) {
-      item.submenu.items.forEach(item => {
-        switch (item.key) {
-          case 'checkForUpdate':
-            item.visible = state === 'no-update'
-            break
-          case 'checkingForUpdate':
-            item.visible = state === 'checking'
-            break
-          case 'restartToUpdate':
-            item.visible = state === 'installed'
-            break
-        }
-      })
-    }
-  })
-}
-
-exports.createShortcut = callback => {
-  spawnUpdate([
-    '--createShortcut',
-    path.basename(process.execPath),
-    '--shortcut-locations',
-    'StartMenu'
-  ], callback)
-}
-
-exports.removeShortcut = callback => {
-  spawnUpdate([
-    '--removeShortcut',
-    path.basename(process.execPath)
-  ], callback)
-}
-
-function spawnUpdate (args, callback) {
-  const updateExe = path.resolve(path.dirname(process.execPath), '..', 'Update.exe')
-  let stdout = ''
-  let spawned = null
-
-  try {
-    spawned = ChildProcess.spawn(updateExe, args)
-  } catch (error) {
-    if (error && error.stdout == null) {
-      error.stdout = stdout
-    }
-    process.nextTick(() => { callback(error) })
-    return
-  }
-
-  var error = null
-
-  spawned.stdout.on('data', data => {
-    stdout += data
-  })
-
-  spawned.on('error', processError => {
-    if (!error) error = processError
-  })
-
-  spawned.on('close', (code, signal) => {
-    if (!error && code !== 0) {
-      error = new Error(`Command failed: ${code} ${signal}`)
-    }
-    if (error && error.code == null) error.code = code
-    if (error && error.stdout == null) error.stdout = stdout
-    callback(error)
-  })
-}
diff --git a/main.js b/main.js
index 266fca7..838f07f 100644 (file)
--- a/main.js
+++ b/main.js
@@ -1,9 +1,7 @@
 const {app, BrowserWindow, ipcMain} = require('electron')
-const autoUpdater = require('./auto-updater')
 const exec = require('child_process').exec
 const glob = require('glob')
 const settings = require('electron-settings')
-
 global.language = settings.get('browserSetting.core.lang')
 
 const i18n = require('./main-process/i18n.js')
@@ -25,7 +23,7 @@ function initialize () {
   loadMenu()
 
   function createWindow() {
-    // 创建浏览器窗口。
+    // Create browser Window
     win = new BrowserWindow({
       width: 1024 + 208,
       height: 768,
@@ -72,18 +70,15 @@ function initialize () {
         ipcMain.on('bytomdInitNetwork', (event, arg) => {
           setBytomInit( event,  arg )
         })
-
       } else {
         log.error('Some other error: ', err.code)
       }
-
     })
-
     createWindow()
   })
 
 
-// 当全部窗口关闭时退出。
+//All window Closed
   app.on('window-all-closed', () => {
     if (process.platform !== 'darwin') {
       quitApp('window-all-closed')
@@ -151,17 +146,12 @@ function setBytomInit(event, bytomNetwork) {
 function loadMenu () {
   const files = glob.sync(path.join(__dirname, 'main-process/menus/*.js'))
   files.forEach((file) => { require(file) })
-  // autoUpdater.updateMenu()
 }
 
 // Handle Squirrel on Windows startup events
 switch (process.argv[1]) {
   case '--squirrel-install':
-    autoUpdater.createShortcut(() => { app.quit() })
-    break
   case '--squirrel-uninstall':
-    autoUpdater.removeShortcut(() => { app.quit() })
-    break
   case '--squirrel-obsolete':
   case '--squirrel-updated':
     app.quit()