diff options
Diffstat (limited to 'src/index.js')
-rw-r--r-- | src/index.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/index.js b/src/index.js index ebea48f..0babcea 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,6 @@ +const fs = require("fs"); const path = require("path"); -const { app, BrowserWindow } = require("electron"); +const { app, dialog, ipcMain, BrowserWindow } = require("electron"); function start() { win = new BrowserWindow({ @@ -16,6 +17,14 @@ function start() { win.removeMenu(); win.loadFile(__dirname + "/app/index.html"); win.webContents.once("dom-ready", () => {win.show()}); + + ipcMain.on("setpath", (event) => { + dialog.showOpenDialog({properties: ["openDirectory"]}).then(res => { + fs.writeFileSync(app.getPath("appData") + "/viper.json", JSON.stringify({path: res.filePaths[0]})) + + win.webContents.send("newpath", res.filePaths[0]); + }).catch(err => {console.error(err)}) + }) } app.on("ready", () => { @@ -23,4 +32,3 @@ app.on("ready", () => { app.setPath("userData", path.join(app.getPath("cache"), app.name)); start(); }) - |