跳转到主内容
Soon, @electron packages on npm will require Node.js 22 LTS. Read more on our blog.

在 BrowserWindow 中展示文件

概览

在 macOS 上,您可以为应用程序中的任何窗口设置一个代表文件。 代表文件的图标将显示在标题栏中,当用户 Command-单击Control-单击,一个带有文件路径的弹出窗口将会显示。

展示文件(Represented File)

注意:上面的屏幕截图是一个示例,其中此功能用于指示 Atom 文本编辑器中当前打开的文件。

您还可以设置窗口的编辑状态,以便文件图标可以指示该窗口中的文档是否已修改。

To set the represented file of window, you can use the BrowserWindow.setRepresentedFilename and BrowserWindow.setDocumentEdited APIs.

示例

启动 Electron 应用程序后,在按下 CommandControl 键时单击标题。 You should see a popup with the represented file at the top. In this guide, this is the current user's home directory:

[画像:所展示的文件]

AltStyle によって変換されたページ (->オリジナル) /