main.js 508 B

1234567891011121314151617181920212223242526
  1. const { app } = require('electron');
  2. app.whenReady().then(() => {
  3. console.log('started'); // ping parent
  4. });
  5. const obj = {
  6. level: 1,
  7. testkey: 'testvalue1',
  8. inner: {
  9. level: 2,
  10. testkey: 'testvalue2'
  11. }
  12. };
  13. const gotTheLock = app.requestSingleInstanceLock(obj);
  14. app.on('second-instance', (event, args, workingDirectory, data) => {
  15. setImmediate(() => {
  16. console.log([JSON.stringify(args), JSON.stringify(data)].join('||'));
  17. app.exit(0);
  18. });
  19. });
  20. if (!gotTheLock) {
  21. app.exit(1);
  22. }