mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-13 13:44:57 +00:00
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
import { shell } from 'electron';
|
|
let electronSocket;
|
|
|
|
export = (socket: SocketIO.Socket) => {
|
|
electronSocket = socket;
|
|
socket.on('shell-showItemInFolder', (fullPath) => {
|
|
shell.showItemInFolder(fullPath);
|
|
|
|
electronSocket.emit('shell-showItemInFolderCompleted');
|
|
});
|
|
|
|
socket.on('shell-openPath', async (path) => {
|
|
const errorMessage = await shell.openPath(path);
|
|
|
|
electronSocket.emit('shell-openPathCompleted', errorMessage);
|
|
});
|
|
|
|
socket.on('shell-openExternal', async (url, options) => {
|
|
let result = '';
|
|
|
|
if (options) {
|
|
await shell.openExternal(url, options).catch(e => {
|
|
result = e.message;
|
|
});
|
|
} else {
|
|
await shell.openExternal(url).catch((e) => {
|
|
result = e.message;
|
|
});
|
|
}
|
|
|
|
electronSocket.emit('shell-openExternalCompleted', result);
|
|
});
|
|
|
|
socket.on('shell-moveItemToTrash', (fullPath, deleteOnFail) => {
|
|
const success = shell.moveItemToTrash(fullPath, deleteOnFail);
|
|
|
|
electronSocket.emit('shell-moveItemToTrashCompleted', success);
|
|
});
|
|
|
|
socket.on('shell-beep', () => {
|
|
shell.beep();
|
|
});
|
|
|
|
socket.on('shell-writeShortcutLink', (shortcutPath, operation, options) => {
|
|
const success = shell.writeShortcutLink(shortcutPath, operation, options);
|
|
|
|
electronSocket.emit('shell-writeShortcutLinkCompleted', success);
|
|
});
|
|
|
|
socket.on('shell-readShortcutLink', (shortcutPath) => {
|
|
const shortcutDetails = shell.readShortcutLink(shortcutPath);
|
|
|
|
electronSocket.emit('shell-readShortcutLinkCompleted', shortcutDetails);
|
|
});
|
|
};
|