mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-16 16:04:56 +00:00
leanote protocol移到main进程, 所有图片的操作通过db_client进行操作
This commit is contained in:
37
node_modules/db_client.js
generated
vendored
Normal file
37
node_modules/db_client.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* db_main的db client, 调用db client即会调用后端的db_main
|
||||
*/
|
||||
|
||||
var DatastoreProxy = require('nedb_proxy');
|
||||
var path = require('path');
|
||||
var Evt = require('evt');
|
||||
var ipc = require('ipc');
|
||||
|
||||
|
||||
var dbPath = Evt.getBasePath() + '/nedb55';
|
||||
if(dbPath.length < 6) {
|
||||
var dbPath = '/Users/life/Library/Application Support/Leanote' + '/nedb2';
|
||||
}
|
||||
|
||||
// console.log(dbPath);
|
||||
// g, 表全局环境
|
||||
var db = {};
|
||||
var dbNames = ['images']; // 现在只有images表在后台控制
|
||||
for(var i in dbNames) {
|
||||
var name = dbNames[i];
|
||||
(function (name) {
|
||||
db[name] = new DatastoreProxy(name);
|
||||
})(name);
|
||||
}
|
||||
|
||||
// 在db.js的initForUser时调用
|
||||
// 初始化, 给后端发消息
|
||||
db.init = function (curUser, dbPath) {
|
||||
ipc.send('db-init', {
|
||||
curUser: curUser,
|
||||
dbPath: dbPath
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = db;
|
||||
console.log('db inited');
|
Reference in New Issue
Block a user