mirror of
https://github.com/YuzuZensai/Termix.git
synced 2026-09-13 10:49:03 +00:00
19 lines
495 B
TypeScript
19 lines
495 B
TypeScript
type ElectronWindow = Window &
|
|||
|
|
typeof globalThis & {
|
||
|
|
IS_ELECTRON?: boolean;
|
||
|
|
electronAPI?: {
|
||
|
|
isElectron?: boolean;
|
||
|
|
};
|
||
|
|
};
|
||
|
|
|
||
|
|
export function isElectron(): boolean {
|
||
|
|
if (typeof window === "undefined") return false;
|
||
|
|
|
||
|
|
const win = window as ElectronWindow;
|
||
|
|
const hasISElectron = win.IS_ELECTRON === true;
|
||
|
|
const hasElectronAPI = !!win.electronAPI;
|
||
|
|
const isElectronProp = win.electronAPI?.isElectron === true;
|
||
|
|
|
||
|
|
return hasISElectron || hasElectronAPI || isElectronProp;
|
||
|
|
}
|