Server.js 461 B

123456789101112131415161718192021222324
  1. /**
  2. * @author oldj
  3. * @blog https://oldj.net
  4. */
  5. 'use strict'
  6. const {ipcMain} = require('electron')
  7. const actions = require('./actions')
  8. ipcMain.on('x', (e, d) => {
  9. let sender = e.sender
  10. let action = d.action
  11. if (typeof actions[action] === 'function') {
  12. actions[action](d.args, (e, v) => {
  13. try {
  14. sender.send(d.callback, [e, v])
  15. } catch (e2) {
  16. console.log(e2)
  17. sender.send(d.callback, [e2])
  18. }
  19. })
  20. }
  21. })