mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-09 00:11:30 +01:00
Change download to happen in the renderer (#365)
This commit is contained in:
parent
4eb50d757d
commit
672d07e1e2
@ -19,17 +19,6 @@ export class ElectronMainMessagingService implements MessagingService {
|
|||||||
return dialog.showMessageBox(options);
|
return dialog.showMessageBox(options);
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle('saveFile', (event, options) => {
|
|
||||||
dialog.showSaveDialog(windowMain.win, {
|
|
||||||
defaultPath: options.fileName,
|
|
||||||
showsTagField: false,
|
|
||||||
}).then(ret => {
|
|
||||||
if (ret.filePath != null) {
|
|
||||||
fs.writeFile(ret.filePath, options.buffer, { mode: 0o600 });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcMain.handle('openContextMenu', (event, options: {menu: RendererMenuItem[]}) => {
|
ipcMain.handle('openContextMenu', (event, options: {menu: RendererMenuItem[]}) => {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const menu = new Menu();
|
const menu = new Menu();
|
||||||
|
@ -97,10 +97,13 @@ export class ElectronPlatformUtilsService implements PlatformUtilsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
saveFile(win: Window, blobData: any, blobOptions: any, fileName: string): void {
|
saveFile(win: Window, blobData: any, blobOptions: any, fileName: string): void {
|
||||||
ipcRenderer.invoke('saveFile', {
|
const blob = new Blob([blobData], blobOptions);
|
||||||
fileName: fileName,
|
const a = win.document.createElement('a');
|
||||||
buffer: Buffer.from(blobData),
|
a.href = URL.createObjectURL(blob);
|
||||||
});
|
a.download = fileName;
|
||||||
|
win.document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
win.document.body.removeChild(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
getApplicationVersion(): Promise<string> {
|
getApplicationVersion(): Promise<string> {
|
||||||
|
Loading…
Reference in New Issue
Block a user