import os from "os";/*** @name - Host Process* @description - Describes the host process* @member type - The type of the host process (electron, browser, etc)* @member release - The release string of the host process*/export interface IHostProcess {type: HostProcessType;release: string;}/*** @enum ELECTRON - Electron Host Process Type* @enum BROWSER - Browser Host Process Type*/export enum HostProcessType {Electron = 1, // bits: 01Browser = 2, // bits: 10All = 3, // bits: 11}export enum PlatformType {Web = "web",Windows = "win32",Linux = "linux",MacOS = "darwin",}function getHostProcess(): IHostProcess {const osRelease = os.release().toLowerCase();let hostProcessType: HostProcessType;if (osRelease.indexOf("electron") > -1 || process.env.HOST_TYPE === "electron") {hostProcessType = HostProcessType.Electron;} else {hostProcessType = HostProcessType.Browser;}return {release: osRelease,type: hostProcessType,};}export function isElectron(): boolean {return getHostProcess().type === HostProcessType.Electron;}export function isBrowser(): boolean {return getHostProcess().type === HostProcessType.Browser;}export default getHostProcess;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。