如何为电子设置命令行
how to set command line for electron
我需要在 linux 中以透明 window 开头的电子,文档说我需要在命令行中输入 --enable-transparent-visuals --disable-gpu。有没有办法在程序中而不是在终端命令行中传递命令行参数。
像这样:
electron . --enable-transparent-visuals --disable-gpu
我需要的时候 运行
electron .
args 已在 program.It 中设置意味着我只需双击 bin 文件,args 就可以了。不需要手动传递它们。
您可以将它们放在应用程序的主脚本中 (main.js),在 app 模块的 'ready' 事件发出之前,例如所以:
const electron = require('electron')
// Module to control application life.
const app = electron.app
app.commandLine.appendSwitch('enable-transparent-visuals');
app.commandLine.appendSwitch('disable-gpu');
app.on('ready', () => {
// Your code here
});
有关其他命令行开关的列表,您可以转到 here
我需要在 linux 中以透明 window 开头的电子,文档说我需要在命令行中输入 --enable-transparent-visuals --disable-gpu。有没有办法在程序中而不是在终端命令行中传递命令行参数。 像这样:
electron . --enable-transparent-visuals --disable-gpu
我需要的时候 运行
electron .
args 已在 program.It 中设置意味着我只需双击 bin 文件,args 就可以了。不需要手动传递它们。
您可以将它们放在应用程序的主脚本中 (main.js),在 app 模块的 'ready' 事件发出之前,例如所以:
const electron = require('electron')
// Module to control application life.
const app = electron.app
app.commandLine.appendSwitch('enable-transparent-visuals');
app.commandLine.appendSwitch('disable-gpu');
app.on('ready', () => {
// Your code here
});
有关其他命令行开关的列表,您可以转到 here