mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
Download File Option (#80)
This adds to the context menu to give the ability to download a file. It also fixes a couple bugs and improves some formatting of the directory view.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// Copyright 2024, Command Line Inc.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { getBackendHostPort } from "@/app/store/global";
|
||||
import * as keyutil from "@/util/keyutil";
|
||||
import * as electron from "electron";
|
||||
import fs from "fs";
|
||||
@@ -421,6 +422,13 @@ electron.ipcMain.on("getPlatform", (event) => {
|
||||
event.returnValue = unamePlatform;
|
||||
});
|
||||
|
||||
electron.ipcMain.on("download", (event, payload) => {
|
||||
const window = electron.BrowserWindow.fromWebContents(event.sender);
|
||||
const baseName = payload.filePath.split(/[\\/]/).pop();
|
||||
const streamingUrl = getBackendHostPort() + "/wave/stream-file?path=" + encodeURIComponent(payload.filePath);
|
||||
window.webContents.downloadURL(streamingUrl);
|
||||
});
|
||||
|
||||
electron.ipcMain.on("getCursorPoint", (event) => {
|
||||
const window = electron.BrowserWindow.fromWebContents(event.sender);
|
||||
const screenPoint = electron.screen.getCursorScreenPoint();
|
||||
|
||||
@@ -11,4 +11,5 @@ contextBridge.exposeInMainWorld("api", {
|
||||
openNewWindow: () => ipcRenderer.send("openNewWindow"),
|
||||
showContextMenu: (menu, position) => ipcRenderer.send("contextmenu-show", menu, position),
|
||||
onContextMenuClick: (callback) => ipcRenderer.on("contextmenu-click", callback),
|
||||
downloadFile: (filePath) => ipcRenderer.send("download", { filePath }),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user