import { app, dialog, ipcMain } from "electron"; import * as fs from 'fs'; import * as path from 'path'; ipcMain.handle('save-txt-file', async (event, { name, title, content }) => { const { filePath } = await dialog.showSaveDialog({ title, defaultPath: path.join(app.getPath('documents'), `${name}.txt`), filters: [{ name: 'Text Files', extensions: ['txt'] }], }); if (filePath) { fs.writeFileSync(filePath, content, 'utf-8'); return { success: true, filePath }; } else { return { success: false }; } });