From 555fcfeda8a3b7de374b05e37bdb29e094d7206a Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Fri, 30 Mar 2018 00:21:40 +0530 Subject: [PATCH] Add electron client --- client/electron.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 client/electron.js diff --git a/client/electron.js b/client/electron.js new file mode 100644 index 00000000..1c25cd02 --- /dev/null +++ b/client/electron.js @@ -0,0 +1,36 @@ +const common = require('frappejs/common'); +const sqlite = require('frappejs/backends/sqlite'); +const frappe = require('frappejs'); +frappe.ui = require('./ui'); +const Desk = require('./desk'); +const Observable = require('frappejs/utils/observable'); + +module.exports = { + async start({dbPath, columns = 3, models}) { + window.frappe = frappe; + frappe.init(); + + frappe.registerLibs(common); + frappe.registerModels(require('frappejs/models')); + + if (models) { + frappe.registerModels(models); + } + + frappe.db = await new sqlite({ dbPath }); + await frappe.db.connect(); + await frappe.db.migrate(); + + frappe.fetch = window.fetch.bind(); + + frappe.docs = new Observable(); + + await frappe.getSingle('SystemSettings'); + + frappe.desk = new Desk(columns); + await frappe.login(); + + return frappe; + } +}; +