19 lines
421 B
TypeScript
19 lines
421 B
TypeScript
import { Injectable } from '@angular/core';
|
|
|
|
type ElectronPlatformWindow = Window & {
|
|
electronAPI?: unknown;
|
|
};
|
|
|
|
@Injectable({ providedIn: 'root' })
|
|
export class PlatformService {
|
|
readonly isElectron: boolean;
|
|
readonly isBrowser: boolean;
|
|
|
|
constructor() {
|
|
this.isElectron =
|
|
typeof window !== 'undefined' && !!(window as ElectronPlatformWindow).electronAPI;
|
|
|
|
this.isBrowser = !this.isElectron;
|
|
}
|
|
}
|