1. 文章编辑加入未保存浏览器缓存

2. 文章编辑标题加入长度检查
This commit is contained in:
lxyer 2018-05-13 00:38:49 +08:00
parent 976c62197a
commit 9011563784
7 changed files with 38 additions and 12 deletions

Binary file not shown.

View File

@ -19,7 +19,13 @@
</a>
<h2>
<a class="layui-badge">#(x.typeName)</a>
<a href="/jie/detail/#(x.contentId)">#(x.title)</a>
<a href="/jie/detail/#(x.contentId)">
#if(x.top == 3)
<span style="color: #AB5D7C;font-weight: bold;">#(x.title)</span>
#else
#(x.title)
#end
</a>
</h2>
<div class="fly-list-info">
<a href="/user/#(x.userId)" link>
@ -34,6 +40,7 @@
<span class="layui-badge fly-badge-accept layui-hide-xs">已结</span>
-->
<span class="fly-list-nums">
<i class="iconfont" title="人气">&#xe60b;</i> #(x.viewNum??0)
<i class="iconfont icon-pinglun1" title="回答"></i> #(x.replyNum??0)
</span>
</div>
@ -90,6 +97,7 @@
<span class="layui-badge fly-badge-accept layui-hide-xs">已结</span>
-->
<span class="fly-list-nums">
<i class="iconfont" title="人气">&#xe60b;</i> #(x.viewNum??0)
<i class="iconfont icon-pinglun1" title="回答"></i> #(x.replyNum??0)
</span>
</div>

View File

@ -254,7 +254,17 @@ layui.define(['layer', 'laytpl', 'form', 'element', 'upload', 'util', 'face'], f
var E = window.wangEditor;
var editor = new E('#editor');
editor.customConfig.uploadImgServer = '/upload/img';
editor.create()
var cache_key = "content_" + $("input[name='contentId']").val();
var html = localStorage.getItem(cache_key);
editor.customConfig.onblur = function (html) {
localStorage.setItem(cache_key, html);
};
editor.create();
if (html) editor.txt.html(html);//缓存的内容
return editor;
}
@ -319,11 +329,11 @@ layui.define(['layer', 'laytpl', 'form', 'element', 'upload', 'util', 'face'], f
return arguments.callee;
}
,userstat: function () {
/*,userstat: function () {
$.getJSON("/os/user/stat",{},function (data) {
$("#user_count").html(data.count);
});
}
}*/
};

View File

@ -247,7 +247,9 @@ layui.define(['fly','laypage'], function(exports){
bean:JSON.stringify(bean)
},function (res) {
layer.msg("发布成功",{time:2000},function () {
location.href = "/";
var cache_key = "content_" + $("input[name='contentId']").val();
localStorage.removeItem(cache_key);
location.href = "/user";
});
});
return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。

View File

@ -288,7 +288,8 @@ layui.define(['laypage', 'fly', 'element', 'flow'], function(exports){
bean:JSON.stringify({username:fdata.username, password:fdata.password})
,vercode:fdata.vercode
},function (data) {
data = JSON.parse(data);
console.log(data);
//data = JSON.parse(data);
if(data.retcode != 0){
layer.msg(data.retinfo);
return false;

View File

@ -1,11 +1,12 @@
package com.lxyer.bbs.comment;
import com.lxyer.bbs.base.BaseService;
import com.lxyer.bbs.base.LxyKit;
import com.lxyer.bbs.base.RetCodes;
import com.lxyer.bbs.base.entity.ActLog;
import com.lxyer.bbs.content.Content;
import com.lxyer.bbs.base.user.User;
import com.lxyer.bbs.base.user.UserService;
import com.lxyer.bbs.content.Content;
import org.redkale.net.http.RestMapping;
import org.redkale.net.http.RestParam;
import org.redkale.net.http.RestService;
@ -20,7 +21,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static com.lxyer.bbs.base.RetCodes.*;
import static com.lxyer.bbs.base.RetCodes.RET_COMMENT_CONTENT_ILLEGAL;
import static com.lxyer.bbs.base.RetCodes.RET_COMMENT_PARA_ILLEGAL;
/**
* Created by Lxy at 2017/11/29 10:00.

View File

@ -4,12 +4,10 @@ import com.jfinal.kit.Kv;
import com.lxyer.bbs.base.BaseService;
import com.lxyer.bbs.base.LxyKit;
import com.lxyer.bbs.base.RetCodes;
import com.lxyer.bbs.base.entity.ActLog;
import com.lxyer.bbs.base.user.User;
import com.lxyer.bbs.base.user.UserInfo;
import com.lxyer.bbs.base.user.UserService;
import com.lxyer.bbs.content.ContentInfo;
import com.lxyer.bbs.base.entity.ActLog;
import com.lxyer.bbs.content.Content;
import com.lxyer.bbs.base.user.User;
import org.redkale.net.http.*;
import org.redkale.service.RetResult;
import org.redkale.source.*;
@ -89,6 +87,11 @@ public class ContentService extends BaseService{
@RestMapping(name = "save", auth = true, comment = "内容保存")
public RetResult contentSave(@RestParam(name = "bean")Content content, @RestSessionid String sessionid){
//数据校验
if (content.getTitle().isEmpty() || content.getTitle().length() > 64){
return RetCodes.retResult(-1, "少年你的文章标题太长啦精简化标题吧为了更好的SEO长度请少于64个字节");
}
if (content.getContentId() < 1){
int maxId = source.getNumberResult(Content.class, FilterFunc.MAX, 10_0000, "contentId").intValue();
int userId = userService.currentUserId(sessionid);