Electron官方文档(v1.6.1)中文翻译

5. shell

2017-03-07  本文已影响112人  Shmily落墨

原文:https://github.com/electron/electron/blob/master/docs/api/shell.md
译者:Lin

使用文件和URL的默认应用管理文件和URL

进程:主进程渲染进程

shell模块提供有关于桌面集成的函数。

一个使用用户默认浏览器打开一个URL的例子:

const {shell} = require('electron')

shell.openExternal('https://github.com')

<h2 id="methods">方法</h2>

shell模块有下面的方法:

<h3 id="shell-showItemInFolder"><code>shell.showItemInFolder(fullPath)</code></h3>

返回值为Boolean类型 - 项是否展示成功。

在一个文件管理器中展示要展示的文件。如果可能,将会选中这个文件。

<h3 id="shell-openItem"><code>shell.openItem(fullPath)</code></h3>

返回值为Boolean类型 - 项是否打开成功。

在桌面的默认方式中打开指定文件。

<h3 id="shell-openExternal"><code>shell.openExternal(url[, options, callback])</code></h3>

返回值为Boolean类型 - 应用程序是否有效的打开了URL。如果callback被指定,将总是返回true

在桌面的默认打开方式中打开传入的外部协议URL。(例如,地址:用户的默认邮件代理的网址)。

<h3 id="shell-moveItemToTrash"><code>shell.moveItemToTrash(fullPath)</code></h3>

返回值为Boolean类型 - 项是否成功的被移除到了垃圾桶中。

移动给定的文件到垃圾桶,并且返回一个boolean类型的操作状态。

<h3 id="shell-beep"><code>shell.beep()</code></h3>

播放beep声音。

<h3 id="shell-writeShortcutLink"><code>shell.writeShortcutLink(shortcutPath[, operation], options)</code> <i>(Windows)</i></h3>

返回值为Boolean类型 - 快捷方式是否被创建成功。

创建或者更新shortcutPath下的一个快捷方式的链接

<h3 id="shell-"><code>shell.readShortcutLink(shortcutPath) Windows</code><i>(Windows)</i></h3>

返回值为ShortcutDetails类型

分解shortcutPath下的快捷方式的链接。

任何错误发生时都将会抛出一个意外。

上一篇 下一篇

猜你喜欢

热点阅读