Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Electron在编译应用程序时不显示未存储的图像_Javascript_Node.js_Compilation_Electron_Electron Forge - Fatal编程技术网

Javascript Electron在编译应用程序时不显示未存储的图像

Javascript Electron在编译应用程序时不显示未存储的图像,javascript,node.js,compilation,electron,electron-forge,Javascript,Node.js,Compilation,Electron,Electron Forge,我有一个项目,我下载一个FTP图像,我存储它们,我显示它们 这些图像被加载到img标记的src属性中 当我使用npm启动时,应用程序可以正常工作 另一方面,当我编译(electron forge make)时,我只能访问编译中已经存在的图像。我从应用程序下载的图像不可见 下载的图像和项目的图像具有相同的权限,并且应用程序具有webSecurity:false <button type="button" id="family_1"> <span>Family 1&l

我有一个项目,我下载一个FTP图像,我存储它们,我显示它们

这些图像被加载到img标记的src属性中

当我使用npm启动时,应用程序可以正常工作

另一方面,当我编译(electron forge make)时,我只能访问编译中已经存在的图像。我从应用程序下载的图像不可见

下载的图像和项目的图像具有相同的权限,并且应用程序具有webSecurity:false

<button type="button" id="family_1">
    <span>Family 1</span>
    <img src="/home/miguelcastro/xxx/xxx/xx/src/Cache/Images/Family/1.png" data-image="1.png">
</button>

保存图像后,我会从主渲染器向渲染器发出一个事件,并传递图像的路径,pathImage

您可以使用这部分代码绕过electron forge的检查器

import { addBypassChecker } from 'electron-compile';

addBypassChecker((filePath) => { return filePath.indexOf(app.getAppPath()) === -1 && (/.jpg/.test(filePath) || /.ms/.test(filePath) || /.png/.test(filePath)); });

添加部分代码。
ipcRenderer.on('printImage', (event, arg) => {
    var divImage = document.getElementById(idDiv)
    if (divImage !== null && divImage !== undefined)
        divImage.getElementsByTagName('img')[0].src = arg.pathImage
})
import { addBypassChecker } from 'electron-compile';

addBypassChecker((filePath) => { return filePath.indexOf(app.getAppPath()) === -1 && (/.jpg/.test(filePath) || /.ms/.test(filePath) || /.png/.test(filePath)); });