Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
11f50478
authored
Sep 29, 2025
by
bubblepipe42
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tray
parent
834ab29a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
37 deletions
+37
-37
electron/main.js
+37
-37
electron/tray-iconTemplate.png
+0
-0
electron/tray-iconTemplate@2x.png
+0
-0
No files found.
electron/main.js
View file @
11f50478
...
@@ -110,8 +110,43 @@ function waitForServer(resolve, reject, retries = 30) {
...
@@ -110,8 +110,43 @@ function waitForServer(resolve, reject, retries = 30) {
req
.
end
();
req
.
end
();
}
}
function
createWindow
()
{
mainWindow
=
new
BrowserWindow
({
width
:
1400
,
height
:
900
,
webPreferences
:
{
preload
:
path
.
join
(
__dirname
,
'preload.js'
),
nodeIntegration
:
false
,
contextIsolation
:
true
},
title
:
'New API'
,
icon
:
path
.
join
(
__dirname
,
'icon.png'
)
});
mainWindow
.
loadURL
(
`http://localhost:
${
PORT
}
`
);
if
(
process
.
env
.
NODE_ENV
===
'development'
)
{
mainWindow
.
webContents
.
openDevTools
();
}
// Close to tray instead of quitting
mainWindow
.
on
(
'close'
,
(
event
)
=>
{
if
(
!
app
.
isQuitting
)
{
event
.
preventDefault
();
mainWindow
.
hide
();
if
(
process
.
platform
===
'darwin'
)
{
app
.
dock
.
hide
();
}
}
});
mainWindow
.
on
(
'closed'
,
()
=>
{
mainWindow
=
null
;
});
}
function
createTray
()
{
function
createTray
()
{
tray
=
new
Tray
(
path
.
join
(
__dirname
,
'tray-icon.png'
));
tray
=
new
Tray
(
path
.
join
(
__dirname
,
'tray-icon
Template
.png'
));
const
contextMenu
=
Menu
.
buildFromTemplate
([
const
contextMenu
=
Menu
.
buildFromTemplate
([
{
{
...
@@ -140,7 +175,7 @@ function createTray() {
...
@@ -140,7 +175,7 @@ function createTray() {
tray
.
setToolTip
(
'New API'
);
tray
.
setToolTip
(
'New API'
);
tray
.
setContextMenu
(
contextMenu
);
tray
.
setContextMenu
(
contextMenu
);
// On macOS, clicking the tray icon shows the
menu
// On macOS, clicking the tray icon shows the
window
tray
.
on
(
'click'
,
()
=>
{
tray
.
on
(
'click'
,
()
=>
{
if
(
mainWindow
===
null
)
{
if
(
mainWindow
===
null
)
{
createWindow
();
createWindow
();
...
@@ -153,41 +188,6 @@ function createTray() {
...
@@ -153,41 +188,6 @@ function createTray() {
});
});
}
}
function
createWindow
()
{
mainWindow
=
new
BrowserWindow
({
width
:
1400
,
height
:
900
,
webPreferences
:
{
preload
:
path
.
join
(
__dirname
,
'preload.js'
),
nodeIntegration
:
false
,
contextIsolation
:
true
},
title
:
'New API'
,
icon
:
path
.
join
(
__dirname
,
'icon.png'
)
});
mainWindow
.
loadURL
(
`http://localhost:
${
PORT
}
`
);
if
(
process
.
env
.
NODE_ENV
===
'development'
)
{
mainWindow
.
webContents
.
openDevTools
();
}
// Close to tray instead of quitting
mainWindow
.
on
(
'close'
,
(
event
)
=>
{
if
(
!
app
.
isQuitting
)
{
event
.
preventDefault
();
mainWindow
.
hide
();
if
(
process
.
platform
===
'darwin'
)
{
app
.
dock
.
hide
();
}
}
});
mainWindow
.
on
(
'closed'
,
()
=>
{
mainWindow
=
null
;
});
}
app
.
whenReady
().
then
(
async
()
=>
{
app
.
whenReady
().
then
(
async
()
=>
{
try
{
try
{
await
startServer
();
await
startServer
();
...
...
electron/tray-iconTemplate.png
0 → 100644
View file @
11f50478
459 Bytes
electron/tray-iconTemplate@2x.png
0 → 100644
View file @
11f50478
754 Bytes
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