|
| 1 | +"use strict"; |
| 2 | +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { |
| 3 | + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
| 4 | + return new (P || (P = Promise))(function (resolve, reject) { |
| 5 | + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |
| 6 | + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |
| 7 | + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } |
| 8 | + step((generator = generator.apply(thisArg, _arguments || [])).next()); |
| 9 | + }); |
| 10 | +}; |
| 11 | +var __importDefault = (this && this.__importDefault) || function (mod) { |
| 12 | + return (mod && mod.__esModule) ? mod : { "default": mod }; |
| 13 | +}; |
| 14 | +Object.defineProperty(exports, "__esModule", { value: true }); |
| 15 | +const express_1 = __importDefault(require("express")); |
| 16 | +const electron_1 = require("electron"); |
| 17 | +const router = express_1.default.Router(); |
| 18 | +router.post("/show-item-in-folder", (req, res) => { |
| 19 | + const { path } = req.body; |
| 20 | + electron_1.shell.showItemInFolder(path); |
| 21 | + res.sendStatus(200); |
| 22 | +}); |
| 23 | +router.post("/open-item", (req, res) => __awaiter(void 0, void 0, void 0, function* () { |
| 24 | + const { path } = req.body; |
| 25 | + let result = yield electron_1.shell.openPath(path); |
| 26 | + res.json({ |
| 27 | + result |
| 28 | + }); |
| 29 | +})); |
| 30 | +router.post("/open-external", (req, res) => __awaiter(void 0, void 0, void 0, function* () { |
| 31 | + const { url } = req.body; |
| 32 | + try { |
| 33 | + yield electron_1.shell.openExternal(url); |
| 34 | + res.sendStatus(200); |
| 35 | + } |
| 36 | + catch (e) { |
| 37 | + res.status(500).json({ |
| 38 | + error: e |
| 39 | + }); |
| 40 | + } |
| 41 | +})); |
| 42 | +router.delete("/trash-item", (req, res) => __awaiter(void 0, void 0, void 0, function* () { |
| 43 | + const { path } = req.body; |
| 44 | + try { |
| 45 | + yield electron_1.shell.trashItem(path); |
| 46 | + res.sendStatus(200); |
| 47 | + } |
| 48 | + catch (e) { |
| 49 | + res.status(400).json(); |
| 50 | + } |
| 51 | +})); |
| 52 | +exports.default = router; |
0 commit comments