shell
使用系統(tǒng)默認(rèn)應(yīng)用管理文件和 URL . 進(jìn)程: Main, Renderer
shell 模塊提供了集成其他桌面客戶端的關(guān)聯(lián)功能.
在用戶默認(rèn)瀏覽器中打開(kāi)URL的示例:
const {shell} = require('electron')
shell.openExternal('https://github.com')
方法
shell 模塊包含以下函數(shù):
shell.showItemInFolder(fullPath) fullPath String Returns Boolean - 是否成功打開(kāi)文件所在文件夾,一般情況下還會(huì)選中它.
shell.openItem(fullPath) fullPath String Returns Boolean - 是否成功的以默認(rèn)打開(kāi)方式打開(kāi)文件.
shell.openExternal(url) url String options Object (可選) macOS activate Boolean - true 讓打開(kāi)的應(yīng)用在前面顯示,默認(rèn)為 true. callback Function (可選) - 如果指定將執(zhí)行異步打開(kāi). macOS error Error Returns Boolean - 應(yīng)用程序是否打開(kāi)URL.如果指定了 callback 回調(diào)方法, 則返回 true.
以系統(tǒng)默認(rèn)設(shè)置打開(kāi)外部協(xié)議.(例如,mailto: URLs 會(huì)打開(kāi)用戶默認(rèn)的郵件客戶端)
shell.moveItemToTrash(fullPath) fullPath String Returns Boolean - 文件是否成功移動(dòng)到垃圾桶
刪除指定路徑文件,并返回此操作的狀態(tài)值(boolean類型).
shell.beep() 播放 beep 聲音.
shell.writeShortcutLink(shortcutPath[, operation], options) Windows shortcutPath String operation String (可選) - 默認(rèn)為 create, 可以為下列的值: create - 創(chuàng)建一個(gè)新的快捷方式,如果存在的話會(huì)覆蓋. update - 僅在現(xiàn)有快捷方式上更新指定屬性. replace - 覆蓋現(xiàn)有的快捷方式,如果快捷方式不存在則會(huì)失敗. options ShortcutDetails Returns Boolean - 快捷方式是否成功創(chuàng)建
為 shortcutPath 創(chuàng)建或更新快捷鏈接.
shell.readShortcutLink(shortcutPath) Windows
shortcutPath String
Returns ShortcutDetails
讀取 shortcutPath 的快捷連接的信息.
發(fā)生錯(cuò)誤時(shí),會(huì)拋出異常信息.
更多建議: