improve config panel and file saving/export/delete

This commit is contained in:
2026-01-16 23:50:27 +01:00
parent b69a0c1b2d
commit 0b5ee51ebd
5 changed files with 74 additions and 11 deletions

24
main.js
View File

@@ -1,4 +1,4 @@
const { app, BrowserWindow , ipcMain} = require('electron/main');
const { app, BrowserWindow , ipcMain, dialog} = require('electron/main');
const path = require('node:path');
const Store = require('electron-store').default;
const fs = require('fs/promises');
@@ -57,4 +57,24 @@ ipcMain.handle('file-exists', async (_, filePath) => {
ipcMain.handle('get-userSavePath', () => {
return userSavePath
});
});
ipcMain.handle('delete-data', async (event, path) => {
await fs.unlink(path)
});
ipcMain.handle('export-data', async () => {
const dataPath = `${userSavePath}\\config.json`
const { canceled, filePath } = await dialog.showSaveDialog({
title: 'Export Data',
defaultPath: 'config.json',
filters: [
{ name: 'JSON', extensions: ['json'] }
]
})
if (canceled || !filePath) return
await fs.copyFile(dataPath, filePath)
})