mirror of
https://github.com/Gabi-Zar/Silk-Fly-Launcher.git
synced 2026-04-17 05:26:04 +02:00
change indentation and add import config
This commit is contained in:
15
main.js
15
main.js
@@ -78,3 +78,18 @@ ipcMain.handle('export-data', async () => {
|
|||||||
|
|
||||||
await fs.copyFile(dataPath, filePath)
|
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)
|
||||||
|
})
|
||||||
@@ -7,10 +7,8 @@ contextBridge.exposeInMainWorld('versions', {
|
|||||||
});
|
});
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld('save', {
|
contextBridge.exposeInMainWorld('save', {
|
||||||
saveSilksongPath: (path) =>
|
saveSilksongPath: (path) => ipcRenderer.invoke('save-path', path),
|
||||||
ipcRenderer.invoke('save-path', path),
|
loadSilksongPath: () => ipcRenderer.invoke('load-path')
|
||||||
loadSilksongPath: () =>
|
|
||||||
ipcRenderer.invoke('load-path')
|
|
||||||
});
|
});
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld('files', {
|
contextBridge.exposeInMainWorld('files', {
|
||||||
@@ -18,5 +16,5 @@ contextBridge.exposeInMainWorld('files', {
|
|||||||
userSavePath: () => ipcRenderer.invoke('get-userSavePath'),
|
userSavePath: () => ipcRenderer.invoke('get-userSavePath'),
|
||||||
delete: (path) => ipcRenderer.invoke('delete-data', path),
|
delete: (path) => ipcRenderer.invoke('delete-data', path),
|
||||||
export: () => ipcRenderer.invoke('export-data'),
|
export: () => ipcRenderer.invoke('export-data'),
|
||||||
import: (data) => ipcRenderer.invoke('import-data', data)
|
import: () => ipcRenderer.invoke('import-data')
|
||||||
});
|
});
|
||||||
@@ -74,8 +74,14 @@ async function autoDetectGamePath() {
|
|||||||
|
|
||||||
async function deleteData() {
|
async function deleteData() {
|
||||||
await files.delete(savePath)
|
await files.delete(savePath)
|
||||||
|
document.getElementById("silksong-path-input").value = await save.loadSilksongPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function exportData() {
|
async function exportData() {
|
||||||
await files.export()
|
await files.export()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function importData() {
|
||||||
|
await files.import()
|
||||||
|
document.getElementById("silksong-path-input").value = await save.loadSilksongPath()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user