fix: save goosehints in the UI (#1983)
This commit is contained in:
+35
-35
@@ -426,6 +426,41 @@ ipcMain.handle('get-binary-path', (event, binaryName) => {
|
|||||||
return getBinaryPath(app, binaryName);
|
return getBinaryPath(app, binaryName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.handle('read-file', (event, filePath) => {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
exec(`cat ${filePath}`, (error, stdout, stderr) => {
|
||||||
|
if (error) {
|
||||||
|
// File not found
|
||||||
|
resolve({ file: '', filePath, error: null, found: false });
|
||||||
|
}
|
||||||
|
if (stderr) {
|
||||||
|
console.error('Error output:', stderr);
|
||||||
|
resolve({ file: '', filePath, error, found: false });
|
||||||
|
}
|
||||||
|
resolve({ file: stdout, filePath, error: null, found: true });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.handle('write-file', (event, filePath, content) => {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const command = `cat << 'EOT' > ${filePath}
|
||||||
|
${content}
|
||||||
|
EOT`;
|
||||||
|
exec(command, (error, stdout, stderr) => {
|
||||||
|
if (error) {
|
||||||
|
console.error('Error writing to file:', error);
|
||||||
|
resolve(false);
|
||||||
|
}
|
||||||
|
if (stderr) {
|
||||||
|
console.error('Error output:', stderr);
|
||||||
|
resolve(false);
|
||||||
|
}
|
||||||
|
resolve(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
app.whenReady().then(async () => {
|
app.whenReady().then(async () => {
|
||||||
session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
|
session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
|
||||||
details.requestHeaders['Origin'] = 'http://localhost:5173';
|
details.requestHeaders['Origin'] = 'http://localhost:5173';
|
||||||
@@ -647,41 +682,6 @@ app.whenReady().then(async () => {
|
|||||||
spawn('xdg-open', [url]);
|
spawn('xdg-open', [url]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle('read-file', (event, filePath) => {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
exec(`cat ${filePath}`, (error, stdout, stderr) => {
|
|
||||||
if (error) {
|
|
||||||
// File not found
|
|
||||||
resolve({ file: '', filePath, error: null, found: false });
|
|
||||||
}
|
|
||||||
if (stderr) {
|
|
||||||
console.error('Error output:', stderr);
|
|
||||||
resolve({ file: '', filePath, error, found: false });
|
|
||||||
}
|
|
||||||
resolve({ file: stdout, filePath, error: null, found: true });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcMain.handle('write-file', (event, filePath, content) => {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
const command = `cat << 'EOT' > ${filePath}
|
|
||||||
${content}
|
|
||||||
EOT`;
|
|
||||||
exec(command, (error, stdout, stderr) => {
|
|
||||||
if (error) {
|
|
||||||
console.error('Error writing to file:', error);
|
|
||||||
resolve(false);
|
|
||||||
}
|
|
||||||
if (stderr) {
|
|
||||||
console.error('Error output:', stderr);
|
|
||||||
resolve(false);
|
|
||||||
}
|
|
||||||
resolve(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Quit when all windows are closed, except on macOS.
|
// Quit when all windows are closed, except on macOS.
|
||||||
|
|||||||
Reference in New Issue
Block a user