电子应用程序 - 图标不显示

问题描述 投票:0回答:1

我有以下 eletron-app 代码。当它启动时,它带有相同的开箱即用的通用电子图标,就像我没有提供自己的图标一样。除了图标之外,该应用程序按预期工作。

这是 /src/main.js 中的一个片段 我的 src 文件夹中也有“assets”。

  • src/main.js
  • src/assets/logo.ico
const { width, height } = screen.getPrimaryDisplay().workAreaSize;
    mainWindow = new BrowserWindow({
        width: width,
        height: height,
        icon: path.join(__dirname, 'assets', 'logo.ico'),
        webPreferences: {
            nodeIntegration: true,
            contextIsolation: false
        }
    });

Eletron Icon

electron icons
1个回答
0
投票

在开发过程中您无法轻松更改默认图标,但是当您构建 Electron 应用程序时,如果您使用的是 Electron Forge,则可以遵循 此指南

设置应用程序图标

Windows 和 macOS
module.exports = {
  // ...
  packagerConfig: {
    icon: '/path/to/icon' // no file extension required
  }
  // ...
};

实例化时必须额外加载图标

const { BrowserWindow } = require('electron')

const win = new BrowserWindow({
  // ...
  icon: '/path/to/icon.png'
})
© www.soinside.com 2019 - 2024. All rights reserved.