Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ShirasawaSama committed Apr 28, 2020
1 parent 80b4cb1 commit 3a176dd
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { app, BrowserWindow, ipcMain, systemPreferences } from 'electron'
import minimist from 'minimist'
import isDev from './utils/isDev'
import createServer from './createServer'
import { Server } from 'http'

let server: Server = null
let window: BrowserWindow = null
let launchingWindow: BrowserWindow = null
const webp = join(app.getPath('userData'), 'launching.webp')
Expand All @@ -22,15 +24,14 @@ const parseArgs = (args: string[]) => {

if (app.requestSingleInstanceLock()) {
app.on('second-instance', (_, argv) => {
console.log(argv)
if (window) {
if (window.isMinimized()) {
window.restore()
window.setBounds({ height: 586, width: 816 })
}
window.focus()
}
parseArgs(argv)
parseArgs(argv)
} else app.exit()
})
} else app.exit()

Expand Down Expand Up @@ -109,15 +110,18 @@ const create = () => {
if (isDev) window.webContents.openDevTools()
parseArgs(process.argv)

createServer(window)
server = createServer(window)
}

if (process.platform === 'linux') app.commandLine.appendSwitch('enable-transparent-visuals')

app
.on('ready', process.platform === 'linux' ? () => setTimeout(create, 400) : create)
.on('before-quit', () => runBeforeQuit && runBeforeQuit.length && spawn.apply(null, runBeforeQuit)
.once('error', console.error).unref())
.on('before-quit', () => {
server.close()
runBeforeQuit && runBeforeQuit.length && spawn.apply(null, runBeforeQuit)
.once('error', console.error).unref()
})
// .on('quit', () => setTimeout(() => app.exit(), 1500))
.on('window-all-closed', () => process.platform !== 'darwin' && app.quit())
.on('activate', () => window == null && create())

0 comments on commit 3a176dd

Please sign in to comment.