|
@ -62,7 +62,23 @@ |
|
|
<div class="ivu-menu-png" @click="drawer = true"> |
|
|
<div class="ivu-menu-png" @click="drawer = true"> |
|
|
<img src="/static/img/imenu.png" alt="" width="30" height="30"> |
|
|
<img src="/static/img/imenu.png" alt="" width="30" height="30"> |
|
|
</div> |
|
|
</div> |
|
|
<mavon-editor :externalLink="externalLink" :toolbars="toolbars" v-model="meval"></mavon-editor> |
|
|
<Modal |
|
|
|
|
|
v-model="modal1" |
|
|
|
|
|
title="笔记信息" |
|
|
|
|
|
@on-ok="okHandler" |
|
|
|
|
|
@on-cancel="cancelHandler"> |
|
|
|
|
|
<i-form :label-width="100"> |
|
|
|
|
|
<form-item label="文件夹名称"> |
|
|
|
|
|
<i-select v-model="currentNote.pid"> |
|
|
|
|
|
<i-option v-for="item in noteCols" :value="item.id" :key="item.id">${ item.title }</i-option> |
|
|
|
|
|
</i-select> |
|
|
|
|
|
</form-item> |
|
|
|
|
|
<form-item label="笔记名称"> |
|
|
|
|
|
<i-input type="text" v-model="currentNote.title" placeholder="请输入笔记名称"/> |
|
|
|
|
|
</form-item> |
|
|
|
|
|
</i-form> |
|
|
|
|
|
</Modal> |
|
|
|
|
|
<mavon-editor :externalLink="externalLink" :toolbars="toolbars" v-model="meval" @save="saveHandler"></mavon-editor> |
|
|
<Drawer title="目录选择" placement="left" :closable="false" v-model="drawer" width="400"> |
|
|
<Drawer title="目录选择" placement="left" :closable="false" v-model="drawer" width="400"> |
|
|
<i-button type="primary" ghost long>添加文件夹</i-button> |
|
|
<i-button type="primary" ghost long>添加文件夹</i-button> |
|
|
<i-button type="success" ghost long style="margin-top: 5px">添加笔记</i-button> |
|
|
<i-button type="success" ghost long style="margin-top: 5px">添加笔记</i-button> |
|
@ -87,7 +103,8 @@ |
|
|
'mavon-editor': MavonEditor.mavonEditor |
|
|
'mavon-editor': MavonEditor.mavonEditor |
|
|
}, |
|
|
}, |
|
|
data: { |
|
|
data: { |
|
|
drawer: true, |
|
|
modal1: false, |
|
|
|
|
|
drawer: false, |
|
|
externalLink: { |
|
|
externalLink: { |
|
|
// markdown_css: function() { |
|
|
// markdown_css: function() { |
|
|
// // 这是你的markdown css文件路径 |
|
|
// // 这是你的markdown css文件路径 |
|
@ -125,7 +142,7 @@ |
|
|
/* 1.3.5 */ |
|
|
/* 1.3.5 */ |
|
|
undo: true, // 上一步 |
|
|
undo: true, // 上一步 |
|
|
//redo: true, // 下一步 |
|
|
//redo: true, // 下一步 |
|
|
//trash: true, // 清空 |
|
|
trash: true, // 清空 |
|
|
save: true, // 保存(触发events中的save事件) |
|
|
save: true, // 保存(触发events中的save事件) |
|
|
/* 1.4.2 */ |
|
|
/* 1.4.2 */ |
|
|
navigation: true, // 导航目录 |
|
|
navigation: true, // 导航目录 |
|
@ -139,104 +156,125 @@ |
|
|
menu: true, // 预览 |
|
|
menu: true, // 预览 |
|
|
}, |
|
|
}, |
|
|
notes: [], |
|
|
notes: [], |
|
|
meval: '' |
|
|
currentNote: {}, |
|
|
|
|
|
meval: '', |
|
|
|
|
|
noteCols: [] |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
mounted() { |
|
|
mounted() { |
|
|
var _this = this |
|
|
var _this = this |
|
|
$.get("/note/api", function (data, status) { |
|
|
$.get("/api/note", function (data, status) { |
|
|
_this.notes = data |
|
|
_this.notes = data |
|
|
|
|
|
data.forEach((el) => { |
|
|
|
|
|
_this.noteCols.push({title: el.Title, id: el.Id}) |
|
|
|
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
noteSelectHandler(id) { |
|
|
okHandler() { |
|
|
var _this = this |
|
|
var _this = this |
|
|
this.notes.forEach((item) => { |
|
|
if (!this.currentNote.pid) { |
|
|
item.Notes.forEach((note) => { |
|
|
this.$Notice.warning({ |
|
|
if (id == note.Id) { |
|
|
title: '请选择文件夹后重新保存', |
|
|
_this.meval = note.NoteVal ? note.NoteVal : note.NoteHtml |
|
|
desc: '' |
|
|
} |
|
|
|
|
|
}) |
|
|
}) |
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
</script> |
|
|
|
|
|
<script> |
|
|
|
|
|
function keyDown(e) { |
|
|
|
|
|
// e.preventDefault(); |
|
|
|
|
|
var currKey = 0, e = e || event || window.event; |
|
|
|
|
|
currKey = e.keyCode || e.which || e.charCode; |
|
|
|
|
|
if (currKey == 83 && (e.ctrlKey || e.metaKey)) { |
|
|
|
|
|
layer.msg("ctrl+s") |
|
|
|
|
|
saveNote() |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function saveNote() { |
|
|
|
|
|
if (!note || !note.Id) { |
|
|
|
|
|
layer.msg('请在左边菜单中选择笔记', function () { |
|
|
|
|
|
}); |
|
|
|
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
var noteHtml = editor.txt.html() |
|
|
if (!this.currentNote.title) { |
|
|
if (!editor.txt.html() && editor.txt.html().trim().length == 0) { |
|
|
this.$Notice.warning({ |
|
|
layer.msg('保存内容为空', function () { |
|
|
title: '请输入笔记名称后重新保存', |
|
|
}); |
|
|
desc: '' |
|
|
|
|
|
}) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
$.post('/api/note/edit/' + note.Id, { |
|
|
$.post('/api/note/save/', { |
|
|
noteHtml: noteHtml |
|
|
pid: this.currentNote.pid, |
|
|
|
|
|
title: this.currentNote.title, |
|
|
|
|
|
noteHtml: this.currentNote.NoteHtml |
|
|
|
|
|
noteVal: this.currentNote.NoteVal |
|
|
}, |
|
|
}, |
|
|
function (data) { |
|
|
function (data) { |
|
|
if (data.Status == 0) { |
|
|
if (data.Status == 500) { |
|
|
layer.msg("保存成功", {icon: 6}); |
|
|
_this.$Notice.error({ |
|
|
|
|
|
title: '保存失败', |
|
|
|
|
|
desc: '' |
|
|
|
|
|
}) |
|
|
} else if (data.Status == 401) { |
|
|
} else if (data.Status == 401) { |
|
|
window.location.href = "/login" |
|
|
window.location.href = "/login" |
|
|
} else { |
|
|
} else { |
|
|
layer.msg("服务器异常", {icon: 5}); |
|
|
_this.currentNote.Id = data.Id |
|
|
|
|
|
debugger |
|
|
|
|
|
_this.$Notice.success({ |
|
|
|
|
|
title: '保存成功', |
|
|
|
|
|
desc: '' |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
}, 'json') |
|
|
}, 'json') |
|
|
|
|
|
}, |
|
|
|
|
|
cancelHandler() { |
|
|
|
|
|
this.$Notice.warning({ |
|
|
|
|
|
title: '笔记没有被保存!!!', |
|
|
|
|
|
desc: '' |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
noteSelectHandler(id) { |
|
|
|
|
|
var _this = this |
|
|
|
|
|
this.notes.forEach((item) => { |
|
|
|
|
|
item.Notes.forEach((note) => { |
|
|
|
|
|
if (id == note.Id) { |
|
|
|
|
|
_this.currentNote = note |
|
|
|
|
|
_this.meval = note.NoteVal ? note.NoteVal : note.NoteHtml |
|
|
} |
|
|
} |
|
|
|
|
|
}) |
|
|
function noteClick(id) { |
|
|
}) |
|
|
$.get('/api/note/' + id, |
|
|
}, |
|
|
function (data) { |
|
|
saveHandler(value, render) { |
|
|
if (!data.Status) { |
|
|
this.currentNote.NoteVal = value |
|
|
|
|
|
this.currentNote.NoteHtml = render |
|
|
if (data.NoteHtml && data.NoteHtml.trim().length != 0) { |
|
|
if (!this.currentNote.Id) { |
|
|
editor.txt.html(data.NoteHtml); |
|
|
this.modal1 = true |
|
|
$(".current-title").text(data.Title) |
|
|
} else { |
|
|
} else if (note) { |
|
|
this.editHandler(value, render) |
|
|
editor.txt.html(""); |
|
|
|
|
|
} |
|
|
} |
|
|
note = data |
|
|
}, |
|
|
|
|
|
editHandler(value, render) { |
|
|
|
|
|
var _this = this |
|
|
|
|
|
$.post('/api/note/edit/' + this.currentNote.Id, { |
|
|
|
|
|
noteHtml: render, |
|
|
|
|
|
noteVal: value |
|
|
|
|
|
}, |
|
|
|
|
|
function (data) { |
|
|
|
|
|
if (data.Status == 0) { |
|
|
|
|
|
_this.$Notice.success({ |
|
|
|
|
|
title: '保存成功', |
|
|
|
|
|
desc: '' |
|
|
|
|
|
}) |
|
|
} else if (data.Status == 401) { |
|
|
} else if (data.Status == 401) { |
|
|
window.location.href = "/login" |
|
|
window.location.href = "/login" |
|
|
} else if (data.Status == 403) { |
|
|
|
|
|
layer.msg("暂无权限", {icon: 5}); |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
layer.msg("服务器异常", {icon: 5}); |
|
|
_this.$Notice.error({ |
|
|
|
|
|
title: '保存失败', |
|
|
|
|
|
desc: '' |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
}, 'json') |
|
|
}, 'json') |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function addNoteCallback(obj) { |
|
|
|
|
|
var subMenu = $(".sub-menu") |
|
|
|
|
|
$.each(subMenu, function (index, el) { |
|
|
|
|
|
if ($(el).attr("value") == obj.Pid) { |
|
|
|
|
|
var child = '<li><a href="javascript:void(0)" onclick="noteClick(' + obj.Id + ')" value="' + obj.Id + '" >' + obj.Title + '</a></li>' |
|
|
|
|
|
$(el).append(child) |
|
|
|
|
|
if (!note || !note.Id) { |
|
|
|
|
|
note = obj |
|
|
|
|
|
$(".current-title").text(obj.Title) |
|
|
|
|
|
} |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
} |
|
|
</script> |
|
|
|
|
|
<script> |
|
|
|
|
|
// function keyDown(e) { |
|
|
|
|
|
// // e.preventDefault(); |
|
|
|
|
|
// var currKey = 0, e = e || event || window.event; |
|
|
|
|
|
// currKey = e.keyCode || e.which || e.charCode; |
|
|
|
|
|
// if (currKey == 83 && (e.ctrlKey || e.metaKey)) { |
|
|
|
|
|
// layer.msg("ctrl+s") |
|
|
|
|
|
// saveNote() |
|
|
|
|
|
// return false; |
|
|
|
|
|
// } |
|
|
|
|
|
// |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(function () { |
|
|
$(function () { |
|
|
|
|
|
|
|
|