-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
411 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,63 @@ | ||
const { app, BrowserWindow, ipcMain } = require('electron') | ||
const path = require('path') | ||
const sqlite = require('sqlite-electron') | ||
const { app, BrowserWindow, ipcMain } = require("electron"); | ||
const { join } = require("path"); | ||
const { setdbPath, executeQuery, executeMany, executeScript } = require("sqlite-electron"); | ||
|
||
function createWindow () { | ||
function createWindow() { | ||
const win = new BrowserWindow({ | ||
width: 800, | ||
height: 600, | ||
webPreferences: { | ||
preload: path.join(__dirname, 'preload.js') | ||
} | ||
}) | ||
preload: join(__dirname, "preload.js"), | ||
}, | ||
}); | ||
|
||
win.loadFile('index.html') | ||
win.loadFile("index.html"); | ||
} | ||
app.enableSandbox() | ||
app.enableSandbox(); | ||
app.whenReady().then(() => { | ||
sqlite.dbPath = 'test.db'; | ||
createWindow() | ||
createWindow(); | ||
|
||
app.on('activate', () => { | ||
app.on("activate", () => { | ||
if (BrowserWindow.getAllWindows().length === 0) { | ||
createWindow() | ||
createWindow(); | ||
} | ||
}) | ||
}) | ||
}); | ||
}); | ||
|
||
app.on('window-all-closed', () => { | ||
if (process.platform !== 'darwin') { | ||
app.quit() | ||
app.on("window-all-closed", () => { | ||
if (process.platform !== "darwin") { | ||
app.quit(); | ||
} | ||
}) | ||
|
||
ipcMain.handle('potd', (event, dbPath) => { | ||
sqlite.dbPath = dbPath | ||
return true | ||
}) | ||
}); | ||
|
||
ipcMain.handle('executeQuery', async (event, query, fetch, value) => { | ||
ipcMain.handle("potd", async (event, dbPath) => { | ||
try { | ||
return await sqlite.executeQuery(query, fetch, value); | ||
return await setdbPath(dbPath) | ||
} catch (error) { | ||
return error | ||
} | ||
}) | ||
}); | ||
|
||
ipcMain.handle('executeMany', async (event, query, values) => { | ||
ipcMain.handle("executeQuery", async (event, query, fetch, value) => { | ||
try { | ||
return await sqlite.executeMany(query, values) | ||
return await executeQuery(query, fetch, value); | ||
} catch (error) { | ||
return error | ||
return error; | ||
} | ||
}) | ||
}); | ||
|
||
ipcMain.handle('executeScript', async (event, scriptpath) => { | ||
ipcMain.handle("executeMany", async (event, query, values) => { | ||
try { | ||
return await sqlite.executeScript(scriptpath); | ||
return await executeMany(query, values); | ||
} catch (error) { | ||
return error | ||
return error; | ||
} | ||
}); | ||
|
||
ipcMain.handle("executeScript", async (event, scriptpath) => { | ||
try { | ||
return await executeScript(scriptpath); | ||
} catch (error) { | ||
return error; | ||
} | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
{ | ||
"name": "test", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "electron .", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"author": "Motagamwala Taha Arif Ali", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"electron": "^19.0.6", | ||
"electron-packager": "^15.5.1" | ||
}, | ||
"dependencies": { | ||
"sqlite-electron": "^2.0.5" | ||
"electron": "^21.2.2", | ||
"electron-packager": "^17.1.1" | ||
}, | ||
"browser": { | ||
"fs": false, | ||
"path": false, | ||
"os": false | ||
}, | ||
"dependencies": { | ||
"sqlite-electron": "^2.2.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.