mirror of
https://github.com/Gabi-Zar/Silk-Fly-Launcher.git
synced 2026-04-17 05:26:04 +02:00
improve config panel and file saving/export/delete
This commit is contained in:
24
main.js
24
main.js
@@ -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)
|
||||
})
|
||||
Reference in New Issue
Block a user