mirror of
https://github.com/colanode/colanode.git
synced 2025-12-29 00:25:03 +01:00
Implement save file (#108)
* Implement save file * Delete locally downloaded files that have not been opened in last 7 days
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
protocol,
|
||||
shell,
|
||||
globalShortcut,
|
||||
dialog,
|
||||
} from 'electron';
|
||||
|
||||
import started from 'electron-squirrel-startup';
|
||||
@@ -251,3 +252,22 @@ ipcMain.handle(
|
||||
ipcMain.handle('open-external-url', (_, url: string) => {
|
||||
shell.openExternal(url);
|
||||
});
|
||||
|
||||
ipcMain.handle('show-item-in-folder', (_, path: string) => {
|
||||
shell.showItemInFolder(path);
|
||||
});
|
||||
|
||||
ipcMain.handle(
|
||||
'show-file-save-dialog',
|
||||
async (_, { name }: { name: string }) => {
|
||||
const result = await dialog.showSaveDialog({
|
||||
defaultPath: name,
|
||||
});
|
||||
|
||||
if (result.canceled) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return result.filePath;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -55,6 +55,14 @@ contextBridge.exposeInMainWorld('colanode', {
|
||||
openExternalUrl: async (url: string) => {
|
||||
return ipcRenderer.invoke('open-external-url', url);
|
||||
},
|
||||
|
||||
showItemInFolder: async (path: string) => {
|
||||
return ipcRenderer.invoke('show-item-in-folder', path);
|
||||
},
|
||||
|
||||
showFileSaveDialog: async ({ name }: { name: string }) => {
|
||||
return ipcRenderer.invoke('show-file-save-dialog', { name });
|
||||
},
|
||||
});
|
||||
|
||||
contextBridge.exposeInMainWorld('eventBus', {
|
||||
|
||||
Reference in New Issue
Block a user