diff --git a/electron/config/config.local.js b/electron/config/config.local.js index a79eff2..9b63737 100644 --- a/electron/config/config.local.js +++ b/electron/config/config.local.js @@ -10,7 +10,7 @@ module.exports = (appInfo) => { * 开发者工具 */ config.openDevTools = { - mode: 'bottom' + mode: 'undocked' }; /** diff --git a/electron/config/config.prod.js b/electron/config/config.prod.js index 09b5d36..cc58f5b 100644 --- a/electron/config/config.prod.js +++ b/electron/config/config.prod.js @@ -10,7 +10,7 @@ module.exports = (appInfo) => { * 开发者工具 */ config.openDevTools = { - mode: 'bottom' + mode: 'undocked' }; /** diff --git a/electron/controller/framework.js b/electron/controller/framework.js index acc9fa2..c60993c 100644 --- a/electron/controller/framework.js +++ b/electron/controller/framework.js @@ -33,7 +33,7 @@ class FrameworkController extends Controller { * json数据库操作 */ async jsondbOperation(args) { - const { action, info, delete_name, update_name, update_age, search_age } = args; + const { action, info, delete_name, update_name, update_age, search_age, data_dir } = args; const data = { action, @@ -54,6 +54,12 @@ class FrameworkController extends Controller { case 'get' : data.result = await Services.get('database.jsondb').getTestData(search_age); break; + case 'getDataDir' : + data.result = await Services.get('database.jsondb').getDataDir(); + break; + case 'setDataDir' : + data.result = await Services.get('database.jsondb').setCustomDataDir(data_dir); + break; } data.all_list = await Services.get('database.jsondb').getAllTestData(); @@ -65,7 +71,7 @@ class FrameworkController extends Controller { * sqlite数据库操作 */ async sqlitedbOperation(args) { - const { action, info, delete_name, update_name, update_age, search_age } = args; + const { action, info, delete_name, update_name, update_age, search_age, data_dir } = args; const data = { action, diff --git a/electron/service/database/jsondb.js b/electron/service/database/jsondb.js index 724123b..7c6cc6d 100644 --- a/electron/service/database/jsondb.js +++ b/electron/service/database/jsondb.js @@ -3,6 +3,7 @@ const { Service } = require('ee-core'); const Storage = require('ee-core/storage'); const _ = require('lodash'); +const path = require('path'); /** * json数据存储 @@ -14,7 +15,8 @@ class JsondbService extends Service { super(ctx); // jsondb数据库 - this.demoDB = Storage.connection('demo'); + this.jsonFile = 'demo'; + this.demoDB = Storage.connection(this.jsonFile); this.demoDBKey = { test_data: 'test_data' }; @@ -106,6 +108,30 @@ class JsondbService extends Service { return data; } + + /* + * get data dir (sqlite) + */ + async getDataDir() { + const dir = this.demoDB.getStorageDir(); + + return dir; + } + + /* + * set custom data dir (sqlite) + */ + async setCustomDataDir(dir) { + if (_.isEmpty(dir)) { + return; + } + + // the absolute path of the db file + const dbFile = path.join(dir, this.jsonFile); + this.demoDB = Storage.connection(dbFile); + + return; + } } JsondbService.toString = () => '[class JsondbService]'; diff --git a/frontend/src/views/framework/jsondb/Index.vue b/frontend/src/views/framework/jsondb/Index.vue index 7b3105f..4e86563 100644 --- a/frontend/src/views/framework/jsondb/Index.vue +++ b/frontend/src/views/framework/jsondb/Index.vue @@ -20,7 +20,31 @@