Electron windows:架构

Electron windows: architecture

有没有办法检测主进程中电子的结构?

process.platform 似乎 return win32 也在 x64 机器上,我没有在文档中找到任何获取体系结构的选项。

你试过了吗process.arch

我相信returns当前进程的架构,而不是操作系统的架构

在electron(main.js)的主进程中,可以引入节点模块'os',代码为:

const { app, BrowserWindow, autoUpdater } = require('electron');
const os = require("os");

app.on('ready', () => {
  console.log(os.arch()); // print architecture 
  console.log(os.platform()); // print system platform 
  createBrowserWindow();
});

The os.arch() method returns a string identifying the operating system CPU architecture for which the Node.js binary was compiled. The current possible values are: 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'.

The os.platform() method returns a string identifying the operating system platform as set during compile time of Node.js. The current possible values are: 'aix', 'darwin', 'freebsd', 'linux', 'openbsd', 'sunos', 'win32'

更多内容:https://nodejs.org/api/os.html#os_os_platform