leanote协议完成

This commit is contained in:
life
2015-11-09 23:33:41 +08:00
parent 52ed3ea523
commit f20120ebdf
8 changed files with 154 additions and 25 deletions

38
node_modules/evt.js generated vendored
View File

@@ -11,6 +11,9 @@ if(!fs.existsSync(dataBasePath)) {
*/
// dataBasePath = '';
var protocol = require('remote').require('protocol');
var Evt = {
defaultUrl: 'https://leanote.com',
@@ -37,10 +40,45 @@ var Evt = {
localUrl: 'http://127.0.0.1:8912',
dataBasePath: '',
// 是否有这个方法, 就代表是否可以用(含callback)
// https://github.com/atom/electron/commit/7d97bb6fe0a6feef886d927ea894bcb2f3521577
// 老版本没有这个问题
canUseProtocol: function () {
// return false;
return protocol.registerFileProtocol;
},
getImageLocalUrlPrefix: function () {
if (this.canUseProtocol()) {
return 'leanote://file/getImage';
}
return this.localUrl + '/api/file/getImage';
},
getAttachLocalUrlPrefix: function () {
if (this.canUseProtocol()) {
return 'leanote://file/getAttach';
}
return this.localUrl + '/api/file/getAttach';
},
getAllAttachsLocalUrlPrefix: function () {
if (this.canUseProtocol()) {
return 'leanote://file/getAllAttachs';
}
return this.localUrl + '/api/file/getAllAttachs';
},
getImageLocalUrl: function(fileId) {
if (this.canUseProtocol()) {
return 'leanote://file/getImage?fileId=' + fileId;
}
return this.localUrl + '/api/file/getImage?fileId=' + fileId;
},
getAttachLocalUrl: function(fileId) {
if (this.canUseProtocol()) {
return 'leanote://file/getAttach?fileId=' + fileId;
}
return this.localUrl + '/api/file/getAttach?fileId=' + fileId;
},
getAllAttachLocalUrl: function(noteId) {