添加/修改笔记同步传updatedTime, createdTime

This commit is contained in:
life
2015-11-01 11:05:48 +08:00
parent 580220eee4
commit 377af3e26c
2 changed files with 33 additions and 3 deletions

8
node_modules/api.js generated vendored
View File

@@ -466,7 +466,7 @@ var Api = {
Notebook.getServerNotebookIdByNotebookId(note.NotebookId, function(serverNotebookId) {
if(!serverNotebookId) {
console.error('No serverNotebookId');
console.log(note);
// console.log(note);
callback && callback(false);
return;
}
@@ -480,6 +480,8 @@ var Api = {
IsBlog: note.IsBlog,
Files: note.Files,
FileDatas: note.FileDatas,
CreatedTime: Common.formatDatetime(note.CreatedTime),
UpdatedTime: Common.formatDatetime(note.UpdatedTime)
}
// log('add note');
// log(data);
@@ -495,7 +497,6 @@ var Api = {
console.log('end transfer data');
console.log(data);
try {
needle.post(me.getUrl('note/addNote'), data,
{
@@ -542,7 +543,8 @@ var Api = {
IsBlog: note.IsBlog, // 是否是博客
Files: note.Files,
FileDatas: note.FileDatas,
Tags: note.Tags, // 新添加
Tags: note.Tags, // 新添加,
UpdatedTime: Common.formatDatetime(note.UpdatedTime)
};
// 内容不一样才发内容

28
node_modules/common.js generated vendored
View File

@@ -21,6 +21,23 @@ process.on('uncaughtException', function (err) {
*/
function log(o) {console.log(o)}
Date.prototype.format = function(fmt) { //author: meizz
var o = {
"M+" : this.getMonth()+1, //月份
"d+" : this.getDate(), //日
"h+" : this.getHours(), //小时
"m+" : this.getMinutes(), //分
"s+" : this.getSeconds(), //秒
"q+" : Math.floor((this.getMonth()+3)/3), //季度
"S" : this.getMilliseconds() //毫秒
};
if(/(y+)/.test(fmt))
fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
for(var k in o)
if(new RegExp("("+ k +")").test(fmt))
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
return fmt;
}
// log("<>>>>>>>>>>>>>>>>>>>>");
var Common = {
objectId: function() {
@@ -187,6 +204,17 @@ var Common = {
}
},
formatDatetime: function (t) {
if (!t) {
t = new Date();
}
try {
return t.format("yyyy-MM-dd hh:mm:ss");
} catch(e) {
return '';
}
},
// 获取文件的json数据
getFileJson: function(filepath) {
var me = this;