Zagir-vip
@Zagir-vip
Web dev, Game dev, app dev, Разработчик на Python!

Почему Electron. content-security-policy ругается на render.js?

У меня в render.js есть обычный код на отслеживания нажатия на кнопку для завершения работы приложения, но когда я запускаю приложение, то в консоли получаю предупреждение:
Electron Security Warning (Insecure Content-Security-Policy) This renderer process has either no Content Security
  Policy set or a policy with "unsafe-eval" enabled. This exposes users of
  this app to unnecessary security risks.

For more information and help, consult
https://electronjs.org/docs/tutorial/security.
This warning will not show up
once the app is packaged.

и мой код просто не обрабатывается.

render.js
window.onload=function() {
   console.log("LOAD!");
   const sys_shutdown = document.getElementById("SysShutdown");

   sys_shutdown.addEventListener('click', async function() {
      console.log('hello');
      await window.sys.shutdown();
   });
 }


preload.js:
contextBridge.exposeInMainWorld('sys', {
  shutdown: () => ipcRenderer.send('sys-shutdown')
});


Что мне делать?

P.S: Строка console.log("LOAD") в консоли отображается.
  • Вопрос задан
  • 104 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы