mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-20 18:54:27 +00:00
本地用户优化, 无博客, 不能导出pdf
新建用户默认添加笔记本, 笔记, 标签
This commit is contained in:
@@ -103,9 +103,9 @@ if(process.platform != 'darwin') {
|
|||||||
|
|
||||||
<script src="public/config.js"></script>
|
<script src="public/config.js"></script>
|
||||||
<script src="public/js/jquery-1.9.0.min.js"></script>
|
<script src="public/js/jquery-1.9.0.min.js"></script>
|
||||||
|
<script src="public/js/app/service_login.js"></script>
|
||||||
<script src="public/js/lang.js"></script>
|
<script src="public/js/lang.js"></script>
|
||||||
<script src="public/js/bootstrap.js"></script>
|
<script src="public/js/bootstrap.js"></script>
|
||||||
<!-- 很慢 -->
|
|
||||||
<script>
|
<script>
|
||||||
function getMsg(key) {
|
function getMsg(key) {
|
||||||
return langData[key] || key;
|
return langData[key] || key;
|
||||||
@@ -180,27 +180,18 @@ $(function() {
|
|||||||
if(!hasHost) {
|
if(!hasHost) {
|
||||||
host = '';
|
host = '';
|
||||||
}
|
}
|
||||||
UserService.login(email, pwd, function(ret) {
|
UserService.login(email, pwd, host, function(ret) {
|
||||||
if (ret) {
|
if (ret) {
|
||||||
setTimeout(function(){
|
setTimeout(function() {
|
||||||
$body.removeClass('loading');
|
$body.removeClass('loading');
|
||||||
goToMainPage();
|
goToMainPage();
|
||||||
gui.getCurrentWindow().close();
|
gui.getCurrentWindow().close();
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
// 不成功, 则用api登录
|
||||||
else {
|
else {
|
||||||
ApiService.auth(email, pwd, host, function(ret) {
|
$body.removeClass('loading');
|
||||||
if(ret.Ok) {
|
showMsg(getMsg("Email or Password Error"));
|
||||||
setTimeout(function(){
|
|
||||||
$body.removeClass('loading');
|
|
||||||
goToMainPage();
|
|
||||||
gui.getCurrentWindow().close();
|
|
||||||
}, 2000);
|
|
||||||
} else {
|
|
||||||
$body.removeClass('loading');
|
|
||||||
showMsg(getMsg("Email or Password Error"));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@@ -227,20 +218,13 @@ $(function() {
|
|||||||
}
|
}
|
||||||
$body.addClass('loading');
|
$body.addClass('loading');
|
||||||
hideMsg();
|
hideMsg();
|
||||||
var user = {};
|
UserService.createLocalUser(username, pwd1, function(ret, dbuser) {
|
||||||
user.Username = username;
|
|
||||||
user.Pwd = pwd1;
|
|
||||||
user.IsLocal = true;
|
|
||||||
UserService.createLocalUser(user, function(ret, dbuser) {
|
|
||||||
if(ret) {
|
if(ret) {
|
||||||
dbuser.UserId = dbuser._id;
|
setTimeout(function(){
|
||||||
UserService.saveCurUser(dbuser, function() {
|
$body.removeClass('loading');
|
||||||
setTimeout(function(){
|
goToMainPage();
|
||||||
$body.removeClass('loading');
|
gui.getCurrentWindow().close();
|
||||||
goToMainPage();
|
}, 2000);
|
||||||
gui.getCurrentWindow().close();
|
|
||||||
}, 2000);
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
$body.removeClass('loading');
|
$body.removeClass('loading');
|
||||||
showMsg(getMsg(dbuser));
|
showMsg(getMsg(dbuser));
|
||||||
@@ -305,7 +289,6 @@ $(function() {
|
|||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script src="public/js/app/service_login.js" defer="defer"></script>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
3
src/node_modules/db.js
generated
vendored
3
src/node_modules/db.js
generated
vendored
@@ -36,7 +36,8 @@ var db = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
initForLogin: function () {
|
initForLogin: function () {
|
||||||
var dbNames = ['users'];
|
// var dbNames = ['users'];
|
||||||
|
var dbNames = ['users', 'notebooks', 'notes', 'tags', 'noteHistories'];
|
||||||
this._init(dbNames);
|
this._init(dbNames);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
20
src/node_modules/file.js
generated
vendored
20
src/node_modules/file.js
generated
vendored
@@ -159,7 +159,7 @@ var File = {
|
|||||||
IsDirty: true, // 本地是新添加的, ServerFileId = 0
|
IsDirty: true, // 本地是新添加的, ServerFileId = 0
|
||||||
CreatedTime: new Date()
|
CreatedTime: new Date()
|
||||||
};
|
};
|
||||||
Attachs.insert(attach);
|
db.attachs.insert(attach);
|
||||||
callback && callback(attach);
|
callback && callback(attach);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -291,7 +291,7 @@ var File = {
|
|||||||
if(isForce) {
|
if(isForce) {
|
||||||
image.ServerFileId = fileId;
|
image.ServerFileId = fileId;
|
||||||
}
|
}
|
||||||
Images.insert(image, function(err, doc) {
|
db.images.insert(image, function(err, doc) {
|
||||||
log(err);
|
log(err);
|
||||||
if(err) {
|
if(err) {
|
||||||
callback && callback(false);
|
callback && callback(false);
|
||||||
@@ -306,7 +306,7 @@ var File = {
|
|||||||
addImageForce: function(fileId, path, callback) {
|
addImageForce: function(fileId, path, callback) {
|
||||||
var me = this;
|
var me = this;
|
||||||
// 先删除之, 可能是本地有记录, 但是文件没了
|
// 先删除之, 可能是本地有记录, 但是文件没了
|
||||||
Images.remove({FileId: fileId}, function() {
|
db.images.remove({FileId: fileId}, function() {
|
||||||
me._addImage(fileId, path, callback, true);
|
me._addImage(fileId, path, callback, true);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -316,8 +316,8 @@ var File = {
|
|||||||
// 因为图片的链接 有可能是本地添加的, 又有可能是远程的
|
// 因为图片的链接 有可能是本地添加的, 又有可能是远程的
|
||||||
// 如果是远程的, FileId == ServerFileId, 是一样的, 所以不要Or
|
// 如果是远程的, FileId == ServerFileId, 是一样的, 所以不要Or
|
||||||
getImageLocalPath: function(fileId, callback) {
|
getImageLocalPath: function(fileId, callback) {
|
||||||
// Images.findOne({$or: {FileId: fileId}, {ServerFileId: fileId}}, function(err, doc) {
|
// db.images.findOne({$or: {FileId: fileId}, {ServerFileId: fileId}}, function(err, doc) {
|
||||||
Images.findOne({FileId: fileId}, function(err, doc) {
|
db.images.findOne({FileId: fileId}, function(err, doc) {
|
||||||
if(!err && doc && doc.Path) { // FileLocalPath是相对于项目的路径
|
if(!err && doc && doc.Path) { // FileLocalPath是相对于项目的路径
|
||||||
callback(true, doc.Path);
|
callback(true, doc.Path);
|
||||||
} else {
|
} else {
|
||||||
@@ -329,7 +329,7 @@ var File = {
|
|||||||
// 得到fileIds所有的images, 为了发送到服务器上
|
// 得到fileIds所有的images, 为了发送到服务器上
|
||||||
getAllImages: function(fileIds, callback) {
|
getAllImages: function(fileIds, callback) {
|
||||||
var me = this;
|
var me = this;
|
||||||
Images.find({$or:[{FileId: {$in: fileIds}}, {ServerFileId: {$in: fileIds}}]}, function(err, images) {
|
db.images.find({$or:[{FileId: {$in: fileIds}}, {ServerFileId: {$in: fileIds}}]}, function(err, images) {
|
||||||
if(err || !images) {
|
if(err || !images) {
|
||||||
return callback(false);
|
return callback(false);
|
||||||
}
|
}
|
||||||
@@ -352,7 +352,7 @@ var File = {
|
|||||||
if(!file.FileId || !file.LocalFileId) {
|
if(!file.FileId || !file.LocalFileId) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Images.update({FileId: file.LocalFileId}, {$set: {ServerFileId: file.FileId, IsDirty: false}});
|
db.images.update({FileId: file.LocalFileId}, {$set: {ServerFileId: file.FileId, IsDirty: false}});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -503,7 +503,7 @@ var File = {
|
|||||||
IsDirty: true, // 本地是新添加的, ServerFileId = 0
|
IsDirty: true, // 本地是新添加的, ServerFileId = 0
|
||||||
CreatedTime: new Date()
|
CreatedTime: new Date()
|
||||||
};
|
};
|
||||||
Attachs.insert(attach);
|
db.attachs.insert(attach);
|
||||||
targets.push(attach);
|
targets.push(attach);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,7 +513,7 @@ var File = {
|
|||||||
deleteNotExistsAttach: function(noteId, attachs) {
|
deleteNotExistsAttach: function(noteId, attachs) {
|
||||||
var me = this;
|
var me = this;
|
||||||
// console.log('--');
|
// console.log('--');
|
||||||
Attachs.find({NoteId: noteId}, function(err, everAttachs) {
|
db.attachs.find({NoteId: noteId}, function(err, everAttachs) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -525,7 +525,7 @@ var File = {
|
|||||||
for(var i in everAttachs) {
|
for(var i in everAttachs) {
|
||||||
var attach = everAttachs[i];
|
var attach = everAttachs[i];
|
||||||
if(!nowMap[attach.FileId]) { // 如果不在, 则删除之
|
if(!nowMap[attach.FileId]) { // 如果不在, 则删除之
|
||||||
Attachs.remove({FileId: attach.FileId});
|
db.attachs.remove({FileId: attach.FileId});
|
||||||
// 删除源文件, 别删错了啊
|
// 删除源文件, 别删错了啊
|
||||||
if(attach.Path.indexOf(fileBasePath) >= 0) {
|
if(attach.Path.indexOf(fileBasePath) >= 0) {
|
||||||
fs.unlink(attach.Path);
|
fs.unlink(attach.Path);
|
||||||
|
78
src/node_modules/note.js
generated
vendored
78
src/node_modules/note.js
generated
vendored
@@ -10,7 +10,7 @@ var Notebook = require('notebook');
|
|||||||
var Server = require('server');
|
var Server = require('server');
|
||||||
var Common = require('common');
|
var Common = require('common');
|
||||||
var Web = require('web');
|
var Web = require('web');
|
||||||
var Notes = db.notes;
|
// var Notes = db.notes;
|
||||||
|
|
||||||
var Api = null; // require('api')
|
var Api = null; // require('api')
|
||||||
var Tag = null;
|
var Tag = null;
|
||||||
@@ -66,7 +66,7 @@ var Note = {
|
|||||||
noteOrContent['IsTrash'] = false;
|
noteOrContent['IsTrash'] = false;
|
||||||
delete noteOrContent['IsNew'];
|
delete noteOrContent['IsNew'];
|
||||||
noteOrContent['LocalIsNew'] = true;
|
noteOrContent['LocalIsNew'] = true;
|
||||||
Notes.insert(noteOrContent, function (err, newDoc) { // Callback is optional
|
db.notes.insert(noteOrContent, function (err, newDoc) { // Callback is optional
|
||||||
if(err) {
|
if(err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
callback && callback(false);
|
callback && callback(false);
|
||||||
@@ -142,7 +142,7 @@ var Note = {
|
|||||||
// console.log(updates);
|
// console.log(updates);
|
||||||
|
|
||||||
// Set an existing field's value
|
// Set an existing field's value
|
||||||
Notes.update({NoteId: noteOrContent.NoteId}, { $set: updates }, {}, function (err, numReplaced) {
|
db.notes.update({NoteId: noteOrContent.NoteId}, { $set: updates }, {}, function (err, numReplaced) {
|
||||||
if(err) {
|
if(err) {
|
||||||
callback && callback(false);
|
callback && callback(false);
|
||||||
} else {
|
} else {
|
||||||
@@ -168,7 +168,7 @@ var Note = {
|
|||||||
return callback && callback(true);
|
return callback && callback(true);
|
||||||
}
|
}
|
||||||
// 更新, 设置isDirty
|
// 更新, 设置isDirty
|
||||||
Notes.update({NoteId: noteId}, { $set: {IsBlog: isBlog, IsDirty: true} }, {}, function (err, numReplaced) {
|
db.notes.update({NoteId: noteId}, { $set: {IsBlog: isBlog, IsDirty: true} }, {}, function (err, numReplaced) {
|
||||||
return callback && callback(true);
|
return callback && callback(true);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -252,7 +252,7 @@ var Note = {
|
|||||||
if(isTrash) {
|
if(isTrash) {
|
||||||
query['IsTrash'] = true;
|
query['IsTrash'] = true;
|
||||||
}
|
}
|
||||||
Notes.find(query).sort({'UpdatedTime': -1}).exec(function(err, notes) {
|
db.notes.find(query).sort({'UpdatedTime': -1}).exec(function(err, notes) {
|
||||||
if(err) {
|
if(err) {
|
||||||
log(err);
|
log(err);
|
||||||
return callback && callback(false);
|
return callback && callback(false);
|
||||||
@@ -264,7 +264,7 @@ var Note = {
|
|||||||
searchNote: function(key, callback) {
|
searchNote: function(key, callback) {
|
||||||
var reg = new RegExp(key);
|
var reg = new RegExp(key);
|
||||||
var userId = User.getCurActiveUserId();
|
var userId = User.getCurActiveUserId();
|
||||||
Notes.find({UserId: userId, IsTrash: false, LocalIsDelete: false, $or: [{Title: reg}, {Content: reg}]}).sort({'UpdatedTime': -1}).exec(function(err, notes) {
|
db.notes.find({UserId: userId, IsTrash: false, LocalIsDelete: false, $or: [{Title: reg}, {Content: reg}]}).sort({'UpdatedTime': -1}).exec(function(err, notes) {
|
||||||
if(!err && notes) {
|
if(!err && notes) {
|
||||||
console.log('search ' + key + ' result: ' + notes.length);
|
console.log('search ' + key + ' result: ' + notes.length);
|
||||||
callback(notes);
|
callback(notes);
|
||||||
@@ -276,7 +276,7 @@ var Note = {
|
|||||||
|
|
||||||
searchNoteByTag: function(tag, callback) {
|
searchNoteByTag: function(tag, callback) {
|
||||||
var userId = User.getCurActiveUserId();
|
var userId = User.getCurActiveUserId();
|
||||||
Notes.find({UserId: userId, IsTrash: false, LocalIsDelete: false, Tags: {$in: [tag]}}).sort({'UpdatedTime': -1}).exec(function(err, notes) {
|
db.notes.find({UserId: userId, IsTrash: false, LocalIsDelete: false, Tags: {$in: [tag]}}).sort({'UpdatedTime': -1}).exec(function(err, notes) {
|
||||||
if(!err && notes) {
|
if(!err && notes) {
|
||||||
console.log('search by tag: ' + tag + ' result: ' + notes.length);
|
console.log('search by tag: ' + tag + ' result: ' + notes.length);
|
||||||
callback(notes);
|
callback(notes);
|
||||||
@@ -289,7 +289,7 @@ var Note = {
|
|||||||
clearTrash: function(callback) {
|
clearTrash: function(callback) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var userId = User.getCurActiveUserId();
|
var userId = User.getCurActiveUserId();
|
||||||
Notes.update(
|
db.notes.update(
|
||||||
{UserId: userId, IsTrash: true},
|
{UserId: userId, IsTrash: true},
|
||||||
{$set: {LocalIsDelete: true, IsDirty: true}},
|
{$set: {LocalIsDelete: true, IsDirty: true}},
|
||||||
{multi: true},
|
{multi: true},
|
||||||
@@ -305,7 +305,7 @@ var Note = {
|
|||||||
if(!note) {
|
if(!note) {
|
||||||
callback(false);
|
callback(false);
|
||||||
}
|
}
|
||||||
Notes.update({NoteId: noteId}, {$set: {IsTrash: true, IsDirty: true}}, function(err, n) {
|
db.notes.update({NoteId: noteId}, {$set: {IsTrash: true, IsDirty: true}}, function(err, n) {
|
||||||
if(err || !n) {
|
if(err || !n) {
|
||||||
callback(false);
|
callback(false);
|
||||||
} else {
|
} else {
|
||||||
@@ -319,7 +319,7 @@ var Note = {
|
|||||||
},
|
},
|
||||||
// 是新的, 又是deleted的, 则删除之
|
// 是新的, 又是deleted的, 则删除之
|
||||||
deleteLocalNote: function(noteId, callback) {
|
deleteLocalNote: function(noteId, callback) {
|
||||||
Notes.remove({NoteId: noteId}, function() {
|
db.notes.remove({NoteId: noteId}, function() {
|
||||||
callback && callback();
|
callback && callback();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -333,7 +333,7 @@ var Note = {
|
|||||||
|
|
||||||
// TODO 删除附件
|
// TODO 删除附件
|
||||||
|
|
||||||
Notes.update({_id: note._id}, {$set: {IsDirty: true, LocalIsDelete: true}}, function(err, n) {
|
db.notes.update({_id: note._id}, {$set: {IsDirty: true, LocalIsDelete: true}}, function(err, n) {
|
||||||
if(n) {
|
if(n) {
|
||||||
// 如果有tags, 则重新更新tags' count
|
// 如果有tags, 则重新更新tags' count
|
||||||
me.updateTagCount(note.Tags);
|
me.updateTagCount(note.Tags);
|
||||||
@@ -345,7 +345,7 @@ var Note = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Notes.update({NoteId: noteId}, {$set: {IsDirty: true, LocalIsDelete: true}}, function(err, n) {
|
db.notes.update({NoteId: noteId}, {$set: {IsDirty: true, LocalIsDelete: true}}, function(err, n) {
|
||||||
if(err || !n) {
|
if(err || !n) {
|
||||||
callback(false);
|
callback(false);
|
||||||
} else {
|
} else {
|
||||||
@@ -364,7 +364,7 @@ var Note = {
|
|||||||
var to = !note.Star;
|
var to = !note.Star;
|
||||||
var preNotebookId = note.NotebookId;
|
var preNotebookId = note.NotebookId;
|
||||||
note.NotebookId = notebookId;
|
note.NotebookId = notebookId;
|
||||||
Notes.update({_id: note._id}, {$set: {IsDirty: true, NotebookId: notebookId, IsTrash: false, LocalIsDelete: false, UpdatedTime: new Date()}}, function(err, n) {
|
db.notes.update({_id: note._id}, {$set: {IsDirty: true, NotebookId: notebookId, IsTrash: false, LocalIsDelete: false, UpdatedTime: new Date()}}, function(err, n) {
|
||||||
// 重新统计
|
// 重新统计
|
||||||
Notebook.reCountNotebookNumberNotes(preNotebookId);
|
Notebook.reCountNotebookNumberNotes(preNotebookId);
|
||||||
Notebook.reCountNotebookNumberNotes(notebookId);
|
Notebook.reCountNotebookNumberNotes(notebookId);
|
||||||
@@ -382,7 +382,7 @@ var Note = {
|
|||||||
me.getNote(noteId, function(note) {
|
me.getNote(noteId, function(note) {
|
||||||
if(note) {
|
if(note) {
|
||||||
var to = !note.Star;
|
var to = !note.Star;
|
||||||
Notes.update({_id: note._id}, {$set: {Star: to, UpdatedTime: new Date()}});
|
db.notes.update({_id: note._id}, {$set: {Star: to, UpdatedTime: new Date()}});
|
||||||
callback(true, to);
|
callback(true, to);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -390,12 +390,12 @@ var Note = {
|
|||||||
|
|
||||||
conflictIsFixed: function(noteId) {
|
conflictIsFixed: function(noteId) {
|
||||||
var me = this;
|
var me = this;
|
||||||
Notes.update({NoteId: noteId}, {$set: {ConflictNoteId: ""}});
|
db.notes.update({NoteId: noteId}, {$set: {ConflictNoteId: ""}});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 笔记本下是否有笔记
|
// 笔记本下是否有笔记
|
||||||
hasNotes: function(notebookId, callback) {
|
hasNotes: function(notebookId, callback) {
|
||||||
Notes.count({NotebookId: notebookId, IsTrash: false, LocalIsDelete: false}, function(err, n) {
|
db.notes.count({NotebookId: notebookId, IsTrash: false, LocalIsDelete: false}, function(err, n) {
|
||||||
console.log(n);
|
console.log(n);
|
||||||
if(err || n > 0) {
|
if(err || n > 0) {
|
||||||
return callback(true);
|
return callback(true);
|
||||||
@@ -407,7 +407,7 @@ var Note = {
|
|||||||
// 得到笔记
|
// 得到笔记
|
||||||
getNote: function(noteId, callback) {
|
getNote: function(noteId, callback) {
|
||||||
var me = this;
|
var me = this;
|
||||||
Notes.findOne({NoteId: noteId}, function(err, doc) {
|
db.notes.findOne({NoteId: noteId}, function(err, doc) {
|
||||||
if(err || !doc) {
|
if(err || !doc) {
|
||||||
log('不存在');
|
log('不存在');
|
||||||
callback && callback(false);
|
callback && callback(false);
|
||||||
@@ -464,7 +464,7 @@ var Note = {
|
|||||||
|
|
||||||
content = me.fixNoteContent(content);
|
content = me.fixNoteContent(content);
|
||||||
|
|
||||||
Notes.update({NoteId: noteId}, { $set: {Content: content, InitSync: false, IsContentDirty: false} }, {}, function (err, numReplaced) {
|
db.notes.update({NoteId: noteId}, { $set: {Content: content, InitSync: false, IsContentDirty: false} }, {}, function (err, numReplaced) {
|
||||||
if(err) {
|
if(err) {
|
||||||
log(err);
|
log(err);
|
||||||
callback && callback(false);
|
callback && callback(false);
|
||||||
@@ -479,7 +479,7 @@ var Note = {
|
|||||||
updateNoteContentForce: function(noteId, content, callback) {
|
updateNoteContentForce: function(noteId, content, callback) {
|
||||||
// 将笔记内容中
|
// 将笔记内容中
|
||||||
|
|
||||||
Notes.update({NoteId: noteId}, { $set: {Content: content, InitSync: false} }, {}, function (err, numReplaced) {
|
db.notes.update({NoteId: noteId}, { $set: {Content: content, InitSync: false} }, {}, function (err, numReplaced) {
|
||||||
if(err) {
|
if(err) {
|
||||||
log(err);
|
log(err);
|
||||||
callback && callback(false);
|
callback && callback(false);
|
||||||
@@ -577,7 +577,7 @@ var Note = {
|
|||||||
|
|
||||||
getNoteByServerNoteId: function(noteId, callback) {
|
getNoteByServerNoteId: function(noteId, callback) {
|
||||||
var me = this;
|
var me = this;
|
||||||
Notes.find({ServerNoteId: noteId}, function(err, doc) {
|
db.notes.find({ServerNoteId: noteId}, function(err, doc) {
|
||||||
// console.log(doc.length + '...');
|
// console.log(doc.length + '...');
|
||||||
if(doc.length > 1) {
|
if(doc.length > 1) {
|
||||||
console.error(doc.length + '. ..');
|
console.error(doc.length + '. ..');
|
||||||
@@ -594,7 +594,7 @@ var Note = {
|
|||||||
},
|
},
|
||||||
getNoteIdByServerNoteId: function(noteId, callback) {
|
getNoteIdByServerNoteId: function(noteId, callback) {
|
||||||
var me = this;
|
var me = this;
|
||||||
Notes.findOne({ServerNoteId: noteId}, function(err, doc) {
|
db.notes.findOne({ServerNoteId: noteId}, function(err, doc) {
|
||||||
if(err || !doc) {
|
if(err || !doc) {
|
||||||
log('getNoteIdByServerNoteId 不存在' + noteId);
|
log('getNoteIdByServerNoteId 不存在' + noteId);
|
||||||
callback && callback(false);
|
callback && callback(false);
|
||||||
@@ -605,7 +605,7 @@ var Note = {
|
|||||||
},
|
},
|
||||||
getServerNoteIdByNoteId: function(noteId, callback) {
|
getServerNoteIdByNoteId: function(noteId, callback) {
|
||||||
var me = this;
|
var me = this;
|
||||||
Notes.findOne({NoteId: noteId}, function(err, doc) {
|
db.notes.findOne({NoteId: noteId}, function(err, doc) {
|
||||||
if(err || !doc) {
|
if(err || !doc) {
|
||||||
log('getServerNoteIdByNoteId 不存在');
|
log('getServerNoteIdByNoteId 不存在');
|
||||||
callback && callback(false);
|
callback && callback(false);
|
||||||
@@ -626,7 +626,7 @@ var Note = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Notes.remove({_id: note._id}, function(err, n) {
|
db.notes.remove({_id: note._id}, function(err, n) {
|
||||||
if(err) {
|
if(err) {
|
||||||
callback && callback(false);
|
callback && callback(false);
|
||||||
} else {
|
} else {
|
||||||
@@ -670,7 +670,7 @@ var Note = {
|
|||||||
|
|
||||||
Notebook.getNotebookIdByServerNotebookId(note.NotebookId, function(localNotebookId) {
|
Notebook.getNotebookIdByServerNotebookId(note.NotebookId, function(localNotebookId) {
|
||||||
note.NotebookId = localNotebookId;
|
note.NotebookId = localNotebookId;
|
||||||
Notes.insert(note, function (err, newDoc) { // Callback is optional
|
db.notes.insert(note, function (err, newDoc) { // Callback is optional
|
||||||
if(err) {
|
if(err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
callback && callback(false);
|
callback && callback(false);
|
||||||
@@ -784,7 +784,7 @@ var Note = {
|
|||||||
delete note['UpdatedTime'];
|
delete note['UpdatedTime'];
|
||||||
delete note['CreatedTime'];
|
delete note['CreatedTime'];
|
||||||
|
|
||||||
Notes.update({NoteId: note.NoteId}, {$set: note}, {}, function (err, cnt) { // Callback is optional
|
db.notes.update({NoteId: note.NoteId}, {$set: note}, {}, function (err, cnt) { // Callback is optional
|
||||||
console.log('re:');
|
console.log('re:');
|
||||||
console.log(err);
|
console.log(err);
|
||||||
console.log(cnt);
|
console.log(cnt);
|
||||||
@@ -873,7 +873,7 @@ var Note = {
|
|||||||
delete note['UpdatedTime'];
|
delete note['UpdatedTime'];
|
||||||
delete note['CreatedTime'];
|
delete note['CreatedTime'];
|
||||||
|
|
||||||
Notes.update({NoteId: note.NoteId}, {$set: note}, function(err, n) {
|
db.notes.update({NoteId: note.NoteId}, {$set: note}, function(err, n) {
|
||||||
if(err || !n) {
|
if(err || !n) {
|
||||||
log('updateNoteForceForSendChange err');
|
log('updateNoteForceForSendChange err');
|
||||||
log(err);
|
log(err);
|
||||||
@@ -901,7 +901,7 @@ var Note = {
|
|||||||
|
|
||||||
Notebook.getNotebookIdByServerNotebookId(note.NotebookId, function(localNotebookId) {
|
Notebook.getNotebookIdByServerNotebookId(note.NotebookId, function(localNotebookId) {
|
||||||
note['NotebookId'] = localNotebookId;
|
note['NotebookId'] = localNotebookId;
|
||||||
Notes.update({NoteId: note.NoteId}, {$set: note}, {}, function (err, cnt) { // Callback is optional
|
db.notes.update({NoteId: note.NoteId}, {$set: note}, {}, function (err, cnt) { // Callback is optional
|
||||||
if(err) {
|
if(err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
callback && callback(false);
|
callback && callback(false);
|
||||||
@@ -971,7 +971,7 @@ var Note = {
|
|||||||
note.Attachs = newAttachs;
|
note.Attachs = newAttachs;
|
||||||
console.log('conflict 复制后的');
|
console.log('conflict 复制后的');
|
||||||
console.log(note);
|
console.log(note);
|
||||||
Notes.insert(note, function(err, newNote) {
|
db.notes.insert(note, function(err, newNote) {
|
||||||
if(err) {
|
if(err) {
|
||||||
callback(false);
|
callback(false);
|
||||||
|
|
||||||
@@ -1036,7 +1036,7 @@ var Note = {
|
|||||||
note.Attachs = newAttachs;
|
note.Attachs = newAttachs;
|
||||||
console.log('conflict 复制后的');
|
console.log('conflict 复制后的');
|
||||||
console.log(note.Attachs);
|
console.log(note.Attachs);
|
||||||
Notes.insert(note, function(err, newNote) {
|
db.notes.insert(note, function(err, newNote) {
|
||||||
if(err) {
|
if(err) {
|
||||||
callback(false);
|
callback(false);
|
||||||
} else {
|
} else {
|
||||||
@@ -1248,7 +1248,7 @@ var Note = {
|
|||||||
// 获得用户修改的笔记
|
// 获得用户修改的笔记
|
||||||
getDirtyNotes: function(callback) {
|
getDirtyNotes: function(callback) {
|
||||||
var me = this;
|
var me = this;
|
||||||
Notes.find({UserId: User.getCurActiveUserId(), IsDirty: true}, function(err, notes) {
|
db.notes.find({UserId: User.getCurActiveUserId(), IsDirty: true}, function(err, notes) {
|
||||||
if(err) {
|
if(err) {
|
||||||
log(err);
|
log(err);
|
||||||
return callback && callback(false);
|
return callback && callback(false);
|
||||||
@@ -1317,17 +1317,17 @@ var Note = {
|
|||||||
|
|
||||||
// 在send delete笔记时成功
|
// 在send delete笔记时成功
|
||||||
setNotDirty: function(noteId) {
|
setNotDirty: function(noteId) {
|
||||||
Notes.update({NoteId: noteId}, {$set: {IsDirty: false}})
|
db.notes.update({NoteId: noteId}, {$set: {IsDirty: false}})
|
||||||
},
|
},
|
||||||
removeNote: function(noteId) {
|
removeNote: function(noteId) {
|
||||||
Notes.remove({NoteId: noteId});
|
db.notes.remove({NoteId: noteId});
|
||||||
},
|
},
|
||||||
// 在send delete笔记时有冲突, 设为不删除
|
// 在send delete笔记时有冲突, 设为不删除
|
||||||
setNotDirtyNotDelete: function(noteId) {
|
setNotDirtyNotDelete: function(noteId) {
|
||||||
Notes.update({NoteId: noteId}, {$set:{IsDirty: false, LocalIsDelete: false}})
|
db.notes.update({NoteId: noteId}, {$set:{IsDirty: false, LocalIsDelete: false}})
|
||||||
},
|
},
|
||||||
setIsNew: function(noteId) {
|
setIsNew: function(noteId) {
|
||||||
Notes.update({NoteId: noteId}, {$set:{LocalIsNew: true, IsDirty: true}})
|
db.notes.update({NoteId: noteId}, {$set:{LocalIsNew: true, IsDirty: true}})
|
||||||
},
|
},
|
||||||
|
|
||||||
//----------------------------------
|
//----------------------------------
|
||||||
@@ -1350,7 +1350,7 @@ var Note = {
|
|||||||
for(var i in attachs) {
|
for(var i in attachs) {
|
||||||
t.push(attachs[i]);
|
t.push(attachs[i]);
|
||||||
}
|
}
|
||||||
Notes.update({NoteId: noteId}, {$set: {Attachs: t, IsDirty: true, UpdatedTime: new Date()}} );
|
db.notes.update({NoteId: noteId}, {$set: {Attachs: t, IsDirty: true, UpdatedTime: new Date()}} );
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -1528,7 +1528,7 @@ var Note = {
|
|||||||
// attach.Title = filename;
|
// attach.Title = filename;
|
||||||
// attach.Filename = filename;
|
// attach.Filename = filename;
|
||||||
|
|
||||||
Notes.update({_id: note._id}, {$set: {Attachs: attachs}}, function() {
|
db.notes.update({_id: note._id}, {$set: {Attachs: attachs}}, function() {
|
||||||
callback(true, attachs, attach);
|
callback(true, attachs, attach);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -1541,7 +1541,7 @@ var Note = {
|
|||||||
// 根据标签得到笔记数量
|
// 根据标签得到笔记数量
|
||||||
countNoteByTag: function(title, callback) {
|
countNoteByTag: function(title, callback) {
|
||||||
var userId = User.getCurActiveUserId();
|
var userId = User.getCurActiveUserId();
|
||||||
Notes.count({UserId: userId, LocalIsDelete: false , Tags: {$in: [title]}}, function(err, cnt) {
|
db.notes.count({UserId: userId, LocalIsDelete: false , Tags: {$in: [title]}}, function(err, cnt) {
|
||||||
callback && callback(cnt);
|
callback && callback(cnt);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -1571,7 +1571,7 @@ var Note = {
|
|||||||
var updates = {}; // noteId =>
|
var updates = {}; // noteId =>
|
||||||
var userId = User.getCurActiveUserId();
|
var userId = User.getCurActiveUserId();
|
||||||
console.log('updateNoteToDeleteTag--');
|
console.log('updateNoteToDeleteTag--');
|
||||||
Notes.find({UserId: userId, LocalIsDelete: false , Tags: {$in: [title]}}, function(err, notes) {
|
db.notes.find({UserId: userId, LocalIsDelete: false , Tags: {$in: [title]}}, function(err, notes) {
|
||||||
console.log(notes);
|
console.log(notes);
|
||||||
if(!err && notes && notes.length > 0) {
|
if(!err && notes && notes.length > 0) {
|
||||||
for(var i in notes) {
|
for(var i in notes) {
|
||||||
@@ -1587,7 +1587,7 @@ var Note = {
|
|||||||
note.Tags = tags;
|
note.Tags = tags;
|
||||||
note.IsDirty = true;
|
note.IsDirty = true;
|
||||||
updates[note.NoteId] = note;
|
updates[note.NoteId] = note;
|
||||||
Notes.update({_id: note._id}, {$set: {Tags: tags, IsDirty: true}}, function(err) {
|
db.notes.update({_id: note._id}, {$set: {Tags: tags, IsDirty: true}}, function(err) {
|
||||||
console.log("??");
|
console.log("??");
|
||||||
console.log(err);
|
console.log(err);
|
||||||
callback(updates);
|
callback(updates);
|
||||||
|
50
src/node_modules/notebook.js
generated
vendored
50
src/node_modules/notebook.js
generated
vendored
@@ -1,7 +1,7 @@
|
|||||||
var db = require('db');
|
var db = require('db');
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
var User = require('user');
|
var User = require('user');
|
||||||
var NB = db.notebooks;
|
// var db.notebooks = db.notebooks;
|
||||||
var Common = require('common');
|
var Common = require('common');
|
||||||
var Web = require('web');
|
var Web = require('web');
|
||||||
|
|
||||||
@@ -58,11 +58,11 @@ var Notebook = {
|
|||||||
, infos: { name: 'nedb' }
|
, infos: { name: 'nedb' }
|
||||||
};
|
};
|
||||||
console.log("save before")
|
console.log("save before")
|
||||||
NB.insert(doc, function (err, newDoc) { // Callback is optional
|
db.notebooks.insert(doc, function (err, newDoc) { // Callback is optional
|
||||||
// newDoc is the newly inserted document, including its _id
|
// newDoc is the newly inserted document, including its _id
|
||||||
// newDoc has no key called notToBeSaved since its value was undefined
|
// newDoc has no key called notToBeSaved since its value was undefined
|
||||||
console.log(err);
|
// console.log(err);
|
||||||
console.log(newDoc);
|
// console.log(newDoc);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ var Notebook = {
|
|||||||
getNotebooks: function(callback) {
|
getNotebooks: function(callback) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var userId = User.getCurActiveUserId();
|
var userId = User.getCurActiveUserId();
|
||||||
NB.find({UserId: userId, $or: [{LocalIsDelete : { $exists : false }}, {LocalIsDelete: false}] }, function(err, notebooks) {
|
db.notebooks.find({UserId: userId, $or: [{LocalIsDelete : { $exists : false }}, {LocalIsDelete: false}] }, function(err, notebooks) {
|
||||||
if(err) {
|
if(err) {
|
||||||
log(err);
|
log(err);
|
||||||
return callback && callback(false);
|
return callback && callback(false);
|
||||||
@@ -126,7 +126,7 @@ var Notebook = {
|
|||||||
if(notebookId) {
|
if(notebookId) {
|
||||||
notebook['NotebookId'] = notebookId;
|
notebook['NotebookId'] = notebookId;
|
||||||
}
|
}
|
||||||
NB.insert(notebook, function (err, newDoc) { // Callback is optional
|
db.notebooks.insert(notebook, function (err, newDoc) { // Callback is optional
|
||||||
if(err) {
|
if(err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
callback && callback(false);
|
callback && callback(false);
|
||||||
@@ -138,7 +138,7 @@ var Notebook = {
|
|||||||
|
|
||||||
// 修改笔记本标题
|
// 修改笔记本标题
|
||||||
updateNotebookTitle: function(notebookId, title, callback) {
|
updateNotebookTitle: function(notebookId, title, callback) {
|
||||||
NB.update({NotebookId: notebookId},
|
db.notebooks.update({NotebookId: notebookId},
|
||||||
{$set:
|
{$set:
|
||||||
{Title: title, IsDirty: true, UpdatedTime: new Date()}
|
{Title: title, IsDirty: true, UpdatedTime: new Date()}
|
||||||
}, function(err, n) {
|
}, function(err, n) {
|
||||||
@@ -160,14 +160,14 @@ var Notebook = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 先更新之
|
// 先更新之
|
||||||
// NB.update({NotebookId: notebookId}, {$set: {ParentNotebookId: parentNotebookId, IsDirty: true, UpdatedTime: new Date()}}, function(err, n) {
|
// db.notebooks.update({NotebookId: notebookId}, {$set: {ParentNotebookId: parentNotebookId, IsDirty: true, UpdatedTime: new Date()}}, function(err, n) {
|
||||||
// });
|
// });
|
||||||
siblingNotebookIds = siblingNotebookIds || [];
|
siblingNotebookIds = siblingNotebookIds || [];
|
||||||
// 再更新所有子孩子的seq
|
// 再更新所有子孩子的seq
|
||||||
for(var i = 0; i < siblingNotebookIds.length; ++i) {
|
for(var i = 0; i < siblingNotebookIds.length; ++i) {
|
||||||
var siblingNotebookId = siblingNotebookIds[i];
|
var siblingNotebookId = siblingNotebookIds[i];
|
||||||
console.log('siblingNotebookId: ' + siblingNotebookId);
|
console.log('siblingNotebookId: ' + siblingNotebookId);
|
||||||
NB.update({NotebookId: siblingNotebookId},
|
db.notebooks.update({NotebookId: siblingNotebookId},
|
||||||
{$set:
|
{$set:
|
||||||
{ParentNotebookId: parentNotebookId, Seq: i, IsDirty: true, UpdatedTime: new Date()}
|
{ParentNotebookId: parentNotebookId, Seq: i, IsDirty: true, UpdatedTime: new Date()}
|
||||||
}
|
}
|
||||||
@@ -189,14 +189,14 @@ var Notebook = {
|
|||||||
if(has) {
|
if(has) {
|
||||||
callback(false, 'This notebook has notes, please delete notes firstly.');
|
callback(false, 'This notebook has notes, please delete notes firstly.');
|
||||||
} else {
|
} else {
|
||||||
NB.update({NotebookId: notebookId}, {$set: {LocalIsDelete: true, IsDirty: true, UpdatedTime: new Date()}}, function(err, n) {
|
db.notebooks.update({NotebookId: notebookId}, {$set: {LocalIsDelete: true, IsDirty: true, UpdatedTime: new Date()}}, function(err, n) {
|
||||||
callback(true);
|
callback(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
NB.remove({NotebookId: notebookId}, function(err, n) {
|
db.notebooks.remove({NotebookId: notebookId}, function(err, n) {
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
@@ -204,7 +204,7 @@ var Notebook = {
|
|||||||
|
|
||||||
// 删除本地的笔记本, 是New又是Delete
|
// 删除本地的笔记本, 是New又是Delete
|
||||||
deleteLocalNotebook: function(notebookId, callback) {
|
deleteLocalNotebook: function(notebookId, callback) {
|
||||||
NB.remove({NotebookId: notebookId}, function(err, n) {
|
db.notebooks.remove({NotebookId: notebookId}, function(err, n) {
|
||||||
callback && callback();
|
callback && callback();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -218,14 +218,14 @@ var Notebook = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Web.updateNotebookNumberNotes(notebookId, count);
|
Web.updateNotebookNumberNotes(notebookId, count);
|
||||||
NB.update({NotebookId: notebookId}, {$set: {NumberNotes: count}}, {})
|
db.notebooks.update({NotebookId: notebookId}, {$set: {NumberNotes: count}}, {})
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 得到笔记本
|
// 得到笔记本
|
||||||
getNotebook: function(notebookId, callback) {
|
getNotebook: function(notebookId, callback) {
|
||||||
var me = this;
|
var me = this;
|
||||||
NB.findOne({NotebookId: notebookId}, function(err, doc) {
|
db.notebooks.findOne({NotebookId: notebookId}, function(err, doc) {
|
||||||
if(err || !doc) {
|
if(err || !doc) {
|
||||||
log('不存在');
|
log('不存在');
|
||||||
callback && callback(false);
|
callback && callback(false);
|
||||||
@@ -242,7 +242,7 @@ var Notebook = {
|
|||||||
|
|
||||||
getNotebookByServerNotebookId: function(notebookId, callback) {
|
getNotebookByServerNotebookId: function(notebookId, callback) {
|
||||||
var me = this;
|
var me = this;
|
||||||
NB.findOne({ServerNotebookId: notebookId}, function(err, doc) {
|
db.notebooks.findOne({ServerNotebookId: notebookId}, function(err, doc) {
|
||||||
if(err || !doc) {
|
if(err || !doc) {
|
||||||
log('不存在');
|
log('不存在');
|
||||||
callback && callback(false);
|
callback && callback(false);
|
||||||
@@ -257,7 +257,7 @@ var Notebook = {
|
|||||||
if(!serverNotebookId) {
|
if(!serverNotebookId) {
|
||||||
return callback(false);
|
return callback(false);
|
||||||
}
|
}
|
||||||
NB.findOne({ServerNotebookId: serverNotebookId}, function(err, notebook) {
|
db.notebooks.findOne({ServerNotebookId: serverNotebookId}, function(err, notebook) {
|
||||||
if(err || !notebook) {
|
if(err || !notebook) {
|
||||||
return callback(false);
|
return callback(false);
|
||||||
}
|
}
|
||||||
@@ -269,7 +269,7 @@ var Notebook = {
|
|||||||
if(!notebookId) {
|
if(!notebookId) {
|
||||||
return callback(false);
|
return callback(false);
|
||||||
}
|
}
|
||||||
NB.findOne({NotebookId: notebookId}, function(err, notebook) {
|
db.notebooks.findOne({NotebookId: notebookId}, function(err, notebook) {
|
||||||
if(err || !notebook) {
|
if(err || !notebook) {
|
||||||
return callback(false);
|
return callback(false);
|
||||||
}
|
}
|
||||||
@@ -280,7 +280,7 @@ var Notebook = {
|
|||||||
// 强制删除
|
// 强制删除
|
||||||
deleteNotebookForce: function(notebookId, callback) {
|
deleteNotebookForce: function(notebookId, callback) {
|
||||||
var me = this;
|
var me = this;
|
||||||
NB.remove({ServerNotebookId: notebookId}, function(err, n) {
|
db.notebooks.remove({ServerNotebookId: notebookId}, function(err, n) {
|
||||||
if(err) {
|
if(err) {
|
||||||
callback && callback(false);
|
callback && callback(false);
|
||||||
} else {
|
} else {
|
||||||
@@ -311,7 +311,7 @@ var Notebook = {
|
|||||||
notebook.LocalIsNew = false;
|
notebook.LocalIsNew = false;
|
||||||
notebook.LocalIsDelete = false;
|
notebook.LocalIsDelete = false;
|
||||||
|
|
||||||
NB.insert(notebook, function (err, newDoc) { // Callback is optional
|
db.notebooks.insert(notebook, function (err, newDoc) { // Callback is optional
|
||||||
if(err) {
|
if(err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
callback && callback(false);
|
callback && callback(false);
|
||||||
@@ -339,7 +339,7 @@ var Notebook = {
|
|||||||
notebook.ParentNotebookId = parentNotebookId;
|
notebook.ParentNotebookId = parentNotebookId;
|
||||||
notebook.ServerNotebookId = notebook.NotebookId;
|
notebook.ServerNotebookId = notebook.NotebookId;
|
||||||
notebook.NotebookId = notebookLocal.NotebookId;
|
notebook.NotebookId = notebookLocal.NotebookId;
|
||||||
NB.update({ServerNotebookId: serverNotebookId}, {$set: notebook}, {}, function (err, updates) { // Callback is optional
|
db.notebooks.update({ServerNotebookId: serverNotebookId}, {$set: notebook}, {}, function (err, updates) { // Callback is optional
|
||||||
if(err) {
|
if(err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
callback && callback(false);
|
callback && callback(false);
|
||||||
@@ -367,7 +367,7 @@ var Notebook = {
|
|||||||
// console.log(notebook2);
|
// console.log(notebook2);
|
||||||
// notebook2.Title += " H-";
|
// notebook2.Title += " H-";
|
||||||
// multi, 因为历史原因, 导致大量重复notebookId的元素
|
// multi, 因为历史原因, 导致大量重复notebookId的元素
|
||||||
NB.update({NotebookId: notebookId}, {$set: notebook}, {multi: true}, function (err, n) {
|
db.notebooks.update({NotebookId: notebookId}, {$set: notebook}, {multi: true}, function (err, n) {
|
||||||
// console.log('updateNotebookForceForSendChange end' + notebookId + ' ' + n);
|
// console.log('updateNotebookForceForSendChange end' + notebookId + ' ' + n);
|
||||||
if(err) {
|
if(err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
@@ -402,7 +402,7 @@ var Notebook = {
|
|||||||
// 获得用户修改的笔记本
|
// 获得用户修改的笔记本
|
||||||
getDirtyNotebooks: function(callback) {
|
getDirtyNotebooks: function(callback) {
|
||||||
var me = this;
|
var me = this;
|
||||||
NB.find({UserId: User.getCurActiveUserId(), IsDirty: true}, function(err, notebooks) {
|
db.notebooks.find({UserId: User.getCurActiveUserId(), IsDirty: true}, function(err, notebooks) {
|
||||||
if(err) {
|
if(err) {
|
||||||
log(err);
|
log(err);
|
||||||
return callback && callback(false);
|
return callback && callback(false);
|
||||||
@@ -483,14 +483,14 @@ var Notebook = {
|
|||||||
|
|
||||||
// 在send delete笔记时成功
|
// 在send delete笔记时成功
|
||||||
setNotDirty: function(notebookId) {
|
setNotDirty: function(notebookId) {
|
||||||
NB.update({NotebookId: notebookId}, {$set:{IsDirty: false}})
|
db.notebooks.update({NotebookId: notebookId}, {$set:{IsDirty: false}})
|
||||||
},
|
},
|
||||||
// 在send delete笔记时有冲突
|
// 在send delete笔记时有冲突
|
||||||
setNotDirtyNotDelete: function(notebookId) {
|
setNotDirtyNotDelete: function(notebookId) {
|
||||||
NB.update({NotebookId: notebookId}, {$set:{IsDirty: false, LocalIsDelete: false}})
|
db.notebooks.update({NotebookId: notebookId}, {$set:{IsDirty: false, LocalIsDelete: false}})
|
||||||
},
|
},
|
||||||
setIsNew: function(notebookId) {
|
setIsNew: function(notebookId) {
|
||||||
NB.update({NotebookId: notebookId}, {$set:{LocalIsNew: true, IsDirty: true}})
|
db.notebooks.update({NotebookId: notebookId}, {$set:{LocalIsNew: true, IsDirty: true}})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
module.exports = Notebook;
|
module.exports = Notebook;
|
32
src/node_modules/tag.js
generated
vendored
32
src/node_modules/tag.js
generated
vendored
@@ -3,7 +3,7 @@ var Common = require('common');
|
|||||||
var User = require('user');
|
var User = require('user');
|
||||||
// var Note = require('note');
|
// var Note = require('note');
|
||||||
var Web = require('web');
|
var Web = require('web');
|
||||||
var Tags = db.tags;
|
// var Tags = db.tags;
|
||||||
/*
|
/*
|
||||||
TagId
|
TagId
|
||||||
ServerTagId
|
ServerTagId
|
||||||
@@ -21,21 +21,21 @@ var Tag = {
|
|||||||
// 添加或更新标签
|
// 添加或更新标签
|
||||||
addOrUpdateTag: function(title, callback, isForce, usn) {
|
addOrUpdateTag: function(title, callback, isForce, usn) {
|
||||||
var userId = User.getCurActiveUserId();
|
var userId = User.getCurActiveUserId();
|
||||||
Tags.findOne({UserId: userId, Tag: title}, function(err, tag) {
|
db.tags.findOne({UserId: userId, Tag: title}, function(err, tag) {
|
||||||
// 存在, 则更新该tag下的笔记数量
|
// 存在, 则更新该tag下的笔记数量
|
||||||
// 已存的, 不更新IsDirty
|
// 已存的, 不更新IsDirty
|
||||||
var Note = require('note');
|
var Note = require('note');
|
||||||
if(!err && tag) {
|
if(!err && tag) {
|
||||||
Note.countNoteByTag(title, function(cnt) {
|
Note.countNoteByTag(title, function(cnt) {
|
||||||
tag.Count = cnt;
|
tag.Count = cnt;
|
||||||
Tags.update({UserId: userId, Title: title}, {$set: {Count: cnt, UpdatedTime: new Date()}}, function() {
|
db.tags.update({UserId: userId, Title: title}, {$set: {Count: cnt, UpdatedTime: new Date()}}, function() {
|
||||||
console.log('已存在tag' + title);
|
console.log('已存在tag' + title);
|
||||||
callback(tag);
|
callback(tag);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
Tags.insert({
|
db.tags.insert({
|
||||||
TagId: Common.objectId(),
|
TagId: Common.objectId(),
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
Tag: title,
|
Tag: title,
|
||||||
@@ -56,7 +56,7 @@ var Tag = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
getTags: function(callback) {
|
getTags: function(callback) {
|
||||||
Tags.find({UserId: User.getCurActiveUserId(), LocalIsDelete: false}, function(err, tags) {
|
db.tags.find({UserId: User.getCurActiveUserId(), LocalIsDelete: false}, function(err, tags) {
|
||||||
if(err) {
|
if(err) {
|
||||||
callback && callback(false);
|
callback && callback(false);
|
||||||
} else {
|
} else {
|
||||||
@@ -68,7 +68,7 @@ var Tag = {
|
|||||||
// 删除标签, 更新为LocaleIsDelete = true
|
// 删除标签, 更新为LocaleIsDelete = true
|
||||||
deleteTag: function(title, callback, isForce) {
|
deleteTag: function(title, callback, isForce) {
|
||||||
var me = this;
|
var me = this;
|
||||||
Tags.update({UserId: User.getCurActiveUserId(), Tag: title}, {$set: {LocalIsDelete: true, IsDirty: !isForce, UpdatedTime: new Date()}}, function() {
|
db.tags.update({UserId: User.getCurActiveUserId(), Tag: title}, {$set: {LocalIsDelete: true, IsDirty: !isForce, UpdatedTime: new Date()}}, function() {
|
||||||
});
|
});
|
||||||
//
|
//
|
||||||
var Note = require('./note');
|
var Note = require('./note');
|
||||||
@@ -82,14 +82,14 @@ var Tag = {
|
|||||||
updateTagCount: function(title, count) {
|
updateTagCount: function(title, count) {
|
||||||
userId = User.getCurActiveUserId();
|
userId = User.getCurActiveUserId();
|
||||||
// 更新Tag's Count
|
// 更新Tag's Count
|
||||||
Tags.update({UserId: userId, Tag: title}, {$set: {Count: count}});
|
db.tags.update({UserId: userId, Tag: title}, {$set: {Count: count}});
|
||||||
// 更新web
|
// 更新web
|
||||||
Web.updateTagCount({Tag: title, Count: count});
|
Web.updateTagCount({Tag: title, Count: count});
|
||||||
},
|
},
|
||||||
|
|
||||||
getTag: function(title, callback) {
|
getTag: function(title, callback) {
|
||||||
var userId = User.getCurActiveUserId();
|
var userId = User.getCurActiveUserId();
|
||||||
Tags.findOne({UserId: userId, Tag: title}, function(err, tag) {
|
db.tags.findOne({UserId: userId, Tag: title}, function(err, tag) {
|
||||||
if(err || !tag) {
|
if(err || !tag) {
|
||||||
return callback && callback(false);
|
return callback && callback(false);
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ var Tag = {
|
|||||||
var me = this;
|
var me = this;
|
||||||
tag.IsDirty = false;
|
tag.IsDirty = false;
|
||||||
var userId = User.getCurActiveUserId();
|
var userId = User.getCurActiveUserId();
|
||||||
Tags.update({UserId: userId, Tag: tag.Tag}, {$set: tag}, function() {
|
db.tags.update({UserId: userId, Tag: tag.Tag}, {$set: tag}, function() {
|
||||||
callback && callback();
|
callback && callback();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -111,7 +111,7 @@ var Tag = {
|
|||||||
setNotDirty: function(title) {
|
setNotDirty: function(title) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var userId = User.getCurActiveUserId();
|
var userId = User.getCurActiveUserId();
|
||||||
Tags.update({UserId: userId, Tag: title}, {$set: {IsDirty: false, UpdatedTime: new Date()}}, function() {
|
db.tags.update({UserId: userId, Tag: title}, {$set: {IsDirty: false, UpdatedTime: new Date()}}, function() {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ var Tag = {
|
|||||||
setNotDirtyAndUsn: function(title, usn) {
|
setNotDirtyAndUsn: function(title, usn) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var userId = User.getCurActiveUserId();
|
var userId = User.getCurActiveUserId();
|
||||||
Tags.update({UserId: userId, Tag: title}, {$set: {IsDirty: false, Usn: usn, UpdatedTime: new Date()}}, function() {
|
db.tags.update({UserId: userId, Tag: title}, {$set: {IsDirty: false, Usn: usn, UpdatedTime: new Date()}}, function() {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ var Tag = {
|
|||||||
getDirtyTags: function(callback) {
|
getDirtyTags: function(callback) {
|
||||||
var me = this;
|
var me = this;
|
||||||
userId = User.getCurActiveUserId();
|
userId = User.getCurActiveUserId();
|
||||||
Tags.find({UserId: userId, IsDirty: true}, function(err, tags) {
|
db.tags.find({UserId: userId, IsDirty: true}, function(err, tags) {
|
||||||
if(err || !tags) {
|
if(err || !tags) {
|
||||||
return callback && callback(false);
|
return callback && callback(false);
|
||||||
}
|
}
|
||||||
@@ -145,12 +145,12 @@ var Tag = {
|
|||||||
// 添加标签, 先查询是否存在
|
// 添加标签, 先查询是否存在
|
||||||
addTag: function(title, callback) {
|
addTag: function(title, callback) {
|
||||||
var userId = User.getCurActiveUserId();
|
var userId = User.getCurActiveUserId();
|
||||||
Tags.count({UserId: userId, Title: title}, function(err, count) {
|
db.tags.count({UserId: userId, Title: title}, function(err, count) {
|
||||||
if(count) {
|
if(count) {
|
||||||
callback && callback({Ok: false, IsExists: true});
|
callback && callback({Ok: false, IsExists: true});
|
||||||
} else {
|
} else {
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
Tags.insert({
|
db.tags.insert({
|
||||||
TagId: Common.objectId(),
|
TagId: Common.objectId(),
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
Title: title,
|
Title: title,
|
||||||
@@ -169,8 +169,8 @@ var Tag = {
|
|||||||
// 更新标签标题
|
// 更新标签标题
|
||||||
updateTagTitle: function(tagId, Title, callback) {
|
updateTagTitle: function(tagId, Title, callback) {
|
||||||
userId = User.getCurActiveUserId();
|
userId = User.getCurActiveUserId();
|
||||||
// Tags.update({TagId: tagId, userId: userId}, {$set: {NumberNotes: count}}, {})
|
// db.tags.update({TagId: tagId, userId: userId}, {$set: {NumberNotes: count}}, {})
|
||||||
Tags.update({TagId: tagId, userId: userId}, {$set: {Title: title}}, {}, function(err) {
|
db.tags.update({TagId: tagId, userId: userId}, {$set: {Title: title}}, {}, function(err) {
|
||||||
if(err) {
|
if(err) {
|
||||||
callback && callback(false);
|
callback && callback(false);
|
||||||
} else {
|
} else {
|
||||||
|
84
src/node_modules/user.js
generated
vendored
84
src/node_modules/user.js
generated
vendored
@@ -1,6 +1,7 @@
|
|||||||
var Evt = require('evt');
|
var Evt = require('evt');
|
||||||
var db = require('db');
|
var db = require('db');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
var Common = require('common');
|
||||||
|
|
||||||
function log(o) {
|
function log(o) {
|
||||||
console.log(o);
|
console.log(o);
|
||||||
@@ -46,23 +47,80 @@ User = {
|
|||||||
me.setUserDataPath();
|
me.setUserDataPath();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
login: function(username, password, callback) {
|
|
||||||
// 验证用户名密码
|
// 登录
|
||||||
//FIXME 鉴于服务器端也是明文密码,暂时用明文,安全性堪忧
|
login: function(username, password, host, callback) {
|
||||||
db.users.count({Username: username, Pwd: password},
|
var me = this;
|
||||||
function(err, count) {
|
// 先本地验证
|
||||||
// log('login failed: ' + count);
|
console.log('login');
|
||||||
// log(err);
|
db.users.findOne({Username: username, IsLocal: true}, function(err, user) {
|
||||||
callback && callback(count == 1);
|
console.log('login end');
|
||||||
|
if(err || !user || !user.UserId || user.Pwd != password) {
|
||||||
|
if(!Api) {
|
||||||
|
Api = require('api');
|
||||||
|
}
|
||||||
|
// 远程验证
|
||||||
|
Api.auth(username, password, host, function(ret) {
|
||||||
|
if(ret.Ok) {
|
||||||
|
callback(true);
|
||||||
|
} else {
|
||||||
|
callback(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
me.saveCurUser(user, function() {
|
||||||
|
callback(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
createLocalUser: function(user, callback) {
|
|
||||||
// 当前用户是否在数据库中
|
// 创建本地帐户
|
||||||
db.users.count({Username: user.Username}, function(err, count) {
|
createLocalUser: function(useranme, pwd, callback) {
|
||||||
|
var me = this;
|
||||||
|
db.users.count({Username: useranme}, function(err, count) {
|
||||||
if(count == 0) {
|
if(count == 0) {
|
||||||
|
var user = {};
|
||||||
|
user.Username = useranme;
|
||||||
|
user.IsLocal = true;
|
||||||
|
user.IsActive = true;
|
||||||
|
user.Pwd = pwd;
|
||||||
|
user.UserId = Common.objectId();
|
||||||
db.users.insert(user, function(err, doc) {
|
db.users.insert(user, function(err, doc) {
|
||||||
log(err);
|
// 创建默认的笔记本
|
||||||
callback && callback(!err, doc);
|
if (!err) {
|
||||||
|
// 设为当前user
|
||||||
|
me.saveCurUser(doc);
|
||||||
|
|
||||||
|
me.userId = user.UserId;
|
||||||
|
var Notebook = require('notebook');
|
||||||
|
var notebookId = Common.objectId();
|
||||||
|
Notebook.addNotebook(notebookId, 'Leanote', '', function (notebook) {
|
||||||
|
if (notebook) {
|
||||||
|
var Note = require('note');
|
||||||
|
var Tag = require('tag');
|
||||||
|
Tag.addOrUpdateTag('Leanote');
|
||||||
|
Tag.addOrUpdateTag('Welcome');
|
||||||
|
Note.updateNoteOrContent({
|
||||||
|
IsNew: true,
|
||||||
|
NoteId: Common.objectId(),
|
||||||
|
"NotebookId": notebookId,
|
||||||
|
"Title": "Welcome to Leanote 欢迎来到Leanote",
|
||||||
|
"Content": "<h2>Leanote, Not Just A NotePad!</h2>Welcome!<h2>Leanote, 不只是笔记</h2>欢迎!",
|
||||||
|
"Desc": "Leanote, Not Just A NotePad! Welcome",
|
||||||
|
"Tags": ['Leanote', 'Welcome']
|
||||||
|
}, function () {
|
||||||
|
callback(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
callback(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
callback(true);
|
||||||
|
} else {
|
||||||
|
callback(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// log('save new user failed: username exists')
|
// log('save new user failed: username exists')
|
||||||
|
8
src/node_modules/web.js
generated
vendored
8
src/node_modules/web.js
generated
vendored
@@ -13,16 +13,16 @@ var Web = {
|
|||||||
// 断网处理
|
// 断网处理
|
||||||
unConnected: function() {
|
unConnected: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
me.Note.unConnected();
|
me.Note && me.Note.unConnected();
|
||||||
},
|
},
|
||||||
notLogin: function() {
|
notLogin: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
me.Note.notLogin();
|
me.Note && me.Note.notLogin();
|
||||||
},
|
},
|
||||||
|
|
||||||
alertWeb: function(msg) {
|
alertWeb: function(msg) {
|
||||||
var me = this;
|
var me = this;
|
||||||
me.Note.alertWeb(msg);
|
me.Note && me.Note.alertWeb(msg);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 注入前端变量
|
// 注入前端变量
|
||||||
@@ -152,7 +152,7 @@ var Web = {
|
|||||||
// 重新统计后, 显示到web上
|
// 重新统计后, 显示到web上
|
||||||
updateNotebookNumberNotes: function(notebookId, count) {
|
updateNotebookNumberNotes: function(notebookId, count) {
|
||||||
var me = this;
|
var me = this;
|
||||||
me.Notebook.updateNotebookNumberNotes(notebookId, count);
|
me.Notebook && me.Notebook.updateNotebookNumberNotes(notebookId, count);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
module.exports = Web;
|
module.exports = Web;
|
||||||
|
@@ -20,6 +20,6 @@ var Config = {
|
|||||||
"name": "繁体中文"
|
"name": "繁体中文"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"lang": "en-us",
|
"lang": "zh-hk",
|
||||||
"theme": ""
|
"theme": ""
|
||||||
};
|
};
|
@@ -2219,6 +2219,7 @@ Note.initContextmenu = function() {
|
|||||||
Note.deleteNote(self.target);
|
Note.deleteNote(self.target);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.publicBlog = new gui.MenuItem({
|
this.publicBlog = new gui.MenuItem({
|
||||||
label: getMsg("Public as blog"),
|
label: getMsg("Public as blog"),
|
||||||
click: function(e) {
|
click: function(e) {
|
||||||
@@ -2249,9 +2250,11 @@ Note.initContextmenu = function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.menu.append(this.publicBlog);
|
if (!UserInfo.IsLocal) {
|
||||||
this.menu.append(this.unPublicBlog);
|
this.menu.append(this.publicBlog);
|
||||||
this.menu.append(gui.getSeparatorMenu());
|
this.menu.append(this.unPublicBlog);
|
||||||
|
this.menu.append(gui.getSeparatorMenu());
|
||||||
|
}
|
||||||
|
|
||||||
this.menu.append(this.del);
|
this.menu.append(this.del);
|
||||||
this.menu.append(gui.getSeparatorMenu());
|
this.menu.append(gui.getSeparatorMenu());
|
||||||
|
@@ -1416,14 +1416,15 @@ function initPage(initedCallback) {
|
|||||||
UserService.init(function(userInfo) {
|
UserService.init(function(userInfo) {
|
||||||
if(userInfo) {
|
if(userInfo) {
|
||||||
UserInfo = userInfo;
|
UserInfo = userInfo;
|
||||||
//no full sync for local account
|
// no full sync for local account
|
||||||
//see https://github.com/leanote/desktop-app/issues/36
|
// see https://github.com/leanote/desktop-app/issues/36
|
||||||
if (UserInfo.IsLocal) {
|
if (UserInfo.IsLocal) {
|
||||||
console.log('skip full sync for local account');
|
// console.log('skip full sync for local account');
|
||||||
_init();
|
_init();
|
||||||
$('#syncRefresh').off ('click');
|
$('#syncRefresh').off('click');
|
||||||
$('#syncRefresh').hide ();
|
$('body').addClass('local');
|
||||||
}// 之前已同步过, 就不要full sync了
|
}
|
||||||
|
// 之前已同步过, 就不要full sync了
|
||||||
else if('LastSyncUsn' in UserInfo && UserInfo['LastSyncUsn'] > 0) {
|
else if('LastSyncUsn' in UserInfo && UserInfo['LastSyncUsn'] > 0) {
|
||||||
_init();
|
_init();
|
||||||
} else {
|
} else {
|
||||||
@@ -1926,7 +1927,7 @@ function userMenu() {
|
|||||||
|
|
||||||
this.menu = new gui.Menu();
|
this.menu = new gui.Menu();
|
||||||
this.email = new gui.MenuItem({
|
this.email = new gui.MenuItem({
|
||||||
label: UserInfo.Username + ' (' + shortHost + ')',
|
label: UserInfo.IsLocal ? UserInfo.Username + ' (' + getMsg('Local') + ')' : UserInfo.Username + ' (' + shortHost + ')',
|
||||||
enabled: false,
|
enabled: false,
|
||||||
click: function(e) {
|
click: function(e) {
|
||||||
}
|
}
|
||||||
|
@@ -275,6 +275,8 @@
|
|||||||
"Create Local Account": "创建本地帐户",
|
"Create Local Account": "创建本地帐户",
|
||||||
"Sign in to Leanote": "登录到Leanote",
|
"Sign in to Leanote": "登录到Leanote",
|
||||||
"Confirm password": "确认密码",
|
"Confirm password": "确认密码",
|
||||||
"Username": "用户名"
|
"Username": "用户名",
|
||||||
|
"User exists": "用户已存在",
|
||||||
|
"Local": "本地"
|
||||||
|
|
||||||
}
|
}
|
@@ -275,6 +275,7 @@
|
|||||||
"Create Local Account": "創建本地帳戶",
|
"Create Local Account": "創建本地帳戶",
|
||||||
"Sign in to Leanote": "登錄到Leanote",
|
"Sign in to Leanote": "登錄到Leanote",
|
||||||
"Confirm password": "確認密碼",
|
"Confirm password": "確認密碼",
|
||||||
"Username": "用户名"
|
"Username": "用戶名",
|
||||||
|
"User exists": "用戶已存在",
|
||||||
|
"Local": "本地"
|
||||||
}
|
}
|
2
src/public/min/config-min.js
vendored
2
src/public/min/config-min.js
vendored
@@ -1 +1 @@
|
|||||||
var Config={plugins:["theme","import_evernote","export_pdf","langs"],langs:[{filename:"en-us",name:"English"},{filename:"zh-cn",name:"简体中文"},{filename:"zh-hk",name:"繁体中文"}],lang:"zh-hk",theme:"pebbles"};
|
var Config={plugins:["theme","import_evernote","export_pdf","export_html","langs"],langs:[{filename:"en-us",name:"English"},{filename:"zh-cn",name:"简体中文"},{filename:"zh-hk",name:"繁体中文"}],lang:"zh-hk",theme:""};
|
@@ -8,19 +8,22 @@ define(function() {
|
|||||||
'export': 'Export PDF',
|
'export': 'Export PDF',
|
||||||
'exportSuccess': 'PDF saved successful!',
|
'exportSuccess': 'PDF saved successful!',
|
||||||
'exportFailure': 'PDF saved failure!',
|
'exportFailure': 'PDF saved failure!',
|
||||||
'notExists': 'Please sync your note to ther server firslty.'
|
'notExists': 'Please sync your note to ther server firslty.',
|
||||||
|
'localUser': 'Not support for local user'
|
||||||
},
|
},
|
||||||
'zh-cn': {
|
'zh-cn': {
|
||||||
'export': '导出PDF',
|
'export': '导出PDF',
|
||||||
'exportSuccess': 'PDF导出成功!',
|
'exportSuccess': 'PDF导出成功!',
|
||||||
'exportFailure': 'PDF导出失败!',
|
'exportFailure': 'PDF导出失败!',
|
||||||
'notExists': '请先同步该笔记!'
|
'notExists': '请先同步该笔记!',
|
||||||
|
'localUser': '本地用户不支持导出PDF'
|
||||||
},
|
},
|
||||||
'zh-hk': {
|
'zh-hk': {
|
||||||
'export': '導出PDF',
|
'export': '導出PDF',
|
||||||
'exportSuccess': 'PDF導出成功!',
|
'exportSuccess': 'PDF導出成功!',
|
||||||
'exportFailure': 'PDF導出失敗!',
|
'exportFailure': 'PDF導出失敗!',
|
||||||
'notExists': '請先同步該筆記!'
|
'notExists': '請先同步該筆記!',
|
||||||
|
'localUser': '本地用戶不支持導出PDF'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -115,6 +118,10 @@ define(function() {
|
|||||||
label: Api.getMsg('plugin.export_pdf.export'),
|
label: Api.getMsg('plugin.export_pdf.export'),
|
||||||
click: (function() {
|
click: (function() {
|
||||||
return function(note) {
|
return function(note) {
|
||||||
|
if (UserInfo.IsLocal) {
|
||||||
|
Notify.show({type: 'warning', title: 'Warning', body: getMsg('plugin.export_pdf.localUser')});
|
||||||
|
return;
|
||||||
|
}
|
||||||
me.exportPDF(note);
|
me.exportPDF(note);
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
@@ -2514,3 +2514,7 @@ body,
|
|||||||
#leftNotebook {
|
#leftNotebook {
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
|
.local #syncRefresh,
|
||||||
|
.local #syncProgress {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
@@ -796,3 +796,8 @@ body {
|
|||||||
html, body, #page, #pageInner, #noteList, #notebook, #leftNotebook {
|
html, body, #page, #pageInner, #noteList, #notebook, #leftNotebook {
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// localUser
|
||||||
|
.local #syncRefresh, .local #syncProgress {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user