Windows:电子通知未显示应用徽标,而是其他任何地方

发布于 2025-02-03 05:50:51 字数 1752 浏览 3 评论 0 原文

该应用徽标在其他任何地方都可以正确显示,但在通知部分中显示一个空徽标

https://i.sstatic.net/ddygv.png“ alt =”在此处输入图像说明“>

我知道您可以为通知添加一个自定义图像,传递 iCON property像这样:

           new Notification({
              title: 'Test Notification',
              body: 'This is a test notification',
              icon: path.join(__dirname, 'icon.ico'),
            });

但这不是我要更改的徽标。

构建时该应用程序还将在其他地方显示正确的徽标:

”“在此处输入图像说明”

我还添加了 iCON 属性创建 browserwindow ,例如 here

  const win = splashWindow = new BrowserWindow({
    width: 320,
    height: 320,
    // more 
    icon: path.resolve(__dirname, 'icon.ico'),
  });

添加A

win.setIcon(path.resolve(__dirname, 'icon.ico');

也无效。

此代码全部都在 main.js 中。

而且我一直在检查 app class 并且有一个 getfileicon ,但似乎与此无关。

可能是相关的吗

ipcMain.on('app-ready', () => {
  if (process.platform === 'win32') {
    // somehow also change logo here? can't find it in the docs
    app.setAppUserModelId('Awesome app');
  }

The app logo is properly shown everywhere else but in the notification section where it displays an empty logo

enter image description here

I know that you can add a custom image for the notification passing a icon property like so:

           new Notification({
              title: 'Test Notification',
              body: 'This is a test notification',
              icon: path.join(__dirname, 'icon.ico'),
            });

But that's not the logo I want to change.

The app when built also shows the correct logo elsewhere:

enter image description here

I also added an icon property when creating the BrowserWindow like advised here.

  const win = splashWindow = new BrowserWindow({
    width: 320,
    height: 320,
    // more 
    icon: path.resolve(__dirname, 'icon.ico'),
  });

Adding a

win.setIcon(path.resolve(__dirname, 'icon.ico');

doesn't work too.

This code is all in main.js.

And I've been checking the docs for the App class and there's a getFileIcon but it doesn't appear to be related to this.

May be related?

I have been able to modify the app name to 'Awesome App' via setAppUserModelId like so:

ipcMain.on('app-ready', () => {
  if (process.platform === 'win32') {
    // somehow also change logo here? can't find it in the docs
    app.setAppUserModelId('Awesome app');
  }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

乖乖哒 2025-02-10 05:50:51

我调用 app.setappusermodelid('xxxx')新通知之前,它起作用。

xxxx是您的捆绑包ID。

令人困惑的部分是捆绑ID,因此Bulde ID在package中是appid.json

"build": {
   "appId": "com.windshieldhub.TimeTracker",
   "productName": "WindshieldHUB Time Tracker",
   "win": {
     "target": "nsis",
     "icon": "public/assets/logo-icon.ico",
     "publish": {
     "provider": "github"
  }
},
}

在setappusermodelid()中添加appid()将从此数组中获取产品名称和图标。

I call app.setAppUserModelId('xxxx') before new Notification and it works.

xxxx is your bundle id.

Confusing part was what is the bundle id so bulde id is appId in package.json

"build": {
   "appId": "com.windshieldhub.TimeTracker",
   "productName": "WindshieldHUB Time Tracker",
   "win": {
     "target": "nsis",
     "icon": "public/assets/logo-icon.ico",
     "publish": {
     "provider": "github"
  }
},
}

Adding appId in setAppUserModelId() will take the product Name and icon from this array.

伴随着你 2025-02-10 05:50:51
    i have used below changes.
inside package.json --> add below. make sure to add  "appId": "YOUR APP NAME"
    "win": {
      "target": "nsis",
      "icon": "logo256.ico",
      "appId": "YOUR APP NAME"
    }


also make sure to add 
app.on("ready", ev => {
  if (process.platform == 'win32') {
    app.setAppUserModelId('YOUR APP NAME');
  }
}
    i have used below changes.
inside package.json --> add below. make sure to add  "appId": "YOUR APP NAME"
    "win": {
      "target": "nsis",
      "icon": "logo256.ico",
      "appId": "YOUR APP NAME"
    }


also make sure to add 
app.on("ready", ev => {
  if (process.platform == 'win32') {
    app.setAppUserModelId('YOUR APP NAME');
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文