diff --git a/node_modules/user.js b/node_modules/user.js
index b8c79a7b..fa63c186 100644
--- a/node_modules/user.js
+++ b/node_modules/user.js
@@ -332,6 +332,69 @@ User = {
};
},
+ // 加载用户的DB, 这样才能统计
+ _loadUserDB: function (user) {
+ var me = this;
+ var sourceDB = {};
+ var names = ['notebooks', 'notes', 'tags'];
+ if (user.UserId === me.userId) {
+ return db;
+ }
+ if (user.HasDB) {
+ db.initIt(sourceDB, names, user.UserId, false);
+ }
+ else {
+ if (!me.hasDB) {
+ return db;
+ }
+ else {
+ db.initIt(sourceDB, names, '', false);
+ }
+ }
+ return sourceDB;
+ },
+
+ // notebook, note, tag统计
+ getUserDBDataStats: function (user, callback) {
+ var me = this;
+ var data = {};
+ var userId = user.UserId;
+
+ var sourceDB = me._loadUserDB(user);
+
+ var query = {UserId: userId,
+ $or:[
+ {LocalIsDelete: {$exists: false}},
+ {LocalIsDelete: false}
+ ],
+ $or:[
+ {IsDeleted: {$exists: false}},
+ {IsDeleted: false}
+ ],
+ $or:[
+ {IsTrash: {$exists: false}},
+ {IsTrash: false}
+ ]
+ };
+
+ sourceDB.notebooks.count(query, function (err, n) {
+ data.notebook = n;
+ sourceDB.notes.count(query, function (err, n) {
+ data.note = n;
+ sourceDB.tags.count(query, function (err, n) {
+ data.tag = n;
+
+ // 垃圾回收
+ if (sourceDB != db) {
+ sourceDB = null;
+ }
+
+ callback(data);
+ });
+ });
+ });
+ },
+
setUserDataPath: function(userId) {
var me = this;
// 判断是否存在, 不存在则创建dir
diff --git a/public/plugins/accounts/plugin.js b/public/plugins/accounts/plugin.js
index 3cc3fec0..598f5b16 100644
--- a/public/plugins/accounts/plugin.js
+++ b/public/plugins/accounts/plugin.js
@@ -35,6 +35,10 @@ define(function() {
"Error": "错误",
"No such account": "无该帐户",
"Are you sure, it can't be recovered after it has been deleted": "确定要删除该帐户? 本地的数据将会彻底删除",
+
+ "Notebook": "笔记本",
+ "Note": "笔记",
+ "Tag": "标签"
},
'zh-hk': {
'Accounts': '帳戶管理',
@@ -58,6 +62,10 @@ define(function() {
"Error": "錯誤",
"No such account": "無該帳戶",
"Are you sure, it can't be recovered after it has been deleted": "確定要刪除該帳戶? 本地的數據將會徹底刪除",
+
+ "Notebook": "筆記本",
+ "Note": "筆記",
+ "Tag": "標簽"
}
},
_tpl: `
@@ -209,9 +217,34 @@ define(function() {
userLength: 0,
curUser: null,
+ _renderUserDBDataStats: function(userId, data, n) {
+ var me = this;
+ if (n > 3) {
+ return;
+ }
+ if($('#' + userId + '-stat-notebook').length) {
+ $('#' + userId + '-stat-notebook').text(data.notebook);
+ $('#' + userId + '-stat-note').text(data.note);
+ $('#' + userId + '-stat-tag').text(data.tag);
+ }
+ else {
+ setTimeout(function () {
+ me._renderUserDBDataStats(userId, data, n+1);
+ }, 100);
+ }
+ },
+
+ renderUserDBDataStats: function (user) {
+ var me = this;
+ Api.userService.getUserDBDataStats(user, function (data) {
+ me._renderUserDBDataStats(user.UserId, data, 0);
+ });
+ },
+
renderUser: function(user, renderToExists) {
var me = this;
var username = user.Username;
+ var userId = user.UserId;
if (user.IsActive) {
username += ' ' + me.getMsg('Current') + '';
}
@@ -243,6 +276,10 @@ define(function() {
+ '' + me.getMsg('Open Dir') + ''
+ '' + me.getMsg('DB Optimization') + ''
+ ''
+ + '
'
+ + me.getMsg('Notebook') + '
'
+ + me.getMsg('Note') + '
'
+ + me.getMsg('Tag') + ' '
+ ' '
dataTd += '