Du kan inte välja fler än 25 ämnen
Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
316 rader
12 KiB
316 rader
12 KiB
<!doctype html>
|
|
<html lang="en" class="no-js">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<meta name="description"
|
|
content="码农随笔,个人随笔是一个面向IT技术人员,提供个人平时工作总结和在线记录学习笔记,个人技术博客,在线云笔记,码农笔录,最新的技术博客,www.aiprose.com">
|
|
<meta name="keywords" content="码农随笔,个人随笔,博客,个人博客,个人笔记,技术博客,免费云笔记,云笔记,随笔,IT博客,谷歌地图,码农笔录,aiprose">
|
|
<title>我的笔记 - 码农随笔</title>
|
|
<script type="text/javascript" src="/static/js/vue.min.js"></script>
|
|
<link rel="stylesheet" href="/static/css/iview.css">
|
|
<script src="/static/js/iview.min.js"></script>
|
|
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.4.0/jquery.min.js"></script>
|
|
<link rel="stylesheet" href="/static/editor/css/index.css">
|
|
<script src="/static/editor/mavon-editor.js"></script>
|
|
<style>
|
|
html, body {
|
|
height: 100%;
|
|
min-height: 100%;
|
|
}
|
|
|
|
main {
|
|
margin-top: 0 !important;
|
|
margin-bottom: 0 !important;
|
|
background-color: #f5f4e9;
|
|
}
|
|
|
|
#vue-app {
|
|
height: 100%;
|
|
}
|
|
|
|
.v-note-wrapper {
|
|
height: 100%;
|
|
z-index: 99 !important;
|
|
}
|
|
|
|
.v-note-wrapper .v-note-op {
|
|
padding-left: 40px !important;
|
|
}
|
|
|
|
.ivu-menu-png {
|
|
z-index: 1000;
|
|
position: fixed;
|
|
left: 10px;
|
|
top: 5px;
|
|
}
|
|
|
|
.ivu-drawer-body {
|
|
scrollbar-width: none; /* firefox */
|
|
-ms-overflow-style: none; /* IE 10+ */
|
|
overflow-x: hidden;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
::-webkit-scrollbar {
|
|
display: none; /* Chrome Safari */
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="vue-app">
|
|
<div class="ivu-menu-png" @click="drawer = true">
|
|
<img src="/static/img/imenu.png" alt="" width="30" height="30">
|
|
</div>
|
|
<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">
|
|
<i-button type="primary" ghost long>添加文件夹</i-button>
|
|
<i-button type="success" ghost long style="margin-top: 5px">添加笔记</i-button>
|
|
<i-menu theme="light" accordion="true" width="380" @on-select="noteSelectHandler">
|
|
<Submenu :name="item.Id" v-for="(item,key) in notes" :key="key">
|
|
<template slot="title">
|
|
<i class="ivu-icon ivu-icon-ios-paper"></i>
|
|
${item.Title}
|
|
</template>
|
|
<menu-item :name="note.Id" v-for="(note,nkey) in item.Notes" :key="nkey">${note.Title}</menu-item>
|
|
</Submenu>
|
|
</i-menu>
|
|
</Drawer>
|
|
</div>
|
|
|
|
</body>
|
|
<script>
|
|
var app = new Vue({
|
|
delimiters: ['${', '}'],
|
|
el: '#vue-app',
|
|
components: {
|
|
'mavon-editor': MavonEditor.mavonEditor
|
|
},
|
|
data: {
|
|
modal1: false,
|
|
drawer: false,
|
|
externalLink: {
|
|
// markdown_css: function() {
|
|
// // 这是你的markdown css文件路径
|
|
// return '/markdown/github-markdown.min.css';
|
|
// },
|
|
katex_css: function () {
|
|
// 这是你的katex配色方案路径路径
|
|
return '/katex/katex.min.css';
|
|
},
|
|
katex_js: function () {
|
|
// 这是你的katex.js路径
|
|
return '/katex/katex.min.js';
|
|
},
|
|
},
|
|
toolbars: {
|
|
bold: true, // 粗体
|
|
italic: true, // 斜体
|
|
header: true, // 标题
|
|
underline: true, // 下划线
|
|
strikethrough: true, // 中划线
|
|
mark: true, // 标记
|
|
superscript: true, // 上角标
|
|
subscript: true, // 下角标
|
|
quote: true, // 引用
|
|
ol: true, // 有序列表
|
|
ul: true, // 无序列表
|
|
link: true, // 链接
|
|
imagelink: true, // 图片链接
|
|
code: true, // code
|
|
table: true, // 表格
|
|
//fullscreen: true, // 全屏编辑
|
|
readmodel: true, // 沉浸式阅读
|
|
htmlcode: true, // 展示html源码
|
|
help: true, // 帮助
|
|
/* 1.3.5 */
|
|
undo: true, // 上一步
|
|
//redo: true, // 下一步
|
|
trash: true, // 清空
|
|
save: true, // 保存(触发events中的save事件)
|
|
/* 1.4.2 */
|
|
navigation: true, // 导航目录
|
|
/* 2.1.8 */
|
|
alignleft: true, // 左对齐
|
|
aligncenter: true, // 居中
|
|
alignright: true, // 右对齐
|
|
/* 2.2.1 */
|
|
subfield: true, // 单双栏模式
|
|
preview: true, // 预览
|
|
menu: true, // 预览
|
|
},
|
|
notes: [],
|
|
currentNote: {},
|
|
meval: '',
|
|
noteCols: []
|
|
|
|
},
|
|
mounted() {
|
|
var _this = this
|
|
$.get("/api/note", function (data, status) {
|
|
_this.notes = data
|
|
data.forEach((el) => {
|
|
_this.noteCols.push({title: el.Title, id: el.Id})
|
|
})
|
|
})
|
|
},
|
|
methods: {
|
|
okHandler() {
|
|
var _this = this
|
|
if (!this.currentNote.pid) {
|
|
this.$Notice.warning({
|
|
title: '请选择文件夹后重新保存',
|
|
desc: ''
|
|
})
|
|
return
|
|
}
|
|
if (!this.currentNote.title) {
|
|
this.$Notice.warning({
|
|
title: '请输入笔记名称后重新保存',
|
|
desc: ''
|
|
})
|
|
return
|
|
}
|
|
$.post('/api/note/save/', {
|
|
pid: this.currentNote.pid,
|
|
title: this.currentNote.title,
|
|
noteHtml: this.currentNote.NoteHtml
|
|
noteVal: this.currentNote.NoteVal
|
|
},
|
|
function (data) {
|
|
if (data.Status == 500) {
|
|
_this.$Notice.error({
|
|
title: '保存失败',
|
|
desc: ''
|
|
})
|
|
} else if (data.Status == 401) {
|
|
window.location.href = "/login"
|
|
} else {
|
|
_this.currentNote.Id = data.Id
|
|
debugger
|
|
_this.$Notice.success({
|
|
title: '保存成功',
|
|
desc: ''
|
|
})
|
|
}
|
|
}, '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
|
|
}
|
|
})
|
|
})
|
|
},
|
|
saveHandler(value, render) {
|
|
this.currentNote.NoteVal = value
|
|
this.currentNote.NoteHtml = render
|
|
if (!this.currentNote.Id) {
|
|
this.modal1 = true
|
|
} else {
|
|
this.editHandler(value, render)
|
|
}
|
|
},
|
|
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) {
|
|
window.location.href = "/login"
|
|
} else {
|
|
_this.$Notice.error({
|
|
title: '保存失败',
|
|
desc: ''
|
|
})
|
|
}
|
|
}, 'json')
|
|
}
|
|
}
|
|
})
|
|
</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 () {
|
|
|
|
$("#delNote").click(function () {
|
|
if (!note || !note.Id) {
|
|
layer.msg('请在右边菜单中选择笔记', function () {
|
|
});
|
|
return
|
|
}
|
|
layer.confirm('删除确认', {
|
|
btn: ['确认', '手滑了'] //按钮
|
|
}, function () {
|
|
$.post('/api/note/del/' + note.Id,
|
|
function (data) {
|
|
if (data.Status == 0) {
|
|
var subMenu = $(".sub-menu li a")
|
|
$.each(subMenu, function (index, el) {
|
|
if ($(el).attr("value") == note.Id) {
|
|
$(el).remove()
|
|
return
|
|
}
|
|
})
|
|
note = null
|
|
layer.msg("删除成功", {icon: 6});
|
|
} else if (data.Status == 401) {
|
|
window.location.href = "/login"
|
|
} else if (data.Status == 403) {
|
|
layer.msg("暂无权限", {icon: 5});
|
|
} else {
|
|
layer.msg("服务器异常", {icon: 5});
|
|
}
|
|
}, 'json')
|
|
}, function () {
|
|
|
|
});
|
|
})
|
|
})
|
|
</script>
|
|
</html>
|