diff options
Diffstat (limited to 'desktop/main.js')
-rw-r--r-- | desktop/main.js | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/desktop/main.js b/desktop/main.js index 1d0b322..02f153d 100644 --- a/desktop/main.js +++ b/desktop/main.js @@ -229,7 +229,6 @@ function getCopyrightYear() { } } -app.setName("Mist"); app.setAsDefaultProtocolClient("mist"); app.setAboutPanelOptions({ applicationName: "Mist", @@ -239,10 +238,12 @@ app.setAboutPanelOptions({ website: "https://mist.equestria.horse/app/" }); -const gotTheLock = app.requestSingleInstanceLock(); +if (app.getName() !== "Electron") { + const gotTheLock = app.requestSingleInstanceLock(); -if (!gotTheLock) { - app.quit(); + if (!gotTheLock) { + app.quit(); + } } let loggedIn = false; @@ -337,6 +338,40 @@ const createWindow = () => { }); } +const studioMode = () => { + if (global.studioWindow) return; + + global.studioWindow = new BrowserWindow({ + width: require('electron').screen.getPrimaryDisplay().workAreaSize.width, + minWidth: 1280, + height: require('electron').screen.getPrimaryDisplay().workAreaSize.height, + minHeight: 720, + autoHideMenuBar: true, + title: "Mist Studio", + backgroundColor: "#111111", + webPreferences: { + nodeIntegration: true, + contextIsolation: false, + scrollBounce: true, + enableWebSQL: false + } + }); + + updateMenu(studioWindow); + + studioWindow.webContents.setUserAgent(studioWindow.webContents.getUserAgent() + " MistNative/" + process.platform); + studioWindow.loadURL("https://mist.equestria.horse/app/studio.php"); + + studioWindow.webContents.setWindowOpenHandler((details) => { + shell.openExternal(details.url); + return { action: "deny" }; + }); + + studioWindow.on('close', () => { + global.studioWindow = null; + }); +} + ipcMain.handle('auth', () => { shell.openExternal("https://mist.equestria.horse/oauth/native/"); }); @@ -345,6 +380,11 @@ ipcMain.handle('about', () => { app.showAboutPanel(); }); +ipcMain.handle('studio', () => { + studioMode(); + mainWindow.close(); +}); + ipcMain.handle('userInfo', (e, userInfo) => { global.userInfo = JSON.parse(userInfo); updateMenu(mainWindow); |