针对 macOS系统 BrowserWindows的展示文件
概览
在 macOS 上,您可以为应用程序中的任何窗口设置一个代表文件。 The represented file’s icon will be shown in the title bar, and when users Command-Click
or Control-Click
, a popup with a path to the file will be shown.
NOTE: The screenshot above is an example where this feature is used to indicate the currently opened file in the Atom text editor.
You can also set the edited state for a window so that the file icon can indicate whether the document in this window has been modified.
To set the represented file of window, you can use the BrowserWindow.setRepresentedFilename and BrowserWindow.setDocumentEdited APIs.
示例
从起 Quick Start Guide 示例的应用程序开始,将以下行添加到 main.js
文件:
const { app, BrowserWindow } = require('electron')
app.whenReady().then(() => {
const win = new BrowserWindow()
win.setRepresentedFilename('/etc/passwd')
win.setDocumentEdited(true)
})
After launching the Electron application, click on the title with Command
or Control
key pressed. You should see a popup with the file you just defined: