shell
Gère des fichiers et URLs à l'aide de leurs applications par défaut.
Process: Main, Renderer (non-sandboxed only)
Le module shell
fournit des fonctions liées à l'intégration bureau.
Un exemple d'ouverture d'une URL dans le navigateur par défaut de l'utilisateur :
const { shell } = require('electron')
shell.openExternal('https://github.com')
Note: While the shell
module can be used in the renderer process, it will not function in a sandboxed renderer.
Méthodes
Le module shell
dispose des méthodes suivantes :
shell.showItemInFolder(fullPath)
fullPath
string
Show the given file in a file manager. Si possible, sélectionnez le fichier.
shell.openPath(path)
path
string
Returns Promise<string>
- Resolves with a string containing the error message corresponding to the failure if a failure occurred, otherwise "".
Ouvre le fichier donné dans la manière par défaut de l'ordinateur.
shell.openExternal(url[, options])
url
string - 2081 caractères max. sur Windows.
Retourne Promise<void>
Open the given external protocol URL in the desktop's default manner. (For example, mailto: URLs in the user's default mail agent).
shell.trashItem(path)
path
string - path to the item to be moved to the trash.
Returns Promise<void>
- Resolves when the operation has been completed. Rejects if there was an error while deleting the requested item.
This moves a path to the OS-specific trash location (Trash on macOS, Recycle Bin on Windows, and a desktop-environment-specific location on Linux).
shell.beep()
Émet un signal sonore.
shell.writeShortcutLink(shortcutPath[, operation], options)
Windows
shortcutPath
stringoperation
string (optional) - Default iscreate
, can be one of following:create
- Créer un nouveau raccourci, écrase si besoin.update
- Met à jour les propriétés seulement sur un raccourci existant.replace
- Remplace un raccourci existant, échoue si le raccourci n'existe pas.
Retourne boolean
- Si le raccourci a été créé avec succès.
Créer ou met à jour un lien raccourci à shortcutPath
.
shell.readShortcutLink(shortcutPath)
Windows
shortcutPath
string
Retourne ShortcutDetails
Résout le lien raccourci à shortcutPath
.
Une exception sera levée lorsqu’une erreur se produit.