Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
6fbd96da
Commit
6fbd96da
authored
Jul 06, 2023
by
Eva Ho
Browse files
prevent more than one instance
parent
7c2bb764
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
42 deletions
+45
-42
app/src/index.ts
app/src/index.ts
+45
-42
No files found.
app/src/index.ts
View file @
6fbd96da
import
{
spawn
,
exec
}
from
'
child_process
'
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
path
from
'
path
'
import
*
as
fs
from
'
fs
'
import
*
as
fs
from
'
fs
'
require
(
'
@electron/remote/main
'
).
initialize
()
require
(
'
@electron/remote/main
'
).
initialize
()
let
tray
:
Tray
|
null
=
null
let
tray
:
Tray
|
null
=
null
let
secondInstance
:
Boolean
=
false
const
SingleInstanceLock
=
app
.
requestSingleInstanceLock
()
const
createSystemtray
=
()
=>
{
const
createSystemtray
=
()
=>
{
let
brightModeIconPath
=
path
.
join
(
__dirname
,
'
..
'
,
'
..
'
,
'
assets
'
,
'
ollama_icon_dark_16x16.png
'
)
let
brightModeIconPath
=
path
.
join
(
__dirname
,
'
..
'
,
'
..
'
,
'
assets
'
,
'
ollama_icon_dark_16x16.png
'
)
...
@@ -108,11 +110,10 @@ function installCLI() {
...
@@ -108,11 +110,10 @@ function installCLI() {
})
})
}
}
// This method will be called when Electron has finished
if
(
!
SingleInstanceLock
)
{
// initialization and is ready to create browser windows.
app
.
quit
()
// Some APIs can only be used after this event occurs.
}
else
{
app
.
on
(
'
ready
'
,
()
=>
{
app
.
on
(
'
ready
'
,
()
=>
{
if
(
process
.
platform
===
'
darwin
'
)
{
if
(
process
.
platform
===
'
darwin
'
)
{
app
.
dock
.
hide
()
app
.
dock
.
hide
()
...
@@ -153,7 +154,9 @@ app.on('ready', () => {
...
@@ -153,7 +154,9 @@ app.on('ready', () => {
if
(
app
.
isPackaged
)
{
if
(
app
.
isPackaged
)
{
installCLI
()
installCLI
()
}
}
})
})
}
// Quit when all windows are closed, except on macOS. There, it's common
// 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
// for applications and their menu bar to stay active until the user quits
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment