mirror of https://github.com/mindoc-org/mindoc.git
* fix: #976 评论增加头像 * fix: update cherry markdown read comment user to avatar stylepull/987/head
parent
acf3c46e82
commit
84b947d148
|
@ -35,6 +35,7 @@ type Comment struct {
|
||||||
AgainstCount int `orm:"column(against_count);type(int);default(0)" json:"against_count"`
|
AgainstCount int `orm:"column(against_count);type(int);default(0)" json:"against_count"`
|
||||||
Index int `orm:"-" json:"index"`
|
Index int `orm:"-" json:"index"`
|
||||||
ShowDel int `orm:"-" json:"show_del"`
|
ShowDel int `orm:"-" json:"show_del"`
|
||||||
|
Avatar string `orm:"-" json:"avatar"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName 获取对应数据库表名.
|
// TableName 获取对应数据库表名.
|
||||||
|
@ -90,6 +91,7 @@ func (m *Comment) QueryCommentByDocumentId(doc_id, page, pagesize int, member *M
|
||||||
comments[i].Index = (i + 1) + (page-1)*pagesize
|
comments[i].Index = (i + 1) + (page-1)*pagesize
|
||||||
if member != nil && comments[i].CanDelete(member.MemberId, bookRole) {
|
if member != nil && comments[i].CanDelete(member.MemberId, bookRole) {
|
||||||
comments[i].ShowDel = 1
|
comments[i].ShowDel = 1
|
||||||
|
comments[i].Avatar = member.Avatar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
|
@ -798,6 +798,13 @@ table>tbody>tr:hover {
|
||||||
line-height: 24px
|
line-height: 24px
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.m-comment .comment-item .info img {
|
||||||
|
height: 22px;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin-right: 4px;
|
||||||
|
display: ruby;
|
||||||
|
}
|
||||||
|
|
||||||
.m-comment .comment-item .vote {
|
.m-comment .comment-item .vote {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-right: 12px
|
margin-right: 12px
|
||||||
|
|
|
@ -77,26 +77,39 @@ function pageClicked($page, $docid) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderOperateSection(comment) {
|
||||||
|
const deleteIcon = comment.show_del == 1
|
||||||
|
? `<i class="delete e-delete glyphicon glyphicon-remove" onclick="onDelComment(${comment.comment_id})"></i>`
|
||||||
|
: '';
|
||||||
|
|
||||||
|
return `
|
||||||
|
<span class="operate ${comment.show_del == 1 ? 'toggle' : ''}">
|
||||||
|
<span class="number">${comment.index}#</span>
|
||||||
|
${deleteIcon}
|
||||||
|
</span>`;
|
||||||
|
}
|
||||||
|
|
||||||
// 加载评论
|
// 加载评论
|
||||||
function loadComment($page, $docid) {
|
function loadComment($page, $docid) {
|
||||||
$("#commentList").empty();
|
$("#commentList").empty();
|
||||||
var html = ""
|
let html = ""
|
||||||
var c = $page.List;
|
let c = $page.List;
|
||||||
for (var i = 0; c && i < c.length; i++) {
|
for (let i = 0; c && i < c.length; i++) {
|
||||||
html += "<div class=\"comment-item\" data-id=\"" + c[i].comment_id + "\">";
|
const comment = c[i];
|
||||||
html += "<p class=\"info\"><a class=\"name\">" + c[i].author + "</a><span class=\"date\">" + timeFormat(c[i].comment_date) + "</span></p>";
|
html += `
|
||||||
html += "<div class=\"content\">" + c[i].content + "</div>";
|
<div class="comment-item" data-id="${comment.comment_id}">
|
||||||
html += "<p class=\"util\">";
|
<p class="info">
|
||||||
if (c[i].show_del == 1) html += "<span class=\"operate toggle\">";
|
<img src="${comment.avatar}" alt="">
|
||||||
else html += "<span class=\"operate\">";
|
<a class="name">${comment.author}</a>
|
||||||
html += "<span class=\"number\">" + c[i].index + "#</span>";
|
<span class="date">${timeFormat(comment.comment_date)}</span>
|
||||||
if (c[i].show_del == 1) html += "<i class=\"delete e-delete glyphicon glyphicon-remove\" style=\"color:red\" onclick=\"onDelComment(" + c[i].comment_id + ")\"></i>";
|
</p>
|
||||||
html += "</span>";
|
<div class="content">${comment.content}</div>
|
||||||
html += "</p>";
|
<p class="util">
|
||||||
html += "</div>";
|
${renderOperateSection(comment)}
|
||||||
|
</p>
|
||||||
|
</div>`;
|
||||||
}
|
}
|
||||||
$("#commentList").append(html);
|
$("#commentList").append(html);
|
||||||
|
|
||||||
if ($page.TotalPage > 1) {
|
if ($page.TotalPage > 1) {
|
||||||
$("#page").bootstrapPaginator({
|
$("#page").bootstrapPaginator({
|
||||||
currentPage: $page.PageNo,
|
currentPage: $page.PageNo,
|
||||||
|
@ -114,7 +127,6 @@ function loadComment($page, $docid) {
|
||||||
|
|
||||||
// 删除评论
|
// 删除评论
|
||||||
function onDelComment($id) {
|
function onDelComment($id) {
|
||||||
console.log($id);
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/comment/delete",
|
url: "/comment/delete",
|
||||||
data: { "id": $id },
|
data: { "id": $id },
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
window.IS_DOCUMENT_INDEX = '{{if .IS_DOCUMENT_INDEX}}true{{end}}' === 'true';
|
window.IS_DOCUMENT_INDEX = '{{if .IS_DOCUMENT_INDEX}}true{{end}}' === 'true';
|
||||||
window.IS_DISPLAY_COMMENT = '{{if .Model.IsDisplayComment}}true{{end}}' === 'true';
|
window.IS_DISPLAY_COMMENT = '{{if .Model.IsDisplayComment}}true{{end}}' === 'true';
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript">window.book={"identify":"{{.Model.Identify}}"};</script>
|
<script type="text/javascript">window.book={"identify": '{{.Model.Identify}}'};</script>
|
||||||
<style>
|
<style>
|
||||||
.btn-mobile {
|
.btn-mobile {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
Loading…
Reference in New Issue