fix: second-instance additionalData parameter (#31661)
* test: second-instance additionalData parameter * Fix posix implementation
This commit is contained in:
parent
86f6285299
commit
9e0e04da25
4 changed files with 110 additions and 29 deletions
15
spec/fixtures/api/singleton-data/main.js
vendored
15
spec/fixtures/api/singleton-data/main.js
vendored
|
@ -1,10 +1,13 @@
|
|||
const { app } = require('electron');
|
||||
|
||||
// Send data from the second instance to the first instance.
|
||||
const sendAdditionalData = app.commandLine.hasSwitch('send-data');
|
||||
|
||||
app.whenReady().then(() => {
|
||||
console.log('started'); // ping parent
|
||||
});
|
||||
|
||||
const obj = {
|
||||
let obj = {
|
||||
level: 1,
|
||||
testkey: 'testvalue1',
|
||||
inner: {
|
||||
|
@ -12,7 +15,15 @@ const obj = {
|
|||
testkey: 'testvalue2'
|
||||
}
|
||||
};
|
||||
const gotTheLock = app.requestSingleInstanceLock(obj);
|
||||
if (app.commandLine.hasSwitch('data-content')) {
|
||||
obj = JSON.parse(app.commandLine.getSwitchValue('data-content'));
|
||||
if (obj === 'undefined') {
|
||||
obj = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
const gotTheLock = sendAdditionalData
|
||||
? app.requestSingleInstanceLock(obj) : app.requestSingleInstanceLock();
|
||||
|
||||
app.on('second-instance', (event, args, workingDirectory, data) => {
|
||||
setImmediate(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue