我真的无法在项目中包含一个模板的发行版。由于电子是无头的chrome,难道不能把它作为一个脚本包含进去吗?
我似乎有一个关于安全策略的错误。
模板版本:1.12.2。
它们在standalone-html中工作良好
index-64aa1cf6.js:2443 Refused to apply inline style because it violates the following Content Security Policy directive: "default-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-imoMl/F66ZbGZfn+J0jtlxdZvr/1ZBs+8ReasI4LBKQ='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'style-src' was not explicitly set, so 'default-src' is used as a fallback.
bootstrapLazy @ index-64aa1cf6.js:2443
index-64aa1cf6.js:2888 Refused to load the script 'blob:file:///f7aff0d4-a09c-464c-8344-451ac3a43fba' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.
Electron不是无头chrome,它是基于Chromium的。
你的错误信息告诉你,你启用了CSP(内容安全策略),因此加载脚本和内联样式被阻止了。
你可以改变CSP规则,使其允许加载该脚本,或者禁用CSP(不太安全)。
链接
这个问题可能只是因为你试图将脚本与 blob:file://
协议。
对于被阻止的内联样式,你可以在指令中添加一个 nonce 或哈希源(更安全),或者使用 'unsafe-inline'
.