diff --git a/data/user1/images/1421585423218_2.png b/data/user1/images/1421585423218_2.png deleted file mode 100644 index 44fc9d31..00000000 Binary files a/data/user1/images/1421585423218_2.png and /dev/null differ diff --git a/data/user1/images/1421585491332_2.png b/data/user1/images/1421585491332_2.png deleted file mode 100644 index 88645069..00000000 Binary files a/data/user1/images/1421585491332_2.png and /dev/null differ diff --git a/data/user1/images/1421585995435_2.png b/data/user1/images/1421585995435_2.png deleted file mode 100644 index a8302466..00000000 Binary files a/data/user1/images/1421585995435_2.png and /dev/null differ diff --git a/data/user1/images/1421586033786_3.png b/data/user1/images/1421586033786_3.png deleted file mode 100644 index 94db89b6..00000000 Binary files a/data/user1/images/1421586033786_3.png and /dev/null differ diff --git a/data/user1/images/1421589400210_2.png b/data/user1/images/1421589400210_2.png deleted file mode 100644 index 1c31d882..00000000 Binary files a/data/user1/images/1421589400210_2.png and /dev/null differ diff --git a/data/user1/images/1421589444583_3.png b/data/user1/images/1421589444583_3.png deleted file mode 100644 index 41c61821..00000000 Binary files a/data/user1/images/1421589444583_3.png and /dev/null differ diff --git a/data/user1/images/1421589464023_4.png b/data/user1/images/1421589464023_4.png deleted file mode 100644 index 3cdf7a01..00000000 Binary files a/data/user1/images/1421589464023_4.png and /dev/null differ diff --git a/data/user1/images/a.png b/data/user1/images/a.png deleted file mode 100644 index 18bdf82e..00000000 Binary files a/data/user1/images/a.png and /dev/null differ diff --git a/data/user1/images/b.png b/data/user1/images/b.png deleted file mode 100644 index a5fdbc40..00000000 Binary files a/data/user1/images/b.png and /dev/null differ diff --git a/node_modules/db.js b/node_modules/db.js index 01fcab3e..4d8da36c 100644 --- a/node_modules/db.js +++ b/node_modules/db.js @@ -2,7 +2,7 @@ var Datastore = require('nedb'); var path = require('path'); // 数据库初始化 -// var dbPath = require('nw.gui').App.dataPath + '/nedb' +// var dbPath = require('nw.gui').App.dataPath + '/nedb'; var dbPath = '/Users/life/Library/Application Support/Leanote' + '/nedb'; var db = {}; var dbNames = ['notebooks', 'notes', 'users', 'tags', 'images', 'attachs', 'noteHistories']; diff --git a/node_modules/evt.js b/node_modules/evt.js index b54cf7cf..da2308c1 100644 --- a/node_modules/evt.js +++ b/node_modules/evt.js @@ -1,7 +1,20 @@ var fs = require('fs'); var User = require('user'); -function log(o) {console.log(o)} +function log(o) { + console.log(o); +}; + +// 为什么不存在? +// var dataBasePath = require('nw.gui').App.dataPath; // + '/data'; +/* +// 判断是否存在, 不存在则创建dir +if(!fs.existsSync(dataBasePath)) { + fs.mkdirSync(dataBasePath); +} +*/ +dataBasePath = ''; + var Evt = { leanoteUrl: 'http://localhost:9000', port: 8008, @@ -14,6 +27,7 @@ var Evt = { }, // 项目绝对地址 getBasePath: function() { + // return dataBasePath; // process.cwd(); return process.cwd(); }, getAbsolutePath: function(relative) { diff --git a/node_modules/user.js b/node_modules/user.js index dc303535..7c780319 100644 --- a/node_modules/user.js +++ b/node_modules/user.js @@ -1,5 +1,6 @@ var Evt = require('evt'); var db = require('db'); +var fs = require('fs'); function log(o) { console.log(o); @@ -33,6 +34,9 @@ User = { this.username = user.Username; // 保存到数据库中 this.saveCurUser(user); + + // 判断当前用户是否有文件夹 + me.setUserDataPath(); } }, saveCurUser: function(user, callback) { @@ -82,7 +86,7 @@ User = { var me = this; db.users.findOne({IsActive: true}, function(err, user) { if(err || !user || !user.UserId) { - log('不存在'); + console.log('不存在'); callback && callback(false); } else { // me.setCurUser(doc); @@ -93,6 +97,9 @@ User = { me.LastSyncUsn = user.LastSyncUsn; me.LastSyncTime = user.LastSyncTime; + // 设置当前用户数据路径 + me.setUserDataPath(); + callback && callback(user); } }); @@ -117,6 +124,29 @@ User = { return 'data/' + this.getCurActiveUserId() + '/attachs'; }, + setUserDataPath: function(userId) { + var me = this; + // 判断是否存在, 不存在则创建dir + try { + fs.mkdirSync(Evt.getBasePath() + '/data/'); + } + catch(e) {}; + try { + fs.mkdirSync(Evt.getBasePath() + '/data/' + this.getCurActiveUserId()); + } catch(e) { + } + try { + fs.mkdirSync(Evt.getBasePath() + '/data/' + this.getCurActiveUserId() + '/images'); + } catch(e) { + } + try { + fs.mkdirSync(Evt.getBasePath() + '/data/' + this.getCurActiveUserId() + '/attachs'); + } catch(e) { + console.log("eeeeeeeeeeeeeeeeee...........") + console.log(e); + } + }, + getCurUser: function(callback) { var me = this; db.users.findOne({_id: me.getCurActiveUserId()}, function(err, doc) { diff --git a/public/js/app/note.js b/public/js/app/note.js index c63825b7..f316ebc2 100644 --- a/public/js/app/note.js +++ b/public/js/app/note.js @@ -1260,7 +1260,6 @@ Note.listNoteContentHistories = function() { hideDialog(); } }); - }); }