单例
This commit is contained in:
parent
f2aa5bdcf2
commit
c8c60e693f
28
main.js
28
main.js
@ -480,10 +480,21 @@ function createMenu() {
|
||||
}
|
||||
}
|
||||
|
||||
const createMainWindow = () => {
|
||||
function createMainWindow = () => {
|
||||
|
||||
// 实现单例,在启动第二个实例后,激活主窗口,然后退出第二个实例
|
||||
const shouldQuit = app.makeSingleInstance(() => {
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isMinimized()) mainWindow.restore()
|
||||
mainWindow.focus()
|
||||
}
|
||||
})
|
||||
|
||||
shouldQuit && app.quit()
|
||||
|
||||
var mainWindowState = windowStateKeeper({
|
||||
defaultWidth: 745,
|
||||
defaultHeight: 450,
|
||||
defaultWidth: 1300,
|
||||
defaultHeight: 700,
|
||||
});
|
||||
|
||||
mainWindow = new BrowserWindow({
|
||||
@ -705,17 +716,6 @@ const createMainWindow = () => {
|
||||
mainWindow.webContents.setUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8');
|
||||
createMenu();
|
||||
};
|
||||
|
||||
// 实现单例,在启动第二个实例后,激活主窗口,然后退出第二个实例
|
||||
const shouldQuit = app.makeSingleInstance(() => {
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isMinimized()) mainWindow.restore()
|
||||
mainWindow.focus()
|
||||
}
|
||||
})
|
||||
|
||||
shouldQuit && app.quit()
|
||||
|
||||
app.setName(pkg.name);
|
||||
app.dock && app.dock.setIcon(icon);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user