Shell


Shell 是一个包含执行桌面相关任务的 API 的集合。

概要

// Open URL with default browser.
nw.Shell.openExternal('https://github.com/nwjs/nw.js');

// Open a text file with default text editor.
nw.Shell.openItem('test.txt');

// Show a file in parent folder with file manager.
nw.Shell.showItemInFolder('test.txt');

Shell.openExternal(uri)

  • uri {String} 要以系统默认方式打开的 URL。

以桌面默认方式打开给定的外部 URI。例如,在默认邮件用户代理中打开 mailto: URL。

Shell.openItem(file_path)

  • file_path {String} 本地文件的路径

以桌面默认方式打开给定的 file_path

Shell.showItemInFolder(file_path)

  • file_path {String} 本地文件的路径

在文件管理器中显示给定 file_path 的父文件夹。如果可能,选择该文件。