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