diff --git a/main.js b/main.js index c8a6690b..dbd8bd43 100644 --- a/main.js +++ b/main.js @@ -53,6 +53,9 @@ var DB = { db.exec(m, function (ret) { // console.log('main called ret:'); // console.log(ret); + if (ret && ret.ret) { + ret.ret = JSON.stringify(ret.ret); + } event.sender.send('db-exec-ret', ret); }); }); diff --git a/node_modules/nedb_proxy.js b/node_modules/nedb_proxy.js index 5abc21e5..5e6ddcbb 100644 --- a/node_modules/nedb_proxy.js +++ b/node_modules/nedb_proxy.js @@ -87,6 +87,9 @@ ipc.on('db-exec-ret', function(m) { // console.log('clent 接收到消息'); // console.log(m); // console.log('--------------'); + if(m.ret && typeof m.ret == 'string') { + m.ret = JSON.parse(m.ret); + } callback && callback(m.err, m.ret); }); diff --git a/public/plugins/export_evernote/plugin.js b/public/plugins/export_evernote/plugin.js index f3aa1784..835595b5 100644 --- a/public/plugins/export_evernote/plugin.js +++ b/public/plugins/export_evernote/plugin.js @@ -134,6 +134,14 @@ define(function() { if (!t) { t = new Date(); } + if (typeof t != 'object' || !('getTime' in t)) { + try { + t = new Date(t); + } + catch(e) { + t = new Date(); + } + } return t.format("yyyyMMddThhmmssZ"); }, @@ -211,7 +219,7 @@ define(function() { }, findAllImages: function (content) { - var reg = new RegExp(']*?src=["\']?' + Api.evtService.localUrl + '/api/file/getImage\\?fileId=([0-9a-zA-Z]{24})["\']?.*?>', 'g'); + var reg = new RegExp(']*?src=["\']?' + Api.evtService.getImageLocalUrlPrefix() + '\\?fileId=([0-9a-zA-Z]{24})["\']?.*?>', 'g'); var matches = reg.exec(content); // width="330" height="330", style="width:200px" @@ -251,7 +259,7 @@ define(function() { }, findAllAttachs: function (content) { - var reg = new RegExp(']*?href=["\']?' + Api.evtService.localUrl + '/api/file/getAttach\\?fileId=([0-9a-zA-Z]{24})["\']?.*?>([^<]*)', 'g'); + var reg = new RegExp(']*?href=["\']?' + Api.evtService.getAttachLocalUrlPrefix() + '\\?fileId=([0-9a-zA-Z]{24})["\']?.*?>([^<]*)', 'g'); var matches = reg.exec(content); // 先找到所有的 @@ -326,11 +334,10 @@ define(function() { media += ' />'; content = content.replace(eachMatch.all, media); - if (!fileRendered[fileInfo.fileId]) { + if (!fileRendered[eachMatch.fileId]) { resources += me.renderResource(fileInfo); - fileRendered[fileInfo.fileId] = true; + fileRendered[eachMatch.fileId] = true; } - } } diff --git a/public/plugins/export_leanote/plugin.js b/public/plugins/export_leanote/plugin.js index 43925bb5..9cd6a65e 100644 --- a/public/plugins/export_leanote/plugin.js +++ b/public/plugins/export_leanote/plugin.js @@ -117,9 +117,18 @@ define(function() { getLeanoteTime: function(t) { // 20151026T033928Z // 2015 10 26 T 03 39 28 Z + console.log(t); if (!t) { t = new Date(); } + if (typeof t != 'object' || !('getTime' in t)) { + try { + t = new Date(t); + } + catch(e) { + t = new Date(); + } + } return t.format("yyyy-MM-dd hh:mm:ss"); }, @@ -186,7 +195,7 @@ define(function() { // markdown下 // [](http://localhost://fileId=32); if (note.IsMarkdown) { - var reg = new RegExp('!\\[([^\\]]*?)\\]\\(' + Api.evtService.localUrl + '/api/file/getImage\\?fileId=([0-9a-zA-Z]{24})\\)', 'g'); + var reg = new RegExp('!\\[([^\\]]*?)\\]\\(' + Api.evtService.getImageLocalUrlPrefix() + '\\?fileId=([0-9a-zA-Z]{24})\\)', 'g'); var matches = reg.exec(content); while(matches) { var all = matches[0]; @@ -202,7 +211,7 @@ define(function() { } } else { - var reg = new RegExp(']*?)src=["\']?' + Api.evtService.localUrl + '/api/file/getImage\\?fileId=([0-9a-zA-Z]{24})["\']?(.*?)>', 'g'); + var reg = new RegExp(']*?)src=["\']?' + Api.evtService.getImageLocalUrlPrefix() + '\\?fileId=([0-9a-zA-Z]{24})["\']?(.*?)>', 'g'); var matches = reg.exec(content); while(matches) { var all = matches[0]; @@ -230,7 +239,7 @@ define(function() { // markdown下 // ![](http://localhost://fileId=32); if (note.IsMarkdown) { - var reg = new RegExp('\\[([^\\]]*?)\\]\\(' + Api.evtService.localUrl + '/api/file/getAttach\\?fileId=([0-9a-zA-Z]{24})\\)', 'g'); + var reg = new RegExp('\\[([^\\]]*?)\\]\\(' + Api.evtService.getAttachLocalUrlPrefix() + '\\?fileId=([0-9a-zA-Z]{24})\\)', 'g'); var matches = reg.exec(content); while(matches) { var all = matches[0]; @@ -247,7 +256,7 @@ define(function() { } } else { - var reg = new RegExp(']*?)href=["\']?' + Api.evtService.localUrl + '/api/file/getAttach\\?fileId=([0-9a-zA-Z]{24})["\']?(.*?)>([^<]*)', 'g'); + var reg = new RegExp(']*?)href=["\']?' + Api.evtService.getAttachLocalUrlPrefix() + '\\?fileId=([0-9a-zA-Z]{24})["\']?(.*?)>([^<]*)', 'g'); var matches = reg.exec(content); while(matches) { diff --git a/public/plugins/import_leanote/import.js b/public/plugins/import_leanote/import.js index 554bb03d..a2f9b92f 100755 --- a/public/plugins/import_leanote/import.js +++ b/public/plugins/import_leanote/import.js @@ -185,22 +185,22 @@ var Import = { if (note.isMarkdown) { if (!eachMatch.isAttach) { // 用新的FileId - var href = Api.evtService.localUrl + '/api/file/getImage?fileId=' + fileInfo.FileId; + var href = Api.evtService.getImageLocalUrl(fileInfo.FileId); link = '![' + eachMatch.title + '](' + href + ')'; } else { - var href = Api.evtService.localUrl + '/api/file/getAttach?fileId=' + fileInfo.FileId; + var href = Api.evtService.getAttachLocalUrl(fileInfo.FileId); link = '[' + eachMatch.title + '](' + href + ')'; } } else { if (!eachMatch.isAttach) { // 用新的FileId - var href = Api.evtService.localUrl + '/api/file/getImage?fileId=' + fileInfo.FileId; + var href = Api.evtService.getImageLocalUrl(fileInfo.FileId); link = ''; } else { - var href = Api.evtService.localUrl + '/api/file/getAttach?fileId=' + fileInfo.FileId; + var href = Api.evtService.getAttachLocalUrl(fileInfo.FileId); link = '' + eachMatch.title + ''; } }