我已经将整个源代码打包到一个.exe文件夹中。该应用程序的图标已设置,但我的问题是,它不承认(在我的情况下相同的图标)设置覆盖。从package.js提取的用于生成的代码:
"pack": "build --dir",
"dist": "build --win --ia32"
"build": {
"icon": "icon.ico"
}在index.html中,当我收到一个事件并需要覆盖图标时,它就会走出家门,抛出错误。相同的图标,我用来设置的应用程序。
mainWindow = new BrowserWindow({width: 1200, height: 800, icon: `icon.ico`, title: title})

我不明白这条路是从哪里来的..。我希望从应用程序的资源中找到图标的路径。同样的一个用来设置应用程序图标。迷失的想法,here...Please帮助。
来自index.html的相关部分
<script type="text/javascript">
const remoteElectron = require('electron').remote;
const BrowserWindow = remoteElectron.BrowserWindow;
const electron = require("electron");
var win = remoteElectron.getCurrentWindow();
var eventNewmsg = window.document.createEvent('Event');
eventNewmsg.initEvent('okmsg', false, false);
window.document.addEventListener("okmsg", function(){
win.setOverlayIcon(`icon.ico`, "");
}, false);
window.eventNewMsg = eventNewmsg;
var eventNomsg = window.document.createEvent('Event');
eventNomsg.initEvent('cancelmsg', false, false);
window.document.addEventListener("cancelmsg", function(){
win.setOverlayIcon(null, "")
}, false);
window.eventNoMsg = eventNomsg;
</script>发布于 2016-10-01 14:29:21
指定路径时最好是显式的,因此,如果图标与index.html位于同一个目录中,则应执行以下操作:
const path = require('path');
win.setOverlayIcon(path.join(__dirname, 'icon.ico', ''));发布于 2016-10-01 00:14:37
嗯,我设置了一个不同的方式图标,并工作相当好的我。
我会让你知道我是怎么安排的。在所有地方都能工作。
mainWindow = new BrowserWindow({
transparent: false,
frame: false,
fullscreen: false,
width: 800,
height: 400,
resizable: false,
movable: false,
show: false,
icon: __dirname + '/styles/images/app.png'
});https://stackoverflow.com/questions/39795126
复制相似问题