prevent more than one instance
This commit is contained in:
parent
7c2bb76421
commit
6fbd96dab1
|
@ -1,11 +1,13 @@
|
|||
import { spawn, exec } from 'child_process'
|
||||
import { app, autoUpdater, dialog, Tray, Menu, nativeTheme } from 'electron'
|
||||
import { app, autoUpdater, dialog, Tray, Menu, nativeTheme, Notification } from 'electron'
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
|
||||
require('@electron/remote/main').initialize()
|
||||
|
||||
let tray: Tray | null = null
|
||||
let secondInstance: Boolean = false
|
||||
const SingleInstanceLock = app.requestSingleInstanceLock()
|
||||
|
||||
const createSystemtray = () => {
|
||||
let brightModeIconPath = path.join(__dirname, '..', '..', 'assets', 'ollama_icon_dark_16x16.png')
|
||||
|
@ -108,11 +110,10 @@ function installCLI() {
|
|||
})
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
if (!SingleInstanceLock) {
|
||||
app.quit()
|
||||
} else {
|
||||
app.on('ready', () => {
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
app.dock.hide()
|
||||
|
||||
|
@ -154,6 +155,8 @@ app.on('ready', () => {
|
|||
installCLI()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// Quit when all windows are closed, except on macOS. There, it's common
|
||||
// for applications and their menu bar to stay active until the user quits
|
||||
|
|
Loading…
Reference in a new issue