在 BrowserWindow 中展示文件
概览
在 macOS 上,您可以为应用程序中的任何窗口设置一个代表文件。 代表文件的图标将显示在标题栏中,当用户 Command-单击 或 Control-单击,一个带有文件路径的弹出窗口将会显示。
展示文件(Represented File)
注意:上面的屏幕截图是一个示例,其中此功能用于指示 Atom 文本编辑器中当前打开的文件。
您还可以设置窗口的编辑状态,以便文件图标可以指示该窗口中的文档是否已修改。
To set the represented file of window, you can use the BrowserWindow.setRepresentedFilename and BrowserWindow.setDocumentEdited APIs.
示例
docs/fiddles/features/represented-file (39.0.0) UTF-8">
<title>Hello World!</title>
<metahttp-equiv="Content-Security-Policy"content="script-src 'self' 'unsafe-inline';"/>
<linkrel="stylesheet"type="text/css"href="./styles.css">
</head>
<body>
<h1>Hello World!</h1>
<p>
Click on the title with the <pre>Command</pre> or <pre>Control</pre> key pressed.
You should see a popup with the represented file at the top.
</p>
</body>
</body>
</html>
<title>Hello World!</title>
<metahttp-equiv="Content-Security-Policy"content="script-src 'self' 'unsafe-inline';"/>
<linkrel="stylesheet"type="text/css"href="./styles.css">
</head>
<body>
<h1>Hello World!</h1>
<p>
Click on the title with the <pre>Command</pre> or <pre>Control</pre> key pressed.
You should see a popup with the represented file at the top.
</p>
</body>
</body>
</html>