forked from ElectronNET/Electron.NET
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathshell.ts
More file actions
55 lines (41 loc) · 1.64 KB
/
Copy pathshell.ts
File metadata and controls
55 lines (41 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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);
});
};