Supported Command Line Switches支持的命令行开关
Command line switches supported by Electron.Electron支持的命令行开关。
You can use app.commandLine.appendSwitch to append them in your app's main script before the ready event of the app module is emitted:在发出app模块的ready事件之前,您可以使用app.commandLine.appendSwitch将它们附加到应用程序的主脚本中:
const { app } = require('electron')
app.commandLine.appendSwitch('remote-debugging-port', '8315')
app.commandLine.appendSwitch('host-rules', 'MAP * 127.0.0.1')
app.whenReady().then(() => {
// Your code here
})
Electron CLI Flags
--auth-server-whitelist=url
A comma-separated list of servers for which integrated authentication is enabled.启用集成身份验证的服务器的逗号分隔列表。
For example:例如:
--auth-server-whitelist='*example.com, *foobar.com, *baz'
then any 然后,任何以url
ending with example.com
, foobar.com
, baz
will be considered for integrated authentication. example.com
、foobar.com
、baz
结尾的url
都将被考虑用于集成身份验证。Without 如果没有*
prefix the URL has to match exactly.*
前缀,URL必须完全匹配。
--auth-negotiate-delegate-whitelist=url
A comma-separated list of servers for which delegation of user credentials is required. 需要委派用户凭据的服务器的逗号分隔列表。Without 如果没有*
prefix the URL has to match exactly.*
前缀,URL必须完全匹配。
--disable-ntlm-v2
Disables NTLM v2 for posix platforms, no effect elsewhere.为posix平台禁用NTLM v2,在其他地方无效。
--disable-http-cache
Disables the disk cache for HTTP requests.禁用HTTP请求的磁盘缓存。
--disable-http2
Disable HTTP/2 and SPDY/3.1 protocols.禁用HTTP/2和SPDY/3.1协议。
--disable-renderer-backgrounding
Prevents Chromium from lowering the priority of invisible pages' renderer processes.防止Chromium降低不可见页面的渲染器进程的优先级。
This flag is global to all renderer processes, if you only want to disable throttling in one window, you can take the hack of playing silent audio.这个标志对所有渲染器进程都是全局的,如果你只想在一个窗口中禁用节流,你可以尝试播放无声音频。
--disk-cache-size=size
Forces the maximum disk space to be used by the disk cache, in bytes.强制磁盘缓存使用的最大磁盘空间,以字节为单位。
--enable-logging[=file]
Prints Chromium's logging to stderr (or a log file).将Chromium的日志记录打印到stderr(或日志文件)。
The ELECTRON_ENABLE_LOGGING
environment variable has the same effect as passing --enable-logging
.ELECTRON_ENABLE_LOGGING
环境变量具有与传递---enable-logging
相同的效果。
Passing 传递--enable-logging
will result in logs being printed on stderr. --enable-logging
将导致在stderr上打印日志。Passing 传递--enable-logging=file
will result in logs being saved to the file specified by --log-file=...
, or to electron_debug.log
in the user-data directory if --log-file
is not specified.--enable-logging=file
将导致日志保存到--log-file=...
指定的文件中,如果未指定--log-file
,则返回到用户数据目录中的electron_debug.log
。
Note:
On Windows, logs from child processes cannot be sent to stderr.在Windows上,子进程的日志无法发送到stderr。Logging to a file is the most reliable way to collect logs on Windows.记录到文件是在Windows上收集日志的最可靠方式。
See also 另请参阅--log-file
, --log-level
, --v
, and --vmodule
.--log-file
、--log-level
、--v
和--vmodule
。
--force-fieldtrials=trials
Field trials to be forcefully enabled or disabled.强制启用或禁用现场试验。
For example: 例如:WebRTC-Audio-Red-For-Opus/Enabled/
--host-rules=rules
A comma-separated list of 以逗号分隔的rules
that control how hostnames are mapped.rules
列表,用于控制主机名的映射方式。
For example:例如:
MAP * 127.0.0.1
Forces all hostnames to be mapped to 127.0.0.1强制将所有主机名映射到127.0.0.1MAP *.google.com proxy
Forces all google.com subdomains to be resolved to "proxy".强制将所有google.com子域解析为"proxy"。MAP test.com [::1]:77
Forces "test.com" to resolve to IPv6 loopback.强制“test.com”解析为IPv6环回。Will also force the port of the resulting socket address to be 77.还将强制生成的套接字地址的端口为77。MAP * baz, EXCLUDE www.google.com
Remaps everything to "baz", except for "www.google.com".将所有内容重制为“baz”,但"www.google.com"除外。
These mappings apply to the endpoint host in a net request (the TCP connect and host resolver in a direct connection, and the 这些映射应用于网络请求中的端点主机(直接连接中的TCP连接和主机解析程序,HTTP代理连接中的CONNECT
in an HTTP proxy connection, and the endpoint host in a SOCKS
proxy connection).CONNECT
,以及SOCKS
代理连接的端点主机)。
--host-resolver-rules=rules
Like 类似于--host-rules
but these rules
only apply to the host resolver.--host-rules
,但这些rules
仅适用于主机解析程序。
--ignore-certificate-errors
Ignores certificate related errors.忽略与证书相关的错误。
--ignore-connections-limit=domains
Ignore the connections limit for 忽略以domains
list separated by ,
.,
分隔的domains
列表的连接限制。
--js-flags=flags
Specifies the flags passed to the Node.js engine. 指定传递给Node.js引擎的标志。It has to be passed when starting Electron if you want to enable the 如果您想在主进程中启用flags
in the main process.flags
,则必须在启动Electron时通过。
$ electron --js-flags="--harmony_proxies --harmony_collections" your-app
See the Node.js documentation or run 有关可用标志的列表,请参阅Node.js文档或在终端中运行node --help
in your terminal for a list of available flags. node --help
。Additionally, run 此外,运行node --v8-options
to see a list of flags that specifically refer to Node.js's V8 JavaScript engine.node --v8-options
选项可以查看专门引用Node.js的v8 JavaScript引擎的标志列表。
--lang
Set a custom locale.设置自定义区域设置。
--log-file=path
If 如果指定了--enable-logging
is specified, logs will be written to the given path. The parent directory must exist.--enable-logging
记录,则日志将被写入给定的路径。父目录必须存在。
Setting the 设置ELECTRON_LOG_FILE
environment variable is equivalent to passing this flag. ELECTRON_LOG_FILE
环境变量相当于传递此标志。If both are present, the command-line switch takes precedence.如果两者都存在,则命令行开关优先。
--log-net-log=path
Enables net log events to be saved and writes them to 允许保存网络日志事件并将其写入path
.path
。
--log-level=N
Sets the verbosity of logging when used together with --enable-logging
. N
should be one of Chrome's LogSeverities.
Note that two complimentary logging mechanisms in Chromium -- LOG()
and VLOG()
-- are controlled by different switches. --log-level
controls LOG()
messages, while --v
and --vmodule
control VLOG()
messages. So you may want to use a combination of these three switches depending on the granularity you want and what logging calls are made by the code you're trying to watch.
See Chromium Logging source for more information on how LOG()
and VLOG()
interact. Loosely speaking, VLOG()
can be thought of as sub-levels / per-module levels inside LOG(INFO)
to control the firehose of LOG(INFO)
data.
See also --enable-logging
, --log-level
, --v
, and --vmodule
.
--no-proxy-server
Don't use a proxy server and always make direct connections. 不要使用代理服务器,而是始终进行直接连接。Overrides any other proxy server flags that are passed.覆盖传递的任何其他代理服务器标志。
--no-sandbox
Disables the Chromium sandbox. 禁用Chromium沙盒。Forces renderer process and Chromium helper processes to run un-sandboxed. 强制渲染器进程和Chromium辅助进程在非沙盒状态下运行。Should only be used for testing.应仅用于测试。
--proxy-bypass-list=hosts
Instructs Electron to bypass the proxy server for the given semi-colon-separated list of hosts. 指示Electron为给定的以分号分隔的主机列表绕过代理服务器。This flag has an effect only if used in tandem with 只有当与--proxy-server
.--proxy-server
一起使用时,此标志才会生效。
For example:
const { app } = require('electron')
app.commandLine.appendSwitch('proxy-bypass-list', '<local>;*.google.com;*foo.com;1.2.3.4:5678')
Will use the proxy server for all hosts except for local addresses (将对所有主机使用代理服务器,但本地地址(localhost
, 127.0.0.1
etc.), google.com
subdomains, hosts that contain the suffix foo.com
and anything at 1.2.3.4:5678
.localhost
、127.0.0.1
等)、google.com
子域、包含后缀foo.com
的主机以及1.2.3.4:5678
的任何主机除外。
--proxy-pac-url=url
Uses the PAC script at the specified url
.
--proxy-server=address:port
Use a specified proxy server, which overrides the system setting. 使用指定的代理服务器,该代理服务器将覆盖系统设置。This switch only affects requests with HTTP protocol, including HTTPS and WebSocket requests. 此开关仅影响具有HTTP协议的请求,包括HTTPS和WebSocket请求。It is also noteworthy that not all proxy servers support HTTPS and WebSocket requests. 同样值得注意的是,并非所有代理服务器都支持HTTPS和WebSocket请求。The proxy URL does not support username and password authentication per Chromium issue.根据Chromium问题,代理URL不支持用户名和密码身份验证。
--remote-debugging-port=port
Enables remote debugging over HTTP on the specified 在指定的port
.port
上通过HTTP启用远程调试。
--v=log_level
Gives the default maximal active V-logging level; 0 is the default. 给出默认的最大活动V日志记录级别;0是默认值。Normally positive values are used for V-logging levels.V型测井水平通常使用正值。
This switch only works when 此开关仅在同时传递--enable-logging
is also passed.--enable-logging
时工作。
See also --enable-logging
, --log-level
, and --vmodule
.
--vmodule=pattern
Gives the per-module maximal V-logging levels to override the value given by 给出每个模块的最大V日志记录级别,以覆盖--v
. --v
给出的值。E.g. 例如,my_module=2,foo*=3
would change the logging level for all code in source files my_module.*
and foo*.*
.my_module=2,foo*=3
将更改源文件my_modules.*
和foo*.*
中所有代码的日志记录级别。
Any pattern containing a forward or backward slash will be tested against the whole pathname and not only the module. 任何包含正向或反向斜杠的模式都将针对整个路径名进行测试,而不仅仅是针对模块。E.g. 例如,*/foo/bar/*=2
would change the logging level for all code in the source files under a foo/bar
directory.*/foo/bar/*=2
将更改foo/bar
目录下源文件中所有代码的日志记录级别。
This switch only works when 此开关仅在同时传递--enable-logging
is also passed.--enable-logging
时工作。
See also 另请参阅--enable-logging
, --log-level
, and --v
.--enable-logging
、--log-level
和--v
。
--force_high_performance_gpu
Force using discrete GPU when there are multiple GPUs available.当有多个GPU可用时,强制使用离散GPU。
--force_low_power_gpu
Force using integrated GPU when there are multiple GPUs available.当有多个GPU可用时,强制使用集成GPU。
Node.js Flags
Electron supports some of the CLI flags supported by Node.js.Electron支持Node.js支持的一些CLI标志。
Note: Passing unsupported command line switches to Electron when it is not running in 当ELECTRON_RUN_AS_NODE
will have no effect.ELECTRON_RUN_AS_NODE
中没有运行时,将不受支持的命令行开关传递给Electron将没有效果。
--inspect-brk[=[host:]port]
Activate inspector on host:port and break at start of user script. 在主机:端口上激活检查器,并在用户脚本开始时中断。Default host:port is 127.0.0.1:9229.默认主机:端口为127.0.0.1:9229。
Aliased to --debug-brk=[host:]port
.--debug-brk=[host:]port
的别名。
--inspect-port=[host:]port
Set the 设置在激活检查器时要使用的host:port
to be used when the inspector is activated. host:port
。Useful when activating the inspector by sending the SIGUSR1 signal. Default host is 当通过发送SIGUSR1信号激活检查员时很有用。默认主机为127.0.0.1
.127.0.0.1
。
Aliased to --debug-port=[host:]port
.--debug-port=[host:]port
的别名。
--inspect[=[host:]port]
Activate inspector on 激活host:port
. host:port
上的检查器。Default is 默认值为127.0.0.1:9229
.127.0.0.1:9229
。
V8 inspector integration allows tools such as Chrome DevTools and IDEs to debug and profile Electron instances. V8检查器集成允许Chrome DevTools和IDE等工具调试和评测Electron实例。The tools attach to Electron instances via a TCP port and communicate using the Chrome DevTools Protocol.这些工具通过TCP端口连接到Electron实例,并使用Chrome DevTools协议进行通信。
See the Debugging the Main Process guide for more details.有关更多详细信息,请参阅调试主进程指南。
Aliased to --debug[=[host:]port
.--debug[=[host:]port
的别名。
--inspect-publish-uid=stderr,http
Specify ways of the inspector web socket url exposure.指定检查器web套接字url公开的方式。
By default inspector websocket url is available in stderr and under /json/list endpoint on http://host:port/json/list.默认情况下,检查器websocket url在stderr和上的/json/list端点下可用http://host:port/json/list
。