最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do I re-center an electron window after dynamically resizing? - Stack Overflow

programmeradmin0浏览0评论

After calling

remote.getCurrentWindow().setSize(width, height);

the window resizes, but is not positioned in the center of the screen. Is there a way to adjust the offset of the window relative to the screen?

After calling

remote.getCurrentWindow().setSize(width, height);

the window resizes, but is not positioned in the center of the screen. Is there a way to adjust the offset of the window relative to the screen?

Share Improve this question edited Aug 9, 2018 at 15:11 user1234 asked Aug 9, 2018 at 15:07 user1234user1234 8,9784 gold badges30 silver badges37 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 22

There is a .center() method on BrowserWindow, so

const win = remote.getCurrentWindow();
win.setSize(width, height);
win.center();

centers the window after resizing.

发布评论

评论列表(0)

  1. 暂无评论