2017-10-21 04:37:01 +02:00
|
|
|
"use strict";
|
2019-01-05 02:17:31 +01:00
|
|
|
const electron_1 = require("electron");
|
2019-04-18 18:03:17 +01:00
|
|
|
let electronSocket;
|
2019-01-05 02:17:31 +01:00
|
|
|
module.exports = (socket) => {
|
2019-04-18 18:03:17 +01:00
|
|
|
electronSocket = socket;
|
2019-01-05 02:17:31 +01:00
|
|
|
socket.on('shell-showItemInFolder', (fullPath) => {
|
2020-05-26 15:11:22 +02:00
|
|
|
electron_1.shell.showItemInFolder(fullPath);
|
|
|
|
|
electronSocket.emit('shell-showItemInFolderCompleted');
|
2017-10-21 04:37:01 +02:00
|
|
|
});
|
2020-05-25 17:31:27 +02:00
|
|
|
socket.on('shell-openPath', async (path) => {
|
|
|
|
|
const errorMessage = await electron_1.shell.openPath(path);
|
|
|
|
|
electronSocket.emit('shell-openPathCompleted', errorMessage);
|
2017-10-21 04:37:01 +02:00
|
|
|
});
|
2020-05-27 00:51:48 +02:00
|
|
|
socket.on('shell-openExternal', async (url, options) => {
|
2021-01-11 01:56:39 +01:00
|
|
|
let result = '';
|
2019-05-16 03:13:35 +02:00
|
|
|
if (options) {
|
2020-05-27 00:51:48 +02:00
|
|
|
await electron_1.shell.openExternal(url, options).catch(e => {
|
|
|
|
|
result = e.message;
|
2017-10-21 04:37:01 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else {
|
2020-05-27 00:51:48 +02:00
|
|
|
await electron_1.shell.openExternal(url).catch((e) => {
|
|
|
|
|
result = e.message;
|
2019-05-16 03:13:35 +02:00
|
|
|
});
|
2017-10-21 04:37:01 +02:00
|
|
|
}
|
2020-05-27 00:51:48 +02:00
|
|
|
electronSocket.emit('shell-openExternalCompleted', result);
|
2017-10-21 04:37:01 +02:00
|
|
|
});
|
2021-07-02 02:04:23 +02:00
|
|
|
socket.on('shell-trashItem', async (fullPath, deleteOnFail) => {
|
|
|
|
|
let success = false;
|
|
|
|
|
try {
|
|
|
|
|
await electron_1.shell.trashItem(fullPath);
|
|
|
|
|
success = true;
|
|
|
|
|
}
|
|
|
|
|
catch (error) {
|
|
|
|
|
success = false;
|
|
|
|
|
}
|
|
|
|
|
electronSocket.emit('shell-trashItem-completed', success);
|
2017-10-21 04:37:01 +02:00
|
|
|
});
|
2019-01-05 02:17:31 +01:00
|
|
|
socket.on('shell-beep', () => {
|
2017-10-21 04:37:01 +02:00
|
|
|
electron_1.shell.beep();
|
|
|
|
|
});
|
2019-01-05 02:17:31 +01:00
|
|
|
socket.on('shell-writeShortcutLink', (shortcutPath, operation, options) => {
|
|
|
|
|
const success = electron_1.shell.writeShortcutLink(shortcutPath, operation, options);
|
2019-04-18 18:03:17 +01:00
|
|
|
electronSocket.emit('shell-writeShortcutLinkCompleted', success);
|
2017-10-21 04:37:01 +02:00
|
|
|
});
|
2019-01-05 02:17:31 +01:00
|
|
|
socket.on('shell-readShortcutLink', (shortcutPath) => {
|
|
|
|
|
const shortcutDetails = electron_1.shell.readShortcutLink(shortcutPath);
|
2019-04-18 18:03:17 +01:00
|
|
|
electronSocket.emit('shell-readShortcutLinkCompleted', shortcutDetails);
|
2017-10-21 04:37:01 +02:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
//# sourceMappingURL=shell.js.map
|