|
@ -7,6 +7,12 @@ import { resolve } from 'path' |
|
|
|
|
|
|
|
|
import setupAutoUpdater, { quitAndInstall } from './autoUpdate' |
|
|
import setupAutoUpdater, { quitAndInstall } from './autoUpdate' |
|
|
|
|
|
|
|
|
|
|
|
const processes = [] |
|
|
|
|
|
|
|
|
|
|
|
function cleanProcesses() { |
|
|
|
|
|
processes.forEach(kill => kill()) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function onForkChannel(forkType, callType) { |
|
|
function onForkChannel(forkType, callType) { |
|
|
return (event: any, payload) => { |
|
|
return (event: any, payload) => { |
|
|
const { type, data } = payload |
|
|
const { type, data } = payload |
|
@ -24,6 +30,8 @@ function onForkChannel(forkType, callType) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
processes.push(kill) |
|
|
|
|
|
|
|
|
const onMessage = payload => { |
|
|
const onMessage = payload => { |
|
|
const { type, data, options = {} } = payload |
|
|
const { type, data, options = {} } = payload |
|
|
if (callType === 'async') { |
|
|
if (callType === 'async') { |
|
@ -48,6 +56,8 @@ function onForkChannel(forkType, callType) { |
|
|
ipcMain.on('usb', onForkChannel('usb', 'async')) |
|
|
ipcMain.on('usb', onForkChannel('usb', 'async')) |
|
|
ipcMain.on('accounts', onForkChannel('accounts', 'async')) |
|
|
ipcMain.on('accounts', onForkChannel('accounts', 'async')) |
|
|
|
|
|
|
|
|
|
|
|
ipcMain.on('clean-processes', cleanProcesses) |
|
|
|
|
|
|
|
|
const handlers = { |
|
|
const handlers = { |
|
|
updater: { |
|
|
updater: { |
|
|
init: setupAutoUpdater, |
|
|
init: setupAutoUpdater, |
|
|