gui: add form fields to edit config

This commit is contained in:
thePR0M3TH3AN
2025-06-21 15:00:47 -04:00
parent 13f276e4fe
commit c0add37e60
3 changed files with 50 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ const { app, BrowserWindow, ipcMain, dialog } = require('electron');
const { spawn } = require('child_process');
const path = require('path');
const which = require('which');
const fs = require('fs');
let mainWindow;
@@ -18,7 +19,21 @@ function createWindow() {
app.whenReady().then(createWindow);
ipcMain.handle('run-quickstart', async () => {
function getConfigPath() {
return path.join(__dirname, '..', '..', 'voxvera', 'src', 'config.json');
}
ipcMain.handle('load-config', async () => {
const p = getConfigPath();
const raw = fs.readFileSync(p, 'utf8');
return JSON.parse(raw);
});
ipcMain.handle('run-quickstart', async (_, config) => {
const configPath = getConfigPath();
if (config && typeof config === 'object') {
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
}
const voxveraPath = which.sync('voxvera', { nothrow: true });
if (!voxveraPath) {
dialog.showErrorBox(
@@ -28,7 +43,7 @@ ipcMain.handle('run-quickstart', async () => {
return -1;
}
return new Promise((resolve, reject) => {
const proc = spawn(voxveraPath, ['quickstart']);
const proc = spawn(voxveraPath, ['--config', configPath, 'quickstart']);
proc.stdout.on('data', data => {
const line = data.toString();
process.stdout.write(line);