V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
fantastM

VS Code 的这个功能是怎么实现的?

  •  
  •   fantastM · Sep 3, 2020 · 3231 views
    This topic created in 2066 days ago, the information mentioned may be changed or developed.

    我在基于 Electron 开发应用的时候遇到一个问题。在用户使用多个显示器的场景下,我需要获取所有显示器的名称,用于给用户选择将应用窗口放置在哪个显示器上。然而,通过 screen.getAllDisplays() 获取的 Display 对象中只有 id 属性,没有 name 属性。

    我在 Electron issues 里搜了好久,根据这个 issue,作者似乎特意没加 name 属性,反而给了一个 name 的哈希值。不过我看 VS Code 却又实现了这样的功能(这菜单项需要在使用多个显示器的时候才会显示):

    img

    于是我去看了 VS Code 的源码,但在 这段源码 上也没找到相关设置呀...

    希望哪位熟悉 Electron 或者 VS Code 的大佬可以指点一下

    3 replies    2020-09-03 15:18:20 +08:00
    tomatolq
        1
    tomatolq  
       Sep 3, 2020
    这个是 mac 系统自带的菜单
    chenny3
        2
    chenny3  
       Sep 3, 2020
    mac 自带的功能吧
    fantastM
        3
    fantastM  
    OP
       Sep 3, 2020
    @tomatolq @chenny3
    嘶...我试了一下,好像确实是 macOS 自带的。那我这需求估计是只能将就了...

    谢谢二位!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1013 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 18:09 · PVG 02:09 · LAX 11:09 · JFK 14:09
    ♥ Do have faith in what you're doing.