tray
This commit is contained in:
@@ -110,49 +110,6 @@ function waitForServer(resolve, reject, retries = 30) {
|
|||||||
req.end();
|
req.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
function createTray() {
|
|
||||||
tray = new Tray(path.join(__dirname, 'tray-icon.png'));
|
|
||||||
|
|
||||||
const contextMenu = Menu.buildFromTemplate([
|
|
||||||
{
|
|
||||||
label: 'Show New API',
|
|
||||||
click: () => {
|
|
||||||
if (mainWindow === null) {
|
|
||||||
createWindow();
|
|
||||||
} else {
|
|
||||||
mainWindow.show();
|
|
||||||
if (process.platform === 'darwin') {
|
|
||||||
app.dock.show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ type: 'separator' },
|
|
||||||
{
|
|
||||||
label: 'Quit',
|
|
||||||
click: () => {
|
|
||||||
app.isQuitting = true;
|
|
||||||
app.quit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
|
|
||||||
tray.setToolTip('New API');
|
|
||||||
tray.setContextMenu(contextMenu);
|
|
||||||
|
|
||||||
// On macOS, clicking the tray icon shows the menu
|
|
||||||
tray.on('click', () => {
|
|
||||||
if (mainWindow === null) {
|
|
||||||
createWindow();
|
|
||||||
} else {
|
|
||||||
mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show();
|
|
||||||
if (mainWindow.isVisible() && process.platform === 'darwin') {
|
|
||||||
app.dock.show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 1400,
|
width: 1400,
|
||||||
@@ -188,6 +145,49 @@ function createWindow() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createTray() {
|
||||||
|
tray = new Tray(path.join(__dirname, 'tray-iconTemplate.png'));
|
||||||
|
|
||||||
|
const contextMenu = Menu.buildFromTemplate([
|
||||||
|
{
|
||||||
|
label: 'Show New API',
|
||||||
|
click: () => {
|
||||||
|
if (mainWindow === null) {
|
||||||
|
createWindow();
|
||||||
|
} else {
|
||||||
|
mainWindow.show();
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
app.dock.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ type: 'separator' },
|
||||||
|
{
|
||||||
|
label: 'Quit',
|
||||||
|
click: () => {
|
||||||
|
app.isQuitting = true;
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
tray.setToolTip('New API');
|
||||||
|
tray.setContextMenu(contextMenu);
|
||||||
|
|
||||||
|
// On macOS, clicking the tray icon shows the window
|
||||||
|
tray.on('click', () => {
|
||||||
|
if (mainWindow === null) {
|
||||||
|
createWindow();
|
||||||
|
} else {
|
||||||
|
mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show();
|
||||||
|
if (mainWindow.isVisible() && process.platform === 'darwin') {
|
||||||
|
app.dock.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
app.whenReady().then(async () => {
|
app.whenReady().then(async () => {
|
||||||
try {
|
try {
|
||||||
await startServer();
|
await startServer();
|
||||||
|
|||||||
BIN
electron/tray-iconTemplate.png
Normal file
BIN
electron/tray-iconTemplate.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 459 B |
BIN
electron/tray-iconTemplate@2x.png
Normal file
BIN
electron/tray-iconTemplate@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 754 B |
Reference in New Issue
Block a user