码农笔录博客源码
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

114 Zeilen
4.2 KiB

vor 6 Jahren
{{template "header" .}}
<meta name="keywords" content="云悦,个人随笔,博客,个人博客,个人笔记,技术博客,免费云笔记,云笔记,随笔,IT博客,谷歌地图,码农笔录,www.aiprose.com,aiprose.com,aiprose">
<title>发布博客 - 云悦</title>
vor 6 Jahren
<link type="text/css" rel="styleSheet" href="/static/css/newblog.css"/>
vor 6 Jahren
<script src="/static/js/wangEditor.min.js"></script>
vor 6 Jahren
</head>
<body>
<div class="root-container">
<div class="blog-title">
vor 6 Jahren
<input type="text" id="blog-title" placeholder="请输入文章标题">
vor 6 Jahren
<button type="button" id="newBtn" class="btn btn-danger" style="border-radius: 12px">发布文章</button>
</div>
<div id="editor" class="editor">
</div>
<div id="myModal" tabindex="-1" role="dialog" data-hasfoot="false" class="sui-modal hide fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" data-dismiss="modal" aria-hidden="true" class="sui-close">×</button>
<h4 id="myModalLabel" class="modal-title">Modal title</h4>
</div>
<div class="modal-body">我是内容body</div>
<div class="modal-footer">
<button type="button" data-ok="modal" class="sui-btn btn-primary btn-large">可自定ok</button>
<button type="button" data-dismiss="modal" class="sui-btn btn-default btn-large">可自定dismiss</button>
</div>
</div>
</div>
</div>
</div>
</body>
<script>
var storage=window.localStorage
vor 6 Jahren
var E = window.wangEditor
var editor = new E('#editor')
editor.customConfig.uploadImgServer = '/file/upload'
vor 6 Jahren
// 或者 var editor = new E( document.getElementById('editor') )
editor.customConfig.uploadImgHooks = {
customInsert: function (insertImg, result, editor) {
insertImg(result.Data);
debugger
}
}
vor 6 Jahren
editor.create()
document.onkeydown = keyDown;
function keyDown(e) {
var currKey = 0, e = e || event || window.event;
currKey = e.keyCode || e.which || e.charCode;
if (currKey == 83 && (e.ctrlKey || e.metaKey)) {
saveBlog()
return
}
}
function saveBlog() {
var title = $("#blog-title").val();
if (title.trim().length < 3) {
layer.msg('文章标题最少三个字', function () {
});
return
}
tobj.title = $("#blog-title").val();
vor 6 Jahren
if (editor.txt.html().trim().length == 0) {
layer.msg('文章内容不能为空哦', function () {
});
return
}
tobj.blogHtml = editor.txt.html();
storage.setItem("blogHtml",tobj.blogHtml);
storage.setItem("blogTitle",tobj.title);
layer.open({
type: 2,
title: '发布文章',
shadeClose: true,
shade: 0.8,
area: ['420px', '280px'],
content: '/iframe/blog.html/' //iframe的url
});
}
vor 6 Jahren
var tobj = {}
$(function () {
var oldVal = storage.getItem("blogHtml");
editor.txt.html(oldVal);
var oldTitle = storage.getItem("blogTitle");
$("#blog-title").val(oldTitle);
vor 6 Jahren
var height = document.documentElement.clientHeight
$(".w-e-text-container").height(height - 50 - 40 - 1);
$("#newBtn").click(function () {
saveBlog()
vor 6 Jahren
})
})
function saveBlogCallback(callback) {
vor 6 Jahren
$.post('/api/blog/new', tobj,
vor 6 Jahren
function (data) {
if (data.Status == 0) {
storage.removeItem("blogHtml");
storage.removeItem("blogTitle");
layer.msg("保存成功", {icon: 6});
callback(true)
vor 6 Jahren
window.location.href = "/blog/"+ data.Data
} else if (data.Status == 401) {
window.location.href = "login"
} else if (data.Status == 500) {
layer.msg("保存失败", {icon: 6});
callback(false)
}
}, 'json')
vor 6 Jahren
}
</script>
</html>