change indentation and add import config

This commit is contained in:
2026-01-19 12:23:16 +01:00
parent 0b5ee51ebd
commit 11ac159909
5 changed files with 322 additions and 303 deletions

15
main.js
View File

@@ -78,3 +78,18 @@ ipcMain.handle('export-data', async () => {
await fs.copyFile(dataPath, filePath)
})
ipcMain.handle('import-data', async () => {
const dataPath = `${userSavePath}\\config.json`
const { canceled, filePaths } = await dialog.showOpenDialog({
title: 'Import Data',
properties: ['openFile'],
filters: [{ name: 'JSON', extensions: ['json'] }]
})
if (canceled || !filePaths) return
await fs.unlink(dataPath)
await fs.copyFile(filePaths[0], dataPath,fs.constants.COPYFILE_EXCL)
})

View File

@@ -7,10 +7,8 @@ contextBridge.exposeInMainWorld('versions', {
});
contextBridge.exposeInMainWorld('save', {
saveSilksongPath: (path) =>
ipcRenderer.invoke('save-path', path),
loadSilksongPath: () =>
ipcRenderer.invoke('load-path')
saveSilksongPath: (path) => ipcRenderer.invoke('save-path', path),
loadSilksongPath: () => ipcRenderer.invoke('load-path')
});
contextBridge.exposeInMainWorld('files', {
@@ -18,5 +16,5 @@ contextBridge.exposeInMainWorld('files', {
userSavePath: () => ipcRenderer.invoke('get-userSavePath'),
delete: (path) => ipcRenderer.invoke('delete-data', path),
export: () => ipcRenderer.invoke('export-data'),
import: (data) => ipcRenderer.invoke('import-data', data)
import: () => ipcRenderer.invoke('import-data')
});

View File

@@ -74,8 +74,14 @@ async function autoDetectGamePath() {
async function deleteData() {
await files.delete(savePath)
document.getElementById("silksong-path-input").value = await save.loadSilksongPath()
}
async function exportData() {
await files.export()
}
async function importData() {
await files.import()
document.getElementById("silksong-path-input").value = await save.loadSilksongPath()
}