mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-17 16:45:21 +00:00
fix sync
This commit is contained in:
66
node_modules/api.js
generated
vendored
66
node_modules/api.js
generated
vendored
@@ -45,6 +45,9 @@ var Api = {
|
||||
if(!ret['Ok'] && ret['Msg'] == 'NOTLOGIN') {
|
||||
Web.notLogin();
|
||||
}
|
||||
if(!ret['Ok'] && ret['Msg'] == 'NEED-UPGRADE-ACCOUNT') {
|
||||
Web.needUpgradeAccount();
|
||||
}
|
||||
} else {
|
||||
// 出现问题
|
||||
Web.unConnected();
|
||||
@@ -133,8 +136,8 @@ var Api = {
|
||||
return callback && callback(false);
|
||||
}
|
||||
var ret = response.body;
|
||||
console.log(ret);
|
||||
console.log(response);
|
||||
// console.log(ret);
|
||||
// console.log(response);
|
||||
if(Common.isOk(ret)) {
|
||||
callback && callback(ret);
|
||||
} else {
|
||||
@@ -184,7 +187,7 @@ var Api = {
|
||||
getLastSyncState: function(callback) {
|
||||
var me = this;
|
||||
var url = this.getUrl('user/getSyncState');
|
||||
console.log(url);
|
||||
// console.log(url);
|
||||
needle.get(url, {timeout: 10000}, function(error, response) {
|
||||
// console.log('user/getSyncState ret');
|
||||
me.checkError(error, response);
|
||||
@@ -192,7 +195,7 @@ var Api = {
|
||||
return callback && callback(false);
|
||||
}
|
||||
var ret = response.body;
|
||||
console.log('--getSyncState--ret---')
|
||||
// console.log('1. getSyncStateRet:')
|
||||
if(Common.isOk(ret)) {
|
||||
callback && callback(ret);
|
||||
} else {
|
||||
@@ -204,7 +207,8 @@ var Api = {
|
||||
getNoteContent: function(noteId, callback) {
|
||||
var me = this;
|
||||
var url = this.getUrl('note/getNoteContent', {noteId: noteId});
|
||||
console.log(url);
|
||||
console.log(' get note content from server...', noteId);
|
||||
// console.log(url);
|
||||
needle.get(url, function(error, response) {
|
||||
me.checkError(error, response);
|
||||
if(error) {
|
||||
@@ -476,9 +480,7 @@ var Api = {
|
||||
// note.NotebookId是本的, 要得到远程的
|
||||
Notebook.getServerNotebookIdByNotebookId(note.NotebookId, function(serverNotebookId) {
|
||||
if(!serverNotebookId) {
|
||||
console.error('No serverNotebookId');
|
||||
// console.log(note);
|
||||
callback && callback(false);
|
||||
callback && callback('No serverNotebookId');
|
||||
return;
|
||||
}
|
||||
var data = {
|
||||
@@ -494,8 +496,6 @@ var Api = {
|
||||
CreatedTime: Common.formatDatetime(note.CreatedTime),
|
||||
UpdatedTime: Common.formatDatetime(note.UpdatedTime)
|
||||
}
|
||||
// log('add note');
|
||||
// log(data);
|
||||
|
||||
// files处理
|
||||
var needMultiple = false;
|
||||
@@ -505,8 +505,7 @@ var Api = {
|
||||
}
|
||||
|
||||
// 最终传递的数据
|
||||
console.log('end transfer data');
|
||||
console.log(data);
|
||||
console.log(' end transfer data', data);
|
||||
|
||||
try {
|
||||
needle.post(me.getUrl('note/addNote'), data,
|
||||
@@ -514,26 +513,21 @@ var Api = {
|
||||
multipart: needMultiple
|
||||
},
|
||||
function(err, resp) {
|
||||
me.checkError(err, resp);
|
||||
if(err) {
|
||||
console.error('add note error!!-------');
|
||||
console.error(err);
|
||||
return callback(false);
|
||||
}
|
||||
var ret = resp.body;
|
||||
console.log('add note ret');
|
||||
console.log(ret);
|
||||
console.log('add note ret<-');
|
||||
if(Common.isOk(ret)) {
|
||||
// 将serverId保存
|
||||
callback(ret);
|
||||
} else {
|
||||
callback(false);
|
||||
}
|
||||
});
|
||||
me.checkError(err, resp);
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
var ret = resp.body;
|
||||
console.log(' add note ret', ret);
|
||||
if(Common.isOk(ret)) {
|
||||
// 将serverId保存
|
||||
callback(null, ret);
|
||||
} else {
|
||||
callback(ret);
|
||||
}
|
||||
});
|
||||
} catch(e) {
|
||||
console.log('add note needle error');
|
||||
console.log(e);
|
||||
console.log(' add note needle error', e);
|
||||
};
|
||||
});
|
||||
},
|
||||
@@ -568,7 +562,7 @@ var Api = {
|
||||
}
|
||||
}
|
||||
|
||||
console.log('update note :');
|
||||
// console.log('update note :');
|
||||
|
||||
// files处理
|
||||
var needMultiple = false;
|
||||
@@ -581,9 +575,9 @@ var Api = {
|
||||
// console.log('update note ret------------------');
|
||||
me.checkError(err, resp);
|
||||
if(err) {
|
||||
console.error('err');
|
||||
console.log(err);
|
||||
return callback(false);
|
||||
// console.error('err');
|
||||
// console.log(err);
|
||||
return callback(err);
|
||||
}
|
||||
var ret = resp.body;
|
||||
// console.log('update note ret:');
|
||||
@@ -591,7 +585,7 @@ var Api = {
|
||||
// console.log(ret.Files);
|
||||
// 没有传IsMarkdown, 后台会传过来总为false
|
||||
delete ret['IsMarkdown'];
|
||||
callback(ret);
|
||||
callback(null, ret);
|
||||
/*
|
||||
if(Common.isOk(ret)) {
|
||||
} else {
|
||||
|
67
node_modules/note.js
generated
vendored
67
node_modules/note.js
generated
vendored
@@ -881,6 +881,8 @@ var Note = {
|
||||
needReloadContent = true;
|
||||
}
|
||||
|
||||
// console.log('...', JSON.stringify(note))
|
||||
|
||||
note.IsDirty = false;
|
||||
note.InitSync = needReloadContent;
|
||||
note.LocalIsNew = false;
|
||||
@@ -939,6 +941,7 @@ var Note = {
|
||||
allAttachs.push(everAttachsMap[serverFileId]);
|
||||
}
|
||||
}
|
||||
// console.log('allAttachs', allAttachs);
|
||||
note.Attachs = allAttachs;
|
||||
|
||||
note.ServerNoteId = note.NoteId;
|
||||
@@ -964,14 +967,15 @@ var Note = {
|
||||
delete note['CreatedTime'];
|
||||
|
||||
db.notes.update({NoteId: note.NoteId}, {$set: note}, {}, function (err, cnt) { // Callback is optional
|
||||
console.log('re:');
|
||||
console.log(err);
|
||||
console.log(cnt);
|
||||
// console.log('re:');
|
||||
// console.log(err);
|
||||
// console.log(cnt);
|
||||
|
||||
if(err) {
|
||||
console.error(err);
|
||||
callback && callback(false);
|
||||
} else {
|
||||
console.log('强制更新...');
|
||||
console.log(' 强制更新本地笔记...', note.Title);
|
||||
callback && callback(note);
|
||||
|
||||
/*
|
||||
@@ -985,6 +989,8 @@ var Note = {
|
||||
Notebook.reCountNotebookNumberNotes(note.NotebookId);
|
||||
|
||||
// 下载内容, 图片, 附件
|
||||
// console.log('..', note)
|
||||
// console.log(JSON.stringify(note), note.Attachs)
|
||||
me.syncContentAndImagesAndAttachs(note);
|
||||
}
|
||||
});
|
||||
@@ -1004,8 +1010,7 @@ var Note = {
|
||||
// note.LocalIsDelete = false;
|
||||
// note.UserId = User.getCurActiveUserId();
|
||||
//
|
||||
console.log("updateNoteForceForSendChange");
|
||||
console.log(note);
|
||||
// console.log(" updateNoteForceForSendChange", note);
|
||||
|
||||
// 如果是添加的, 因为不会传内容
|
||||
// if(isAdd) {
|
||||
@@ -1014,9 +1019,9 @@ var Note = {
|
||||
|
||||
delete note['NotebookId']; // 不要设置notebookId, 2/16 fixed
|
||||
|
||||
console.log('server data from::::');
|
||||
console.log(note.NoteId);
|
||||
console.log(note.Files);
|
||||
// console.log('server data from::::');
|
||||
// console.log(note.NoteId);
|
||||
// console.log(note.Files);
|
||||
|
||||
// 修改Imags的LocalFileId <=> FileId的映射
|
||||
File.updateImageForce(note.Files);
|
||||
@@ -1033,7 +1038,7 @@ var Note = {
|
||||
// 之前也是有attachs的, 得到之前的attachs, 进行个merge
|
||||
me.getNote(note.NoteId, function(everNote) {
|
||||
if(!everNote) {
|
||||
console.log('我靠, 没有?' + note.NoteId);
|
||||
console.log(' 没有?' + note.NoteId);
|
||||
return;
|
||||
}
|
||||
var everAttachs = everNote.Attachs || [];
|
||||
@@ -1045,8 +1050,7 @@ var Note = {
|
||||
}
|
||||
}
|
||||
note.Attachs = everAttachs;
|
||||
console.log('fix after');
|
||||
console.log(everAttachs);
|
||||
console.log(' fix after', everAttachs);
|
||||
|
||||
delete note['Files'];
|
||||
delete note['UpdatedTime'];
|
||||
@@ -1055,8 +1059,7 @@ var Note = {
|
||||
// multi: true, 避免有历史的笔记有问题
|
||||
db.notes.update({NoteId: note.NoteId}, {$set: note}, {multi: true}, function(err, n) {
|
||||
if(err || !n) {
|
||||
log('updateNoteForceForSendChange err');
|
||||
log(err);
|
||||
console.log(' updateNoteForceForSendChange err', err);
|
||||
return callback && callback(false);
|
||||
}
|
||||
return callback && callback(true);
|
||||
@@ -1118,8 +1121,8 @@ var Note = {
|
||||
// 只复制有path的
|
||||
var attachs = note.Attachs || [];
|
||||
var newAttachs = [];
|
||||
console.log('不会吧.............')
|
||||
console.log(attachs);
|
||||
// console.log('不会吧.............')
|
||||
// console.log(attachs);
|
||||
async.eachSeries(attachs, function(attach, cb) {
|
||||
if(!attach.Path) {
|
||||
return cb();
|
||||
@@ -1128,8 +1131,7 @@ var Note = {
|
||||
var filePathAttr = Common.splitFile(attach.Path);
|
||||
filePathAttr.nameNotExt += '_cp_' + attach.FileId; // 另一个
|
||||
var newPath = filePathAttr.getFullPath();
|
||||
console.log('复制文件');
|
||||
console.log(attach);
|
||||
console.log(' 复制文件', attach);
|
||||
// 复制之
|
||||
// try {
|
||||
Common.copyFile(attach.Path, newPath, function(ret) {
|
||||
@@ -1149,8 +1151,7 @@ var Note = {
|
||||
*/
|
||||
}, function() {
|
||||
note.Attachs = newAttachs;
|
||||
console.log('conflict 复制后的');
|
||||
console.log(note);
|
||||
console.log(' conflict 复制后的', note);
|
||||
db.notes.insert(note, function(err, newNote) {
|
||||
if(err) {
|
||||
callback(false);
|
||||
@@ -1256,8 +1257,9 @@ var Note = {
|
||||
var me = this;
|
||||
|
||||
var conflictNotes = noteSyncInfo.conflicts;
|
||||
console.log('fix note conflicts');
|
||||
console.log(conflictNotes);
|
||||
if (!isEmpty(conflictNotes)) {
|
||||
console.log(' fix note conflicts', conflictNotes);
|
||||
}
|
||||
// 这里为什么要同步? 因为fixConflicts后要进行send changes, 这些有冲突的不能发送changes
|
||||
conflictNotes || (conflictNotes = []);
|
||||
if(!Api) {
|
||||
@@ -1327,8 +1329,15 @@ var Note = {
|
||||
// 因为在处理冲突的时候有些成为更新了, 所以必须在此之后调用
|
||||
// console.log('has updates...');
|
||||
// console.log(noteSyncInfo.updates);
|
||||
|
||||
// 处理更新的
|
||||
Web.updateSyncNote(noteSyncInfo.updates);
|
||||
if (!Common.isEmpty(noteSyncInfo.updates)) {
|
||||
Web.updateSyncNote(noteSyncInfo.updates);
|
||||
}
|
||||
|
||||
if (!Common.isEmpty(noteSyncInfo.changeUpdates)) {
|
||||
Web.updateChangeUpdates(noteSyncInfo.changeUpdates);
|
||||
}
|
||||
});
|
||||
|
||||
// 发送改变的冲突
|
||||
@@ -1373,7 +1382,7 @@ var Note = {
|
||||
if(noteSyncInfo.changeNeedAdds) {
|
||||
var needAddNotes = noteSyncInfo.changeNeedAdds;
|
||||
for(var i in needAddNotes) {
|
||||
console.log('need add ');
|
||||
console.log(' need add note');
|
||||
var note = needAddNotes[i];
|
||||
me.setIsNew(note.NoteId);
|
||||
}
|
||||
@@ -1381,9 +1390,10 @@ var Note = {
|
||||
|
||||
// 处理添加的
|
||||
var addNotes = noteSyncInfo.adds;
|
||||
console.log('has add...');
|
||||
console.log(addNotes);
|
||||
Web.addSyncNote(addNotes);
|
||||
if (!isEmpty(addNotes)) {
|
||||
console.log(' has add note...', addNotes);
|
||||
Web.addSyncNote(addNotes);
|
||||
}
|
||||
|
||||
// 处理删除的
|
||||
Web.deleteSyncNote(noteSyncInfo.deletes);
|
||||
@@ -1467,7 +1477,6 @@ var Note = {
|
||||
});
|
||||
});
|
||||
}, function() {
|
||||
console.log(notes);
|
||||
callback(notes);
|
||||
});
|
||||
}
|
||||
@@ -1659,7 +1668,7 @@ var Note = {
|
||||
|
||||
// 附件
|
||||
var attachs = note.Attachs || [];
|
||||
for(var i in attachs) {
|
||||
for(var i = 0; i < attachs.length; ++i) {
|
||||
var attach = attachs[i];
|
||||
me.downloadAttachFromServer(note.NoteId, attach.ServerFileId, attach.FileId);
|
||||
}
|
||||
|
69
node_modules/notebook.js
generated
vendored
69
node_modules/notebook.js
generated
vendored
@@ -432,10 +432,46 @@ var Notebook = {
|
||||
// 2) 服务器替换之前
|
||||
fixConflicts: function(notebookSyncInfo, callback) {
|
||||
var me = this;
|
||||
|
||||
|
||||
// 服务器没有, 但是是发送更新的, 所以需要作为添加
|
||||
if(notebookSyncInfo.changeNeedAdds) {
|
||||
var needAddNotebooks = notebookSyncInfo.changeNeedAdds;
|
||||
for(var i in needAddNotebooks) {
|
||||
var notebook = needAddNotebooks[i];
|
||||
me.setIsNew(notebook.NotebookId);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理添加的
|
||||
var adds = notebookSyncInfo.adds;
|
||||
if (!isEmpty(adds)) {
|
||||
console.log(' has add notebook');
|
||||
console.log(adds);
|
||||
Web.addSyncNotebook(adds);
|
||||
}
|
||||
|
||||
if (!isEmpty(notebookSyncInfo.changeAdds)) {
|
||||
console.log(' has changeAdds notebook')
|
||||
console.log(notebookSyncInfo.changeAdds)
|
||||
Web.addChangeNotebook(notebookSyncInfo.changeAdds);
|
||||
}
|
||||
|
||||
if (!isEmpty(notebookSyncInfo.updates)) {
|
||||
console.log(' has updates notebook');
|
||||
console.log(notebookSyncInfo.updates);
|
||||
// 处理更新的
|
||||
Web.updateSyncNotebook(notebookSyncInfo.updates);
|
||||
}
|
||||
|
||||
if (!isEmpty(notebookSyncInfo.deletes)) {
|
||||
// 处理删除的
|
||||
Web.deleteSyncNotebook(notebookSyncInfo.deletes);
|
||||
}
|
||||
|
||||
// 没有冲突的, 因为notebook不处理冲突
|
||||
// 处理冲突
|
||||
var conflictNotebooks = notebookSyncInfo.conflicts || [];
|
||||
console.log('fix notebook conflicts');
|
||||
conflictNotebooks.length && console.log(' fix notebook conflicts');
|
||||
async.eachSeries(conflictNotebooks, function(notebook, cb) {
|
||||
/*
|
||||
var noteId = note.NoteId;
|
||||
@@ -458,35 +494,6 @@ var Notebook = {
|
||||
// 最后调用
|
||||
callback && callback();
|
||||
});
|
||||
|
||||
// 服务器没有, 但是是发送更新的, 所以需要作为添加
|
||||
if(notebookSyncInfo.changeNeedAdds) {
|
||||
var needAddNotebooks = notebookSyncInfo.changeNeedAdds;
|
||||
for(var i in needAddNotebooks) {
|
||||
var notebook = needAddNotebooks[i];
|
||||
me.setIsNew(notebook.NotebookId);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理添加的
|
||||
var adds = notebookSyncInfo.adds;
|
||||
log('has add...');
|
||||
log(adds);
|
||||
Web.addSyncNotebook(adds);
|
||||
|
||||
log('has changeAdds')
|
||||
log(notebookSyncInfo.changeAdds)
|
||||
Web.addChangeNotebook(notebookSyncInfo.changeAdds);
|
||||
|
||||
|
||||
log('has updates...');
|
||||
log(notebookSyncInfo);
|
||||
log(notebookSyncInfo.updates);
|
||||
// 处理更新的
|
||||
Web.updateSyncNotebook(notebookSyncInfo.updates);
|
||||
|
||||
// 处理删除的
|
||||
Web.deleteSyncNotebook(notebookSyncInfo.deletes);
|
||||
},
|
||||
|
||||
// 在send delete笔记时成功
|
||||
|
177
node_modules/sync.js
generated
vendored
177
node_modules/sync.js
generated
vendored
@@ -33,7 +33,7 @@ var Sync = {
|
||||
// 同步的信息, 返回给调用者
|
||||
_syncInfo: {
|
||||
notebook: {changeAdds: [], changeConflicts: [], adds: [], deletes: [], updates: []},
|
||||
note: {changeAdds: [], changeConflicts: [], adds: [], deletes: [], updates: [], conflicts: []},
|
||||
note: {changeAdds: [], changeConflicts: [], adds: [], deletes: [], updates: [], conflicts: [], errors: []},
|
||||
tag: {}
|
||||
},
|
||||
/*
|
||||
@@ -85,7 +85,7 @@ var Sync = {
|
||||
// 同步信息
|
||||
me._syncInfo = {
|
||||
notebook: {ok: false, changeAdds: [], changeConflicts: [], changeNeedAdds: [], adds: [], deletes: [], updates: []},
|
||||
note: {ok: false, adds: [], changeAdds: [], changeConflicts: [], changeUpdates:[], changeNeedAdds: [], deletes: [], updates: [], conflicts: []},
|
||||
note: {ok: false, adds: [], changeAdds: [], changeConflicts: [], changeUpdates:[], changeNeedAdds: [], deletes: [], updates: [], conflicts: [], errors: []},
|
||||
tag: {ok: false, adds: [], changeAdds: [], changeConflicts: [], changeNeedAdds: [], deletes: [], updates: [], conflicts: []},
|
||||
};
|
||||
|
||||
@@ -175,7 +175,8 @@ var Sync = {
|
||||
// console.log(notebook);
|
||||
Notebook.getNotebookIdByServerNotebookId(notebookId, function(localNotebookId) {
|
||||
Notebook.deleteNotebookForce(notebookId, function() {
|
||||
me._syncInfo.notebook.deletes.push(localNotebookId);
|
||||
// me._syncInfo.notebook.deletes.push(localNotebookId);
|
||||
me.fixSynced('notebook', 'deletes', localNotebookId);
|
||||
canCall();
|
||||
})
|
||||
});
|
||||
@@ -188,7 +189,8 @@ var Sync = {
|
||||
console.log('add addNotebookForce...')
|
||||
// TODO
|
||||
Notebook.addNotebookForce(notebook, function(notebook) {
|
||||
me._syncInfo.notebook.adds.push(notebook);
|
||||
// me._syncInfo.notebook.adds.push(notebook);
|
||||
me.fixSynced('notebook', 'adds', notebook);
|
||||
canCall();
|
||||
});
|
||||
} else {
|
||||
@@ -207,7 +209,8 @@ var Sync = {
|
||||
// 这里都是用服务器端的数据, 不处理冲突
|
||||
Notebook.updateNotebookForce(notebook, notebookLocal, function(notebook) {
|
||||
if(notebook) {
|
||||
me._syncInfo.notebook.updates.push(notebook);
|
||||
// me._syncInfo.notebook.updates.push(notebook);
|
||||
me.fixSynced('notebook', 'updates', notebook);
|
||||
}
|
||||
canCall();
|
||||
})
|
||||
@@ -223,7 +226,7 @@ var Sync = {
|
||||
return;
|
||||
}
|
||||
Api.getSyncNotebooks(afterUsn, me._notebookMaxEntry, function(notebooks) {
|
||||
console.log('syncNotebook')
|
||||
console.log(' syncNotebook')
|
||||
// console.log(notebooks);
|
||||
if(Common.isOk(notebooks)) {
|
||||
me._totalSyncNotebookNum += notebooks.length;
|
||||
@@ -237,7 +240,7 @@ var Sync = {
|
||||
me.updateSyncUsn('NotebookUsn', last.Usn);
|
||||
|
||||
} else {
|
||||
console.log('no more');
|
||||
console.log(' no more notebooks');
|
||||
me._syncNotebookIsLastChunk = true;
|
||||
me._syncNotebookToLocal(notebooks, callback);
|
||||
|
||||
@@ -255,7 +258,6 @@ var Sync = {
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
//-------------
|
||||
// note
|
||||
//-------------
|
||||
@@ -313,11 +315,11 @@ var Sync = {
|
||||
|
||||
// 1) 服务器端删除了, 本地肯定删除
|
||||
if(note.IsDeleted) {
|
||||
log('delete: ');
|
||||
log(note);
|
||||
console.log(' delete: ', note);
|
||||
Note.getNoteIdByServerNoteId(noteId, function(localNoteId) {
|
||||
Note.deleteNoteForce(noteId, function() {
|
||||
me._syncInfo.note.deletes.push(localNoteId);
|
||||
// me._syncInfo.note.deletes.push(localNoteId);
|
||||
me.fixSynced('note', 'deletes', localNoteId);
|
||||
canCall();
|
||||
});
|
||||
});
|
||||
@@ -327,15 +329,16 @@ var Sync = {
|
||||
Note.getNoteByServerNoteId(noteId, function(noteLocal) {
|
||||
// 2.1 本地没有, 表示是新建
|
||||
if(!noteLocal) {
|
||||
console.log('add: ...');
|
||||
console.log(' add note', note);
|
||||
Note.addNoteForce(note, function(note) {
|
||||
me._syncInfo.note.adds.push(note);
|
||||
// me._syncInfo.note.adds.push(note);
|
||||
me.fixSynced('note', 'adds', note);
|
||||
return canCall();
|
||||
});
|
||||
} else {
|
||||
// 如果Usn一样, 表示服务器端并没有修改
|
||||
if(noteLocal.Usn === note.Usn) {
|
||||
console.log('note 如果Usn一样, 表示服务器端并没有修改');
|
||||
console.log(' note 如果Usn一样, 表示服务器端并没有修改');
|
||||
return canCall();
|
||||
}
|
||||
|
||||
@@ -343,7 +346,7 @@ var Sync = {
|
||||
// 冲突, 将本地修改的笔记复制一份(设置冲突字段, ConflictNoteId), 远程的覆盖本地的
|
||||
// 新方法: 冲突后, 得到最新内容, 看是否与本地内容一致, 如果一致, 则不冲突, 其它数据用服务器上的
|
||||
if(noteLocal.IsDirty) {
|
||||
console.log('note 冲突.... serverNoteId: ' + noteId);
|
||||
console.log(' note 冲突 serverNoteId: ' + noteId, note.Title);
|
||||
// console.log(noteLocal.NoteId);
|
||||
// console.log(noteLocal.IsDirty);
|
||||
// console.log(noteLocal);
|
||||
@@ -354,7 +357,8 @@ var Sync = {
|
||||
// 表示没有获取到content, 则只能标志为冲突了
|
||||
// 内容不一样, 也标为冲突
|
||||
if (content === false || content != noteLocal.Content) {
|
||||
me._syncInfo.note.conflicts.push({server: note, local: noteLocal});
|
||||
// me._syncInfo.note.conflicts.push({server: note, local: noteLocal});
|
||||
me.fixSynced('note', 'conflicts', {server: note, local: noteLocal});
|
||||
}
|
||||
// 否则, 内容一样, 标为不冲突, 需要更新
|
||||
else {
|
||||
@@ -363,7 +367,8 @@ var Sync = {
|
||||
// 服务器是最新的, 本地没动过, 则覆盖之
|
||||
Note.updateNoteForce(note, function(note) {
|
||||
if(note) {
|
||||
me._syncInfo.note.updates.push(note);
|
||||
// me._syncInfo.note.updates.push(note);
|
||||
me.fixSynced('note', 'updates', note);
|
||||
}
|
||||
canCall();
|
||||
}, false);
|
||||
@@ -377,7 +382,8 @@ var Sync = {
|
||||
// 服务器是最新的, 本地没动过, 则覆盖之
|
||||
Note.updateNoteForce(note, function(note) {
|
||||
if(note) {
|
||||
me._syncInfo.note.updates.push(note);
|
||||
// me._syncInfo.note.updates.push(note);
|
||||
me.fixSynced('note', 'updates', note);
|
||||
}
|
||||
canCall();
|
||||
});
|
||||
@@ -394,9 +400,10 @@ var Sync = {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(' pull notes from server...');
|
||||
Api.getSyncNotes(afterUsn, me._noteMaxEntry, function(notes) {
|
||||
// console.log('syncNote---');
|
||||
// console.log(notes);
|
||||
console.log(' notes:', notes);
|
||||
if(Common.isOk(notes)) {
|
||||
me._totalSyncNoteNum += notes.length;
|
||||
// 证明可能还有要同步的
|
||||
@@ -413,7 +420,7 @@ var Sync = {
|
||||
me.updateSyncUsn('NoteUsn', last.Usn);
|
||||
|
||||
} else {
|
||||
log('no more');
|
||||
console.log(' no more notes');
|
||||
me._syncNoteIsLastChunk = true;
|
||||
me._syncNoteToLocal(notes, callback);
|
||||
|
||||
@@ -426,8 +433,7 @@ var Sync = {
|
||||
// 同步失败
|
||||
me._syncInfo.note.ok = false;
|
||||
me._syncInfo.note.msg = "cann't get all chunks";
|
||||
console.error('eeeeeeeeeeeeeeeeeerrror')
|
||||
console.error(notes);
|
||||
console.error(' pull notes error', notes)
|
||||
callback && callback(false);
|
||||
}
|
||||
});
|
||||
@@ -492,7 +498,8 @@ var Sync = {
|
||||
log('delete tag: ');
|
||||
log(tag);
|
||||
Tag.deleteTag(tag.Tag, function() {
|
||||
me._syncInfo.tag.deletes.push(tag.Tag);
|
||||
// me._syncInfo.tag.deletes.push(tag.Tag);
|
||||
me.fixSynced('tag', 'deletes', tag.Tag);
|
||||
canCall();
|
||||
}, true);
|
||||
return;
|
||||
@@ -503,7 +510,8 @@ var Sync = {
|
||||
if(!tagLocal) {
|
||||
log('add tag: ...')
|
||||
Tag.addOrUpdateTag(tag.Tag, function(tagAdded) {
|
||||
me._syncInfo.tag.adds.push(tagAdded);
|
||||
// me._syncInfo.tag.adds.push(tagAdded);
|
||||
me.fixSynced('tag', 'adds', tagAdded);
|
||||
return canCall();
|
||||
}, true, usn);
|
||||
} else {
|
||||
@@ -547,7 +555,7 @@ var Sync = {
|
||||
// 同步失败
|
||||
me._syncInfo.tag.ok = false;
|
||||
me._syncInfo.tag.msg = "cann't get all chunks";
|
||||
console.error('tags eeeeeeeeeeeeeeeeeerrror')
|
||||
console.error(' sync tags error...')
|
||||
// console.log(tags);
|
||||
callback && callback(false);
|
||||
}
|
||||
@@ -636,8 +644,25 @@ var Sync = {
|
||||
});
|
||||
},
|
||||
|
||||
_notebookWeb: null,
|
||||
_noteWeb: null,
|
||||
// 处理同步好的之后的
|
||||
// mainType == notebook, note, tag
|
||||
// type = changeAdds, changeConflicts, adds, deletes, updates, conflicts, errors,
|
||||
fixSynced: function (mainType, type, data) {
|
||||
var o = {};
|
||||
if (!Common.isArray(data)) {
|
||||
data = [data];
|
||||
}
|
||||
o[type] = data;
|
||||
if (mainType == 'notebook') {
|
||||
Notebook.fixConflicts(o);
|
||||
} else if (mainType == 'note') {
|
||||
console.error('........');
|
||||
Note.fixConflicts(o);
|
||||
} else {
|
||||
Web.addOrDeleteTagFromSync(o);
|
||||
}
|
||||
},
|
||||
|
||||
// 处理冲突
|
||||
fixConflicts: function(callback) {
|
||||
var me = this;
|
||||
@@ -648,6 +673,7 @@ var Sync = {
|
||||
var tag = me._syncInfo.tag;
|
||||
|
||||
// 如果是incSync, 则要前端处理
|
||||
// 不是fullSync
|
||||
if(me.incrSyncStart) {
|
||||
|
||||
Notebook.fixConflicts(me._syncInfo.notebook);
|
||||
@@ -656,7 +682,7 @@ var Sync = {
|
||||
// 避免无限循环, 别send changes了
|
||||
if(!me._needIncrSyncAgain) {
|
||||
// alert("?")
|
||||
console.log(">>>>>>>> not needIncrSyncAgain>>>>>>>>>>>>>>>>> ")
|
||||
console.log(" not needIncrSyncAgain")
|
||||
// send changes
|
||||
callback && callback();
|
||||
} else {
|
||||
@@ -672,6 +698,7 @@ var Sync = {
|
||||
Web.addOrDeleteTagFromSync(tag);
|
||||
}
|
||||
},
|
||||
|
||||
fixConflictsForSendChanges: function(callback) {
|
||||
var me = this;
|
||||
me.fixConflicts(function() {
|
||||
@@ -724,39 +751,39 @@ var Sync = {
|
||||
|
||||
// 得到当前LastSyncUsn
|
||||
User.getLastSyncState(function(lastSyncUsn, lastSyncTime) {
|
||||
console.log('%cstep1 getLastSyncState', 'color: #68bc7a')
|
||||
|
||||
// 没有上次同步的时间, 则需要进行一次全量同步, 不可能会发生
|
||||
if(!lastSyncUsn) {
|
||||
console.error('getLastSyncState error!!');
|
||||
console.error(' getLastSyncState error!!');
|
||||
me.setSyncFinished();
|
||||
return;
|
||||
}
|
||||
|
||||
// 先从服务器上得到usn, 与本地的判断, 是否需要pull
|
||||
console.log('先从服务器上得到usn, 与本地的判断, 是否需要pull');
|
||||
Api.getLastSyncState(function(serverState) {
|
||||
if(!serverState) {
|
||||
console.error('get Server LastSyncState error!!');
|
||||
console.error(' get Server LastSyncState error!!');
|
||||
me.setSyncFinished();
|
||||
return;
|
||||
}
|
||||
console.log(serverState.LastSyncUsn + ' ' + lastSyncUsn);
|
||||
console.log(' get Server LastSyncState ret', serverState.LastSyncUsn + ' ' + lastSyncUsn);
|
||||
if(serverState.LastSyncUsn > lastSyncUsn) {
|
||||
// 需要同步笔记本
|
||||
console.log('需要pull');
|
||||
|
||||
console.log('%cstep2 pull', 'color: #68bc7a')
|
||||
// 同步笔记本
|
||||
me.syncNotebook(lastSyncUsn, function(ok) {
|
||||
if(ok) {
|
||||
console.log('-------incr notebook ok-----------' + lastSyncUsn);
|
||||
console.log(' incr notebook ok', lastSyncUsn);
|
||||
me.addSyncProcessStatus(10);
|
||||
console.log(' incr note start');
|
||||
// 同步笔记
|
||||
me.syncNote(lastSyncUsn, function(ok) {
|
||||
if(ok) {
|
||||
console.log('-------incr note ok-----------' + lastSyncUsn);
|
||||
console.log(' incr note ok', lastSyncUsn);
|
||||
me.addSyncProcessStatus(30);
|
||||
// 同步标签
|
||||
me.syncTag(lastSyncUsn, function() {
|
||||
console.log('-------incr tag ok-----------' + lastSyncUsn);
|
||||
console.log(' incr tag ok', lastSyncUsn);
|
||||
me.addSyncProcessStatus(10);
|
||||
// 更新上次同步时间
|
||||
me.updateLastSyncState(function() {
|
||||
@@ -765,7 +792,7 @@ var Sync = {
|
||||
});
|
||||
});
|
||||
} else {
|
||||
console.log('-------incr note not ok-----------')
|
||||
console.log(' incr note not ok')
|
||||
me.fixConflicts();
|
||||
}
|
||||
});
|
||||
@@ -775,7 +802,7 @@ var Sync = {
|
||||
});
|
||||
|
||||
} else {
|
||||
console.log('不需要pull');
|
||||
console.log('%cstep2 不需要pull, skip', 'color: #68bc7a')
|
||||
me.addSyncProcessStatus(50);
|
||||
me.sendChanges(again);
|
||||
}
|
||||
@@ -790,10 +817,14 @@ var Sync = {
|
||||
// 发送笔记本的更改
|
||||
sendNotebookChanges: function(callback) {
|
||||
var me = this;
|
||||
console.log(' 3.1: sendNotebookChanges')
|
||||
// 获取所有笔记本的更改
|
||||
Notebook.getDirtyNotebooks(function(notebooks) {
|
||||
console.log('dirty notebooks');
|
||||
console.log(notebooks);
|
||||
if (!Common.isEmpty(notebooks)) {
|
||||
console.log(' dirty notebooks:', notebooks);
|
||||
} else {
|
||||
console.log(' no dirty notebooks');
|
||||
}
|
||||
if(!notebooks) {
|
||||
callback && callback();
|
||||
} else {
|
||||
@@ -805,7 +836,7 @@ var Sync = {
|
||||
// 本地既是新的, 又是删除的, 删除本地的, 不要同步
|
||||
// 5/4
|
||||
if(notebook.LocalIsNew && notebook.LocalIsDelete) {
|
||||
console.log('笔记本既是新的, 又是删除的, 不同步, 直接删除本地的');
|
||||
console.log(' 笔记本既是新的, 又是删除的, 不同步, 直接删除本地的');
|
||||
Notebook.deleteLocalNotebook(notebook.NotebookId);
|
||||
return cb();
|
||||
}
|
||||
@@ -896,10 +927,14 @@ var Sync = {
|
||||
// 发送笔记本的更改
|
||||
sendNoteChanges: function(callback) {
|
||||
var me = this;
|
||||
console.log(' 3.2: sendNoteChanges');
|
||||
// 获取所有笔记本的更改
|
||||
Note.getDirtyNotes(function(notes) {
|
||||
console.error('>>>>>>>>>>>> dirty notes <<<<<<<<<<<<<<< ');
|
||||
console.log(notes);
|
||||
if (!Common.isEmpty(notes)) {
|
||||
console.log(' dirty notes:', notes);
|
||||
} else {
|
||||
console.log(' no dirty notes');
|
||||
}
|
||||
if(!notes) {
|
||||
callback && callback();
|
||||
} else {
|
||||
@@ -908,7 +943,12 @@ var Sync = {
|
||||
async.eachSeries(notes, function(note, cb) {
|
||||
|
||||
if (note.InitSync) {
|
||||
console.error('InitSync is Dirty');
|
||||
console.log(' InitSync is Dirty', note);
|
||||
return cb();
|
||||
}
|
||||
|
||||
if (note.ConflictNoteId && !note.ConflictFixed) {
|
||||
console.log(' 未解决的冲突不同步', note.Title);
|
||||
return cb();
|
||||
}
|
||||
|
||||
@@ -916,10 +956,13 @@ var Sync = {
|
||||
// 是新的, 且不是trash和删除的
|
||||
if(!note.IsTrash && !note.LocalIsDelete) {
|
||||
// 添加, newNote的返回不会很多值(server端)
|
||||
Api.addNote(note, function(newNote) {
|
||||
if(!Common.isOk(newNote)) {
|
||||
Api.addNote(note, function(err, newNote) {
|
||||
if(err || !Common.isOk(newNote)) {
|
||||
console.log(' 添加笔记失败!', err, newNote);
|
||||
me._syncInfo.note.errors.push({err: err, ret: newNote, note: note});
|
||||
return cb();
|
||||
}
|
||||
console.log(' 添加笔记成功!', note.Title);
|
||||
|
||||
newNote.ServerNoteId = newNote.NoteId;
|
||||
newNote.NoteId = note.NoteId;
|
||||
@@ -938,13 +981,13 @@ var Sync = {
|
||||
// 5/4
|
||||
// 本地已经删除了, 则彻底删除之
|
||||
else if(note.LocalIsDelete) {
|
||||
console.log('既是新的, 又是删除的, 则删除笔记的');
|
||||
console.log(' 既是新的, 又是删除的, 则删除笔记的');
|
||||
Note.deleteLocalNote(note.NoteId);
|
||||
return cb();
|
||||
}
|
||||
// isTrash, 不同步, 不删除
|
||||
else {
|
||||
console.log('既是新的, 又是trash的, 不要同步');
|
||||
console.log(' 既是新的, 又是trash的, 不要同步');
|
||||
return cb();
|
||||
}
|
||||
}
|
||||
@@ -960,13 +1003,12 @@ var Sync = {
|
||||
}
|
||||
else {
|
||||
// 更新
|
||||
Api.updateNote(note, function(ret) {
|
||||
if(!Common.isOk(ret)) {
|
||||
console.log('updateNote eeeeeeeeeeror');
|
||||
console.log(ret);
|
||||
Api.updateNote(note, function(err, ret) {
|
||||
if(err || !Common.isOk(ret)) {
|
||||
console.log(' update error:' + note.Title, ret);
|
||||
if(typeof ret == 'object') {
|
||||
if(ret.Msg == 'conflict') {
|
||||
console.error('updateNote 冲突-----------');
|
||||
console.error(' updateNote 冲突');
|
||||
|
||||
// 这种情况有很少见, 原因是先pull, 肯定会pull过来
|
||||
// 处理方法和pull一样, 看内容是否一样
|
||||
@@ -999,16 +1041,21 @@ var Sync = {
|
||||
}
|
||||
// 其它错误, 不加, notImage 导致不能终止
|
||||
else {
|
||||
console.error(' updateNote error', err);
|
||||
me._syncInfo.note.errors.push({err: err, ret: ret, note: note});
|
||||
cb();
|
||||
}
|
||||
}
|
||||
// 更新失败了, 服务器返回异常
|
||||
else {
|
||||
console.error(' updateNote error', err);
|
||||
me._syncInfo.note.errors.push({err: err, ret: ret, note: note});
|
||||
cb();
|
||||
}
|
||||
}
|
||||
// 更新成功
|
||||
else {
|
||||
console.log(' 更新成功: ', note.Title);
|
||||
ret.ServerNoteId = ret.NoteId;
|
||||
ret.NoteId = note.NoteId;
|
||||
Note.updateNoteForceForSendChange(ret, false);
|
||||
@@ -1028,12 +1075,15 @@ var Sync = {
|
||||
},
|
||||
// 发送标签改变
|
||||
sendTagChanges: function(callback) {
|
||||
log('send note changes');
|
||||
console.log(' 3.3: sendTagChanges');
|
||||
var me = this;
|
||||
// 获取所有笔记本的更改
|
||||
Tag.getDirtyTags(function(tags) {
|
||||
console.log('dirty tags');
|
||||
console.log(tags);
|
||||
if (!Common.isEmpty(tags)) {
|
||||
console.log(' dirty tags:', tags);
|
||||
} else {
|
||||
console.log(' no dirty tags');
|
||||
}
|
||||
if(!tags) {
|
||||
callback && callback();
|
||||
} else {
|
||||
@@ -1075,16 +1125,16 @@ var Sync = {
|
||||
// again, 再一次sync, 不要send changes
|
||||
sendChanges: function(again) {
|
||||
var me = this;
|
||||
console.log('send changes before...')
|
||||
console.log('%cstep3 send changes', 'color: #68bc7a')
|
||||
// 先处理冲突, 可以同时进行
|
||||
if(again) {
|
||||
console.error('send changes again....');
|
||||
console.log(' send changes again....');
|
||||
me.fixConflictsForSendChanges(function(){});
|
||||
return;
|
||||
}
|
||||
me.fixConflicts(function() {
|
||||
// send changes
|
||||
console.log('send changes');
|
||||
console.log(' send changes');
|
||||
me._initSyncInfo(); // 重新初始化[]
|
||||
async.series([
|
||||
function(cb) {
|
||||
@@ -1103,13 +1153,12 @@ var Sync = {
|
||||
|
||||
// 重新再来一次增量同步
|
||||
if(me._needIncrSyncAgain) {
|
||||
console.error('-- _needIncrSyncAgain -- ')
|
||||
console.log('send changes 后解决冲突, 先fix, 再incSync again');
|
||||
console.error(' needIncrSyncAgain')
|
||||
me.fixConflictsForSendChanges(function() {
|
||||
me.incrSync(true);
|
||||
});
|
||||
} else {
|
||||
console.log('send changes 后解决冲突');
|
||||
console.log(' send changes 后解决冲突');
|
||||
me.fixConflictsForSendChanges(function() {
|
||||
});
|
||||
}
|
||||
|
9
node_modules/web.js
generated
vendored
9
node_modules/web.js
generated
vendored
@@ -20,6 +20,11 @@ var Web = {
|
||||
me.Note && me.Note.notLogin();
|
||||
},
|
||||
|
||||
needUpgradeAccount: function () {
|
||||
var me = this;
|
||||
me.Note && me.Note.needUpgradeAccount();
|
||||
},
|
||||
|
||||
alertWeb: function(msg) {
|
||||
var me = this;
|
||||
me.Note && me.Note.alertWeb(msg);
|
||||
@@ -66,6 +71,10 @@ var Web = {
|
||||
var me = this;
|
||||
me.Note.updateSync(notes);
|
||||
},
|
||||
updateChangeUpdates: function (notes) {
|
||||
var me = this;
|
||||
me.Note.updateChangeUpdates(notes);
|
||||
},
|
||||
deleteSyncNote: function(notes) {
|
||||
var me = this;
|
||||
me.Note.deleteSync(notes);
|
||||
|
@@ -21,7 +21,7 @@ Note.notebookIds = {}; // notebookId => true
|
||||
|
||||
// 初始化模版字符串
|
||||
// blog, star, settings
|
||||
var itemIsBlog = '<div class="item-blog"><i class="fa fa-bold" title="' + getMsg('Blog') + '"></i></div><div class="item-conflict-info"><i class="fa fa-bug" title="' + getMsg('Conflict') + '!!"></i></div><div class="item-star"><i class="fa fa-star-o" title="' + getMsg('Star') + '"></i></div><div class="item-setting"><i class="fa fa-cog" title="' + getMsg('Setting') + '"></i></div>';
|
||||
var itemIsBlog = '<div class="item-blog"><i class="fa fa-bold" title="' + getMsg('Blog') + '"></i></div><div class="item-conflict-info"><i class="fa fa-bug" title="' + getMsg('Conflict') + '!!"></i></div><div class="item-star"><i class="fa fa-star-o" title="' + getMsg('Star') + '"></i></div><div class="item-setting"><i class="fa fa-cog" title="' + getMsg('Setting') + '"></i></div><span class="dirty-bg"></span>';
|
||||
Note.itemTplNoImg = '<li href="#" class="item ?" data-seq="?" noteId="?">';
|
||||
Note.itemTplNoImg += itemIsBlog + '<div class="item-desc"><p class="item-title">?</p><p class="item-info"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-clock-o"></i> <span class="updated-time">?</span></p><p class="desc">?</p></div></li>';
|
||||
Note.itemTpl = '<li href="#" class="item ? item-image" data-seq="?" noteId="?"><div class="item-thumb" style=""><img src="?"/></div>';
|
||||
@@ -445,6 +445,10 @@ Note.getImgSrc = function(content) {
|
||||
return "";
|
||||
};
|
||||
|
||||
Note.setNoteDirty = function (noteId) {
|
||||
var $leftNoteNav = $(tt('[noteId="?"]', noteId));
|
||||
$leftNoteNav.addClass('item-dirty');
|
||||
};
|
||||
|
||||
// 如果当前的改变了, 就保存它
|
||||
// 以后要定时调用
|
||||
@@ -506,6 +510,8 @@ Note.curChangedSaveIt = function(force, callback) {
|
||||
Pjax.changeNote(ret);
|
||||
}
|
||||
|
||||
me.setNoteDirty(hasChanged.NoteId);
|
||||
|
||||
callback && callback(ret);
|
||||
}, force);
|
||||
|
||||
@@ -799,9 +805,13 @@ Note.renderChangedNote = function(changedNote) {
|
||||
// 如果标题改了, 如果也在star列表中, 那也要改star的标题啊
|
||||
Note.changeStarNoteTitle(changedNote.NoteId, trimTitle(changedNote.Title));
|
||||
}
|
||||
if($leftNoteNav.hasClass("list-item")) {
|
||||
return; //list view只需要更新title
|
||||
}
|
||||
|
||||
// $leftNoteNav.addClass('item-dirty');
|
||||
|
||||
if($leftNoteNav.hasClass("list-item")) {
|
||||
return; //list view只需要更新title
|
||||
}
|
||||
|
||||
if(changedNote.Desc) {
|
||||
$leftNoteNav.find(".desc").html(trimTitle(changedNote.Desc));
|
||||
}
|
||||
@@ -986,9 +996,6 @@ Note.renderNotes = function(notes, forNewNote, isShared) {
|
||||
|
||||
Note._getNoteHtmlObjct = function(note, isShared) {
|
||||
var baseClasses = "item-my";
|
||||
if(isShared) {
|
||||
baseClasses = "item-shared";
|
||||
}
|
||||
var classes = baseClasses;
|
||||
if (note.IsDeleted) {
|
||||
console.error('_getNoteHtmlObjct note.IsDeleted');
|
||||
@@ -1015,19 +1022,20 @@ Note._getNoteHtmlObjct = function(note, isShared) {
|
||||
},
|
||||
Note._renderNotes = function(notes, forNewNote, isShared, tang) { // 第几趟
|
||||
var baseClasses = "item-my";
|
||||
if(isShared) {
|
||||
baseClasses = "item-shared";
|
||||
}
|
||||
|
||||
|
||||
var len = notes.length;
|
||||
for(var i = (tang-1)*20; i < len && i < tang*20; ++i) {
|
||||
var classes = baseClasses;
|
||||
|
||||
if(!forNewNote && i == 0) {
|
||||
classes += " item-active";
|
||||
}
|
||||
var note = notes[i];
|
||||
note.Title = trimTitle(note.Title);
|
||||
|
||||
if (note.IsDirty) {
|
||||
classes += " item-dirty";
|
||||
}
|
||||
if (note.IsDeleted) {
|
||||
console.error('note.IsDeleted');
|
||||
continue;
|
||||
@@ -1123,9 +1131,6 @@ Note.newNote = function(notebookId, isShare, fromUserId, isMarkdown) {
|
||||
var newItem = "";
|
||||
|
||||
var baseClasses = "item-my item-active";
|
||||
if(isShare) {
|
||||
baseClasses = "item-shared";
|
||||
}
|
||||
|
||||
var notebook = Notebook.getNotebook(notebookId);
|
||||
var notebookTitle = notebook ? notebook.Title : "";
|
||||
@@ -1177,12 +1182,14 @@ Note.showSpin = function() {
|
||||
me._syncRefreshE.addClass('fa-spin');
|
||||
|
||||
// 如果超过30秒还在转, 证明有问题了
|
||||
/*
|
||||
setTimeout(function() {
|
||||
if(me._syncRefreshE.hasClass('fa-spin')) {
|
||||
me._syncRefreshE.removeClass('fa-spin');
|
||||
Note.hideSyncProgress();
|
||||
}
|
||||
}, 30 * 1000);
|
||||
*/
|
||||
|
||||
// 禁止自动保存
|
||||
me.stopInterval(true);
|
||||
@@ -1243,17 +1250,33 @@ Note.notLogin = function() {
|
||||
me.hideSpin();
|
||||
SyncService.setSyncFinished();
|
||||
me._syncWarningE.data('reason', 'notLogin');
|
||||
me._syncWarningE.attr('title', 'You need sign in leanote');
|
||||
me._syncWarningE.attr('title', getMsg('You need to sign in Leanote'));
|
||||
};
|
||||
Note.needUpgradeAccount = function () {
|
||||
var me = this;
|
||||
me._syncWarningE.show();
|
||||
me.hideSpin();
|
||||
SyncService.setSyncFinished();
|
||||
me._syncWarningE.data('reason', 'NEED-UPGRADE-ACCOUNT');
|
||||
me._syncWarningE.attr('title', getMsg('You need to upgrade Leanote account'));
|
||||
};
|
||||
// 点击感叹号, 处理错误
|
||||
Note.fixNetOrAuthError = function() {
|
||||
var me = this;
|
||||
var reason = me._syncWarningE.data('reason');
|
||||
if(reason == 'unConnected') {
|
||||
alert('Network error, please check out your network.');
|
||||
|
||||
if (reason == 'unConnected') {
|
||||
alert(getMsg('Network error, please check out your network.'));
|
||||
|
||||
} else if(reason == 'notLogin') {
|
||||
alert(getMsg('You need to sign in Leanote'));
|
||||
// 弹出登录框登录之, 重新弹出
|
||||
window.open('login.html?ref=needLogin');
|
||||
|
||||
// 需要升级Leanote
|
||||
} else if (reason == 'NEED-UPGRADE-ACCOUNT') {
|
||||
alert(getMsg('You need to upgrade Leanote account'));
|
||||
openExternal('https://leanote.com/pricing#buy');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3426,7 +3449,7 @@ Note.updateSync = function(notes) {
|
||||
|
||||
var curNotebookIsTrash = Notebook.curNotebookIsTrash();
|
||||
|
||||
for(var i in notes) {
|
||||
for(var i = 0; i < notes.length; ++i) {
|
||||
var note = notes[i];
|
||||
note.InitSync = true; // 需要重新获取内容
|
||||
Note.addNoteCache(note);
|
||||
@@ -3442,13 +3465,17 @@ Note.updateSync = function(notes) {
|
||||
Note.reRenderNote(Note.curNoteId);
|
||||
}
|
||||
|
||||
var target = $(tt('[noteId="?"]', note.NoteId));
|
||||
if(target.length) {
|
||||
target.removeClass('item-dirty');
|
||||
}
|
||||
|
||||
// 设置当前是否是博客
|
||||
// alert(note.NoteId + " " + note.IsBlog);
|
||||
Note.setNoteBlogVisible(note.NoteId, note.IsBlog);
|
||||
|
||||
// 如果是trash, 且当前不在trash目录下, 且有该笔记, 则删除之
|
||||
if(!curNotebookIsTrash && note.IsTrash) {
|
||||
var target = $(tt('[noteId="?"]', note.NoteId));
|
||||
// 前端缓存也要删除!!
|
||||
// 先删除, 不然changeToNext()之前会先保存现在的, 导致僵尸note
|
||||
Note.deleteCache(note.NoteId)
|
||||
@@ -3512,4 +3539,18 @@ Note.deleteSync = function(notes) {
|
||||
// 前端缓存也要删除!!
|
||||
Note.deleteCache(noteId);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 发送改变成功了的
|
||||
Note.updateChangeUpdates = function (notes) {
|
||||
if(isEmpty(notes)) {
|
||||
return;
|
||||
}
|
||||
for(var i in notes) {
|
||||
var note = notes[i];
|
||||
var target = $(tt('[noteId="?"]', note.NoteId));
|
||||
if(target.length) {
|
||||
target.removeClass('item-dirty');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@@ -2153,6 +2153,13 @@ function userMenu(allUsers) {
|
||||
}
|
||||
});
|
||||
|
||||
this.debug = new gui.MenuItem({
|
||||
label: getMsg('Toggle DevTools'),
|
||||
click: function(e) {
|
||||
gui.win.toggleDevTools();
|
||||
}
|
||||
});
|
||||
|
||||
this.menu.append(this.email);
|
||||
if (!UserInfo.IsLocal) {//hide sync menu for local account
|
||||
this.blog = new gui.MenuItem({
|
||||
@@ -2231,6 +2238,11 @@ function userMenu(allUsers) {
|
||||
}
|
||||
}
|
||||
|
||||
// debug
|
||||
mores.append(new gui.MenuItem({ type: 'separator' }));
|
||||
mores.append(this.debug);
|
||||
|
||||
|
||||
// 更多
|
||||
this.more = new gui.MenuItem({
|
||||
label: getMsg('More...'),
|
||||
|
@@ -317,5 +317,10 @@
|
||||
"Close": "关闭",
|
||||
|
||||
"Snippet view": "摘要视图",
|
||||
"List view": "列表视图"
|
||||
}
|
||||
"List view": "列表视图",
|
||||
|
||||
"Network error, please check out your network.": "网络异常, 请检查网络或稍后再试",
|
||||
"You need to sign in Leanote": "您需要重新登录Leanote",
|
||||
"You need to upgrade Leanote account": "同步失败, 帐户已到期或流量已用完, 您需要升级Leanote帐户"
|
||||
|
||||
}
|
||||
|
@@ -524,6 +524,33 @@ h3 {
|
||||
}
|
||||
}
|
||||
|
||||
.item-dirty {
|
||||
.dirty-bg {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 1;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-top: 29px solid transparent;
|
||||
border-right: 23px solid #040421;
|
||||
}
|
||||
|
||||
&::after {
|
||||
content: "\f093";
|
||||
position: absolute;
|
||||
right: 1px;
|
||||
bottom: 1px;
|
||||
z-index: 2;
|
||||
color: #FFF;
|
||||
/* font-size: 5px; */
|
||||
font: normal normal normal 14px/1 FontAwesome;
|
||||
/* font-size: inherit; */
|
||||
text-rendering: auto;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
}
|
||||
|
||||
#noteItemList {
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
@@ -560,6 +587,7 @@ h3 {
|
||||
.item-setting {
|
||||
bottom: 0;
|
||||
display: none;
|
||||
z-index: 3;
|
||||
}
|
||||
.item-star {
|
||||
bottom: 0;
|
||||
|
@@ -557,7 +557,7 @@ a.raw:hover {
|
||||
display: none;
|
||||
padding: 0;
|
||||
border: none;
|
||||
background-color: @bgColor;
|
||||
background: none;
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
@@ -482,3 +482,7 @@ textarea#wmd-input {
|
||||
background-color: rgb(101, 189, 119, 0.9);
|
||||
}
|
||||
}
|
||||
|
||||
#tagInput {
|
||||
color: #fff;
|
||||
}
|
Reference in New Issue
Block a user