49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
import { app, BrowserWindow, ipcMain } from 'electron';
|
|
import { join } from 'path';
|
|
import { writeFile } from 'fs/promises';
|
|
import Store from 'electron-store';
|
|
|
|
const store = new Store();
|
|
|
|
async function createWindow() {
|
|
const mainWindow = new BrowserWindow({
|
|
width: 1200,
|
|
height: 800,
|
|
webPreferences: {
|
|
nodeIntegration: true,
|
|
contextIsolation: false
|
|
}
|
|
});
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
mainWindow.loadURL('http://localhost:5173');
|
|
} else {
|
|
mainWindow.loadFile(join(__dirname, '../dist/index.html'));
|
|
}
|
|
}
|
|
|
|
app.whenReady().then(createWindow);
|
|
|
|
app.on('window-all-closed', () => {
|
|
if (process.platform !== 'darwin') {
|
|
app.quit();
|
|
}
|
|
});
|
|
|
|
app.on('activate', () => {
|
|
if (BrowserWindow.getAllWindows().length === 0) {
|
|
createWindow();
|
|
}
|
|
});
|
|
|
|
// Handle audio chunk saves
|
|
ipcMain.handle('save-audio-chunk', async (event, { buffer, fileName }) => {
|
|
try {
|
|
const savePath = join(app.getPath('documents'), 'PodcastRecordings', fileName);
|
|
await writeFile(savePath, Buffer.from(buffer));
|
|
return { success: true, path: savePath };
|
|
} catch (error) {
|
|
console.error('Failed to save audio chunk:', error);
|
|
return { success: false, error: error.message };
|
|
}
|
|
}); |