mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
1 parent
c542ad0348
commit
f88aa2f22e
3 files changed
+33
-1
No files matched your search
+4
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
import "../common/system-ca"
|
||||
import "../common/prometheus-providers"
|
||||
import { app, dialog } from "electron"
|
||||
import { app, dialog, Tray } from "electron"
|
||||
import { appName } from "../common/vars";
|
||||
import path from "path"
|
||||
import { LensProxy } from "./lens-proxy"
|
||||
@@ -13,6 +13,7 @@ import { shellSync } from "./shell-sync"
|
||||
import { getFreePort } from "./port"
|
||||
import { mangleProxyEnv } from "./proxy-env"
|
||||
import { registerFileProtocol } from "../common/register-protocol";
|
||||
import { setupTrayIcon } from "./tray";
|
||||
import { clusterStore } from "../common/cluster-store"
|
||||
import { userStore } from "../common/user-store";
|
||||
import { workspaceStore } from "../common/workspace-store";
|
||||
@@ -28,6 +29,7 @@ if (!process.env.CICD) {
|
||||
let windowManager: WindowManager;
|
||||
let clusterManager: ClusterManager;
|
||||
let proxyServer: LensProxy;
|
||||
let trayIcon: Tray;
|
||||
|
||||
mangleProxyEnv()
|
||||
if (app.commandLine.getSwitchValue("proxy-server") !== "") {
|
||||
@@ -75,6 +77,7 @@ async function main() {
|
||||
|
||||
// create window manager and open app
|
||||
windowManager = new WindowManager(proxyPort);
|
||||
trayIcon = await setupTrayIcon();
|
||||
}
|
||||
|
||||
app.on("ready", main);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import path from "path"
|
||||
import { app, Menu, nativeImage, Tray } from "electron"
|
||||
import { isDevelopment } from "../common/vars";
|
||||
import packageInfo from "../../package.json"
|
||||
|
||||
export async function setupTrayIcon() {
|
||||
await app.whenReady();
|
||||
|
||||
const iconPath = path.resolve(__static, isDevelopment ? "../build" : "", "icon.png");
|
||||
|
||||
// todo: https://www.electronjs.org/docs/api/native-image#high-resolution-image
|
||||
const icon = nativeImage.createFromPath(iconPath).resize({ width: 16, height: 16 });
|
||||
|
||||
const appTray = new Tray(icon);
|
||||
appTray.setToolTip(packageInfo.description)
|
||||
appTray.setIgnoreDoubleClickEvents(true)
|
||||
|
||||
const trayMenu = Menu.buildFromTemplate([
|
||||
{ label: 'Item1', type: 'radio' },
|
||||
{ label: 'Item2', type: 'radio' }
|
||||
]);
|
||||
|
||||
appTray.setContextMenu(trayMenu);
|
||||
return appTray;
|
||||
}
|
||||
Reference in new issue
Block a user