feat: Add persistence for loaded file, scroll position, speed, and font size.
This commit is contained in:
+22
@@ -62,3 +62,25 @@ ipcMain.handle('read-file', async (event, filePath: string) => {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
|
||||
const configPath = path.join(app.getPath('userData'), 'config.json');
|
||||
|
||||
ipcMain.handle('load-settings', async () => {
|
||||
try {
|
||||
if (fs.existsSync(configPath)) {
|
||||
const data = fs.readFileSync(configPath, 'utf-8');
|
||||
return JSON.parse(data);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load settings:', error);
|
||||
}
|
||||
return {};
|
||||
});
|
||||
|
||||
ipcMain.handle('save-settings', async (event, settings) => {
|
||||
try {
|
||||
fs.writeFileSync(configPath, JSON.stringify(settings, null, 2));
|
||||
} catch (error) {
|
||||
console.error('Failed to save settings:', error);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user