🎨 移除自动保存文章功能,由编辑器的自动保存文章替代

pull/37/head
ruibaby 2018-10-11 08:54:42 +08:00
parent 366c3c4fde
commit e5080107ad
3 changed files with 0 additions and 140 deletions

View File

@ -33,7 +33,6 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Optional;
@ -216,61 +215,6 @@ public class PostController extends BaseController {
}
}
/**
* 稿
*
* @param postId
* @param postTitle
* @param postUrl
* @param postContentMd
* @param postType
* @param session session
* @return JsonResult
*/
@PostMapping(value = "/new/autoPush")
@ResponseBody
public JsonResult autoPushPost(@RequestParam(value = "postId", defaultValue = "0") Long postId,
@RequestParam(value = "postTitle") String postTitle,
@RequestParam(value = "postUrl") String postUrl,
@RequestParam(value = "postContentMd") String postContentMd,
@RequestParam(value = "postType", defaultValue = "post") String postType,
HttpSession session) {
Post post = null;
User user = (User) session.getAttribute(HaloConst.USER_SESSION_KEY);
if (postId == 0) {
post = new Post();
} else {
post = postService.findByPostId(postId).get();
}
try {
if (StrUtil.isBlank(postTitle)) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
post.setPostTitle("草稿:" + dateFormat.format(DateUtil.date()));
} else {
post.setPostTitle(postTitle);
}
if (StrUtil.isBlank(postUrl)) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
post.setPostUrl(dateFormat.format(DateUtil.date()));
} else {
post.setPostUrl(postUrl);
}
post.setPostId(postId);
post.setPostStatus(1);
post.setPostContentMd(postContentMd);
post.setPostType(postType);
post.setPostDate(DateUtil.date());
post.setPostUpdate(DateUtil.date());
post.setUser(user);
} catch (Exception e) {
log.error("未知错误:{}", e.getMessage());
return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.common.save-failed"));
}
return new JsonResult(ResultCodeEnum.SUCCESS.getCode(), localeMessageUtil.getMessage("code.admin.common.save-success"), postService.saveByPost(post));
}
/**
*
*

View File

@ -226,49 +226,6 @@
}
});
}
// setInterval("autoPush()","60000");
/**
* 自动保存文章
*/
function autoPush() {
var Title = "";
if(postTitle.val()){
Title = postTitle.val();
}
$.ajax({
type: 'POST',
url: '/admin/posts/new/autoPush',
async: false,
data: {
'postId': $('#postId').val(),
'postTitle': Title,
'postUrl' : $('#postUrl').html().toString(),
'postContentMd': simplemde.value(),
'postType' : "page"
},
success: function (data) {
if(!$("#post_title").val()){
$("#post_title").val(data.result.postTitle);
}
if(!$("#postId").val()){
$("#postId").val(data.result.postId);
}
if($("#postUrl").html()==''){
$("#postUrl").html(data.result.postUrl);
}
}
});
}
/**
* Ctrl+C保存
*/
$(document).keydown(function (event) {
if(event.ctrlKey&&event.keyCode === 83){
autoPush();
}
});
</script>
</div>
<#include "module/_footer.ftl">

View File

@ -334,47 +334,6 @@
}
});
}
// setInterval("autoPush()","60000");
/**
* 自动保存文章
*/
function autoPush() {
var Title = "";
if(postTitle.val()){
Title = postTitle.val();
}
$.ajax({
type: 'POST',
url: '/admin/posts/new/autoPush',
async: false,
data: {
'postId': $('#postId').val(),
'postTitle': Title,
'postUrl' : $('#postUrl').html().toString(),
'postContentMd': simplemde.value()
},
success: function (data) {
if(!$("#post_title").val()){
$("#post_title").val(data.result.postTitle);
}
if(!$("#postId").val()){
$("#postId").val(data.result.postId);
}
if($("#postUrl").html()==''){
$("#postUrl").html(data.result.postUrl);
}
}
});
}
/**
* Ctrl+C保存
*/
$(document).keydown(function (event) {
if(event.ctrlKey&&event.keyCode === 83){
autoPush();
}
});
</script>
</div>
<#include "module/_footer.ftl">