mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-17 16:45:21 +00:00
leanote协议完成
This commit is contained in:
@@ -422,6 +422,10 @@ Note.genAbstract = function(content, len) {
|
||||
return d.innerHTML;
|
||||
};
|
||||
|
||||
Note.fixImageSrc = function(src) {
|
||||
return fixContentUrl(src);
|
||||
};
|
||||
|
||||
Note.getImgSrc = function(content) {
|
||||
if(!content) {
|
||||
return "";
|
||||
@@ -779,9 +783,9 @@ Note.renderChangedNote = function(changedNote) {
|
||||
$thumb = $leftNoteNav.find(".item-thumb");
|
||||
// 有可能之前没有图片
|
||||
if($thumb.length > 0) {
|
||||
$thumb.find("img").attr("src", changedNote.ImgSrc);
|
||||
$thumb.find("img").attr("src", Note.fixImageSrc(changedNote.ImgSrc));
|
||||
} else {
|
||||
$leftNoteNav.append(tt('<div class="item-thumb" style=""><img src="?"></div>', changedNote.ImgSrc));
|
||||
$leftNoteNav.append(tt('<div class="item-thumb" style=""><img src="?"></div>', Note.fixImageSrc(changedNote.ImgSrc)));
|
||||
$leftNoteNav.addClass("item-image");
|
||||
}
|
||||
$leftNoteNav.find(".item-desc").removeAttr("style");
|
||||
@@ -982,7 +986,7 @@ Note._getNoteHtmlObjct = function(note, isShared) {
|
||||
|
||||
var tmp;
|
||||
if(note.ImgSrc) {
|
||||
tmp = tt(Note.itemTpl, classes, this.newNoteSeq(), note.NoteId, note.ImgSrc, note.Title, Notebook.getNotebookTitle(note.NotebookId), goNowToDatetime(note.UpdatedTime), note.Desc);
|
||||
tmp = tt(Note.itemTpl, classes, this.newNoteSeq(), note.NoteId, Note.fixImageSrc(note.ImgSrc), note.Title, Notebook.getNotebookTitle(note.NotebookId), goNowToDatetime(note.UpdatedTime), note.Desc);
|
||||
} else {
|
||||
tmp = tt(Note.itemTplNoImg, classes, this.newNoteSeq(), note.NoteId, note.Title, Notebook.getNotebookTitle(note.NotebookId), goNowToDatetime(note.UpdatedTime), note.Desc);
|
||||
}
|
||||
@@ -1028,7 +1032,7 @@ Note._renderNotes = function(notes, forNewNote, isShared, tang) { // 第几趟
|
||||
|
||||
var tmp;
|
||||
if(note.ImgSrc) {
|
||||
tmp = tt(Note.itemTpl, classes, i, note.NoteId, note.ImgSrc, note.Title, Notebook.getNotebookTitle(note.NotebookId), goNowToDatetime(note.UpdatedTime), note.Desc || '');
|
||||
tmp = tt(Note.itemTpl, classes, i, note.NoteId, Note.fixImageSrc(note.ImgSrc), note.Title, Notebook.getNotebookTitle(note.NotebookId), goNowToDatetime(note.UpdatedTime), note.Desc || '');
|
||||
} else {
|
||||
tmp = tt(Note.itemTplNoImg, classes, i, note.NoteId, note.Title, Notebook.getNotebookTitle(note.NotebookId), goNowToDatetime(note.UpdatedTime), note.Desc || '');
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ var Evt = require('evt');
|
||||
var app = require('remote').require('app');
|
||||
var basePath = app.getPath('appData') + '/leanote'; // /Users/life/Library/Application Support/Leanote'; // require('nw.gui').App.dataPath;
|
||||
Evt.setDataBasePath(basePath);
|
||||
var protocol = require('remote').require('protocol');
|
||||
|
||||
if(!/login.html/.test(location.href)) {
|
||||
// 启动服务器, 图片
|
||||
|
@@ -344,6 +344,14 @@ function switchEditor(isMarkdown) {
|
||||
}
|
||||
}
|
||||
|
||||
// 将http://127.0.0.1:8912转为leanote://
|
||||
function fixContentUrl(content) {
|
||||
if (EvtService.canUseProtocol()) {
|
||||
return content.replace(/http:\/\/127.0.0.1:8912\/api\//g, 'leanote://');
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
// editor 设置内容
|
||||
// 可能是tinymce还没有渲染成功
|
||||
var previewToken = "<div style='display: none'>FORTOKEN</div>"
|
||||
@@ -357,6 +365,9 @@ function _setEditorContent(content, isMarkdown, preview, callback) {
|
||||
if(!content) {
|
||||
content = "";
|
||||
}
|
||||
|
||||
content = fixContentUrl(content);
|
||||
|
||||
if(clearIntervalForSetContent) {
|
||||
clearInterval(clearIntervalForSetContent);
|
||||
}
|
||||
@@ -1704,16 +1715,16 @@ var Notify = {
|
||||
|
||||
var onClose = function(afterFunc) {
|
||||
try {
|
||||
// 先把服务关掉
|
||||
Server.close();
|
||||
SyncService.stop();
|
||||
|
||||
// 先保存之前改变的
|
||||
Note.curChangedSaveIt();
|
||||
// 保存状态
|
||||
State.saveCurState(function() {
|
||||
afterFunc && afterFunc();
|
||||
});
|
||||
// 先把服务/协议关掉
|
||||
Server.close(function () {
|
||||
SyncService.stop();
|
||||
// 先保存之前改变的
|
||||
Note.curChangedSaveIt();
|
||||
// 保存状态
|
||||
State.saveCurState(function() {
|
||||
afterFunc && afterFunc();
|
||||
});
|
||||
});
|
||||
} catch(e) {
|
||||
afterFunc && afterFunc();
|
||||
}
|
||||
|
Reference in New Issue
Block a user