【问题标题】:Electron openItem opens new window of same pathElectron openItem 打开相同路径的新窗口
【发布时间】:2019-08-09 14:30:03
【问题描述】:

我正在使用电子。当我在按钮上触发shell.openItem(fullPath to folderA) 时,它会在寡妇中打开文件夹A(正确)。 但是如果我从不同的按钮再次触发shell.openItem(fullPath to folderA)。它不是带上已经打开的文件夹,而是在新窗口中打开文件夹。

【问题讨论】:

    标签: windows shell electron


    【解决方案1】:

    你的问题实际上是一个观察。是的,openItem 就是这样工作的。 (在它的深处调用 ShellExecuteEx 并带有“explore”动词选项,就是这样工作的)

    如果您希望连续调用使用同一个窗口,您可以使用openExternal(在内部深处执行带有“open”选项的shell,这种方式工作)。它会一直打开同一个窗口,直到您不离开为止

    6.0.1测试

    const { shell } = require('electron')
    
    setInterval(() => {
      shell.openExternal(__dirname)
    }, 5000)
    

    【讨论】:

    • 自 Electron 9.0 以来,shell.openItem() 已被 shell.openPath() 取代
    猜你喜欢
    • 2019-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-15
    • 2011-01-18
    • 1970-01-01
    • 1970-01-01
    • 2014-03-24
    相关资源
    最近更新 更多