mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Set nativeTheme ipc handlers and callers
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
8dbc0b82f8
commit
beba2c0068
8
src/common/ipc/native-theme.ts
Normal file
8
src/common/ipc/native-theme.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
|
||||
export const setNativeThemeChannel = "theme:set-native-theme";
|
||||
export const getNativeThemeChannel = "theme:get-native-theme";
|
||||
@ -55,6 +55,7 @@ import routerInjectable from "./router/router.injectable";
|
||||
import shellApiRequestInjectable from "./proxy-functions/shell-api-request/shell-api-request.injectable";
|
||||
import userStoreInjectable from "../common/user-store/user-store.injectable";
|
||||
import trayMenuItemsInjectable from "./tray/tray-menu-items.injectable";
|
||||
import { broadcastNativeThemeOnUpdate } from "./native-theme";
|
||||
|
||||
const di = getDi();
|
||||
|
||||
@ -108,6 +109,8 @@ di.runSetups().then(() => {
|
||||
}
|
||||
}
|
||||
|
||||
broadcastNativeThemeOnUpdate();
|
||||
|
||||
app.on("second-instance", (event, argv) => {
|
||||
logger.debug("second-instance message");
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { BrowserWindow, IpcMainInvokeEvent, Menu } from "electron";
|
||||
import { BrowserWindow, IpcMainInvokeEvent, Menu, nativeTheme } from "electron";
|
||||
import { clusterFrameMap } from "../../../common/cluster-frames";
|
||||
import { clusterActivateHandler, clusterSetFrameIdHandler, clusterVisibilityHandler, clusterRefreshHandler, clusterDisconnectHandler, clusterKubectlApplyAllHandler, clusterKubectlDeleteAllHandler, clusterDeleteHandler, clusterSetDeletingHandler, clusterClearDeletingHandler } from "../../../common/ipc/cluster";
|
||||
import type { ClusterId } from "../../../common/cluster-types";
|
||||
@ -24,6 +24,8 @@ import { onLocationChange, handleWindowAction } from "../../ipc/window";
|
||||
import { openFilePickingDialogChannel } from "../../../common/ipc/dialog";
|
||||
import { showOpenDialog } from "../../ipc/dialog";
|
||||
import { windowActionHandleChannel, windowLocationChangedChannel, windowOpenAppMenuAsContextMenuChannel } from "../../../common/ipc/window";
|
||||
import { getNativeColorTheme } from "../../native-theme";
|
||||
import { getNativeThemeChannel } from "../../../common/ipc/native-theme";
|
||||
|
||||
interface Dependencies {
|
||||
electronMenuItems: IComputedValue<MenuRegistration[]>;
|
||||
@ -158,4 +160,8 @@ export const initIpcMainHandlers = ({ electronMenuItems, directoryForLensLocalSt
|
||||
y: 20,
|
||||
});
|
||||
});
|
||||
|
||||
ipcMainHandle(getNativeThemeChannel, () => {
|
||||
return getNativeColorTheme();
|
||||
});
|
||||
};
|
||||
|
||||
18
src/main/native-theme.ts
Normal file
18
src/main/native-theme.ts
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { nativeTheme } from "electron";
|
||||
import { broadcastMessage } from "../common/ipc";
|
||||
import { setNativeThemeChannel } from "../common/ipc/native-theme";
|
||||
|
||||
export function broadcastNativeThemeOnUpdate() {
|
||||
nativeTheme.on("updated", () => {
|
||||
broadcastMessage(setNativeThemeChannel, getNativeColorTheme());
|
||||
});
|
||||
}
|
||||
|
||||
export function getNativeColorTheme() {
|
||||
return nativeTheme.shouldUseDarkColors ? "dark" : "light";
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user