AlexTorresDev / custom-electron-titlebar

Custom electon title bar inpire on VS Code title bar
MIT License
866 stars 148 forks source link

Error: Cannot read properties of undefined (reading 'toDataURL') at t.default._setupIcon #197

Closed TiagoSilvaPereira closed 2 years ago

TiagoSilvaPereira commented 2 years ago

Describe the bug When using the package, it is firing the following error message on preload.ts:

Uncaught TypeError: Cannot read properties of undefined (reading 'toDataURL') at t.default._setupIcon

To Reproduce Steps to reproduce the behavior:

  1. Create a new electron + typescript project following this template: https://github.com/Deluze/electron-vue-template
  2. Follow the instructions to setup custom-electron-titlebar
  3. Add the following declaration to a .d.ts file to enable importing custom-electron-titlebar
declare module "custom-electron-titlebar/main" {
  import type cetMain from "custom-electron-titlebar/dist/main/main";

  export const setupTitlebar: typeof cetMain.setupTitlebar;
  export const attachTitlebarToWindow: typeof cetMain.attachTitlebarToWindow;
}
  1. See the error in the console

Expected behavior The expected behavior is to show the title bar

Screenshots image

Desktop:

Muhammad-Taif-Khan commented 2 years ago

Same problem here, did you find any solution?

TiagoSilvaPereira commented 2 years ago

@Muhammad-Taif-Khan no, but I discovered that it is not that hard to add a custom title bar to an electron app, so I decided to do it by myself: https://www.electronjs.org/docs/latest/tutorial/window-customization

Arkellys commented 2 years ago

The error comes from this line. Setting the parameter icon fix the error, but I don't think it should be a mandatory option...

Muhammad-Taif-Khan commented 2 years ago

Yep, it should not be a mandatory one.

AlexTorresDev commented 2 years ago

Working on it

AlexTorresDev commented 2 years ago

Describe the bug When using the package, it is firing the following error message on preload.ts:

Uncaught TypeError: Cannot read properties of undefined (reading 'toDataURL') at t.default._setupIcon

To Reproduce Steps to reproduce the behavior:

  1. Create a new electron + typescript project following this template: https://github.com/Deluze/electron-vue-template
  2. Follow the instructions to setup custom-electron-titlebar
  3. Add the following declaration to a .d.ts file to enable importing custom-electron-titlebar
declare module "custom-electron-titlebar/main" {
  import type cetMain from "custom-electron-titlebar/dist/main/main";

  export const setupTitlebar: typeof cetMain.setupTitlebar;
  export const attachTitlebarToWindow: typeof cetMain.attachTitlebarToWindow;
}
  1. See the error in the console

Expected behavior The expected behavior is to show the title bar

Screenshots image

Desktop:

  • OS: Windows 11
  • Electron version: 20.1.0
  • Node Version: 16.13

This bug was fixed in the clean code branch. In the next few weeks a beta will be released and in the next month the stable version. 🚀🚀