Skip to content

Commit

Permalink
fixed object merge bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
HeiSir committed Jan 29, 2021
1 parent 4e9800f commit 5c5a5b2
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ let localConfig;
});
})();

function MergeObject(a, b) {
let c = JSON.parse(JSON.stringify(a))
for (const key in b) {
if (Object.hasOwnProperty.call(b, key)) {
c[key] = (typeof b[key] == 'object' && c[key] && typeof c[key] == 'object') ? MergeObject(c[key],b[key]) : b[key]
}
}
return c;
}

function getStartParam()
{
let param = {
Expand Down Expand Up @@ -131,18 +141,10 @@ function CreateDefaultWin(options)
alwaysOnTop: false,
hasShadow: false,
};
if(options)
{
for (const key in options) {
if (Object.hasOwnProperty.call(options, key)) {
opt[key] = options[key];
}
}
}
options && (opt = MergeObject(opt,options));
let win = new BrowserWindow(opt);
win.setMenu(null);
isDev && win.webContents.openDevTools();
//win.openDevTools();
win.webContents.on('ipc-message',ipcMessageFun);
win.webContents.on('ipc-message-sync',ipcMessageFun);
win.on('enter-full-screen',fullScreenChanged);
Expand Down

0 comments on commit 5c5a5b2

Please sign in to comment.