This commit is contained in:
limqhz
2022-05-14 01:14:16 +08:00
parent a3df75bd66
commit 9e1dd3af77
31 changed files with 625 additions and 2240 deletions

View File

@@ -16,27 +16,27 @@
<main role="main" class="container mt-3 p-3 bg-white rounded">
<div class="row">
<div class="col-md-12 source-main">
<div class="source-post">
<h2 class="source-post-title" th:text="${source.getSourceName()}"></h2>
<p class="source-post-meta">
<span class="badge-pill badge-primary" th:text="${source.getCategoryName()}">
</span>
<span th:text="${#dates.format(source.getGmtUpdate(),'yyyy-MM-dd HH:mm:ss')}"></span>
<span class="ml-1">
<a class="text-danger text-decoration-none" th:fragment="star_refresh" th:id="id_star_refresh"
href="javascript:starFun(this);">
<svg th:if="${starValue.isStar() == true}" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-heart-fill" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"/>
</svg>
<svg th:if="${starValue.isStar() != true}" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-heart" viewBox="0 0 16 16">
<path d="m8 2.748-.717-.737C5.6.281 2.514.878 1.4 3.053c-.523 1.023-.641 2.5.314 4.385.92 1.815 2.834 3.989 6.286 6.357 3.452-2.368 5.365-4.542 6.286-6.357.955-1.886.838-3.362.314-4.385C13.486.878 10.4.28 8.717 2.01L8 2.748zM8 15C-7.333 4.868 3.279-3.04 7.824 1.143c.06.055.119.112.176.171a3.12 3.12 0 0 1 .176-.17C12.72-3.042 23.333 4.867 8 15z"/>
</svg>
[[${starValue.getTotal()}]]
</a>
</span>
<a href="javascript:downloadFile(this);" class="btn btn-outline-success col-md-2 float-right">下载</a>
</p>
<div class="source-post row">
<h2 class="source-post-title col-md-12" th:text="${source.getSourceName()}"></h2>
<p class="source-post-meta col-md-9">
<span class="badge-pill badge-primary" th:text="${source.getCategoryName()}">
</span>
<span th:text="${#dates.format(source.getGmtUpdate(),'yyyy-MM-dd HH:mm:ss')}"></span>
<span class="ml-1">
<a th:if="${session.loginUser}" class="text-danger text-decoration-none" th:fragment="star_refresh" th:id="id_star_refresh"
href="javascript:starFun(this);">
<svg th:if="${starValue.isStar() == true}" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-heart-fill" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"/>
</svg>
<svg th:if="${starValue.isStar() != true}" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-heart" viewBox="0 0 16 16">
<path d="m8 2.748-.717-.737C5.6.281 2.514.878 1.4 3.053c-.523 1.023-.641 2.5.314 4.385.92 1.815 2.834 3.989 6.286 6.357 3.452-2.368 5.365-4.542 6.286-6.357.955-1.886.838-3.362.314-4.385C13.486.878 10.4.28 8.717 2.01L8 2.748zM8 15C-7.333 4.868 3.279-3.04 7.824 1.143c.06.055.119.112.176.171a3.12 3.12 0 0 1 .176-.17C12.72-3.042 23.333 4.867 8 15z"/>
</svg>
[[${starValue.getTotal()}]]
</a>
</span>
</p>
<a th:if="${session.loginUser}" href="javascript:downloadFile();"class="btn btn-outline-success col-md-2">下载</a>
<button th:if="!${session.loginUser}" disabled class="btn btn-outline-dark col-md-2">请登录后下载</button>
</div>
<div style="display: none">
<form th:action="@{'/source/download/'+${source.getSid()}}" method="post">
@@ -47,7 +47,7 @@
<hr style="margin-top: 18px">
<!--文章主体内容-->
<div id="editor-text-area" style="height: 400px"></div>
<div id="editor-text-area" style="height: 600px"></div>
<textarea id="content-textarea" th:text="${source.getSourceContent()}" name="content" style="display: none;"></textarea>
</div>
@@ -58,21 +58,19 @@
<div class="col-md-12 source-main" style="margin-top: 20px">
<form th:action="@{'/source/comment/'+${source.getSid()}}" method="post">
<input type="hidden" id="userId" name="userId" th:value="${session.loginUser.getUid()}">
<input type="hidden" name="userName" th:value="${session.loginUser.getUsername()}">
<input type="hidden" name="userAvatar" th:value="${session.loginUser.getAvatar()}">
<input type="hidden" id="userId" name="userId" th:value="@{${session.loginUser} ? ${session.loginUser.getUid()} : ''}">
<input type="hidden" name="userName" th:value="@{${session.loginUser} ? ${session.loginUser.getUsername()} : ''}">
<input type="hidden" id="topicId" name="topicId" th:value="${source.getSid()}">
<div class="form-group">
<input name="content" class="form-control" rows="3" required />
<input id="content" name="content" class="form-control" rows="3" required/>
</div>
<button type="submit" onclick="this.disabled=true; this.form.submit();" class="btn btn-primary float-right">提交评论</button>
<button type="submit" onclick="comment()" class="btn btn-primary float-right">提交评论</button>
</form>
</div>
<div th:if="${commentList.size()!=0}" class="col-md-12 source-main" style="margin-top: 20px">
<div class="my-3 p-3 bg-white rounded shadow-sm">
<h6 class="border-bottom border-gray pb-2 mb-0">评论列表</h6>
<div th:each="comment:${commentList}" class="media text-muted pt-3">
<img th:src="${comment.getAvatar()}" style="border-radius: 5px;margin-right: 5px " width="32" height="32">
<p class="media-body pb-3 mb-0 small lh-125 border-bottom border-gray">
@@ -103,12 +101,18 @@
<script th:src="@{/live/js/addlive2d.js}"></script>
<script th:src="@{/wangedit/js/wang.min.js}"></script>
<script th:src="@{/wangedit/js/wang.read.js}"></script>
<script th:src="@{/layer/mobile/layer.js}"></script>
<script type="text/javascript">
function downloadFile(btn){
btn.disabled=true;
function downloadFile(){
if ($('#userId').val()==''){
layer.open({ content: '请登录之后下载', skin: 'msg', time: 2 });
return;
}
this.disabled=true;
var sid = $('#topicId').val();
var sourceDType = $('#sourceDType').val();
if (sourceDType == 'OSS'){
this.disabled=false;
$('#downloadTrans').click();
}else {
$.ajax({
@@ -117,7 +121,12 @@
type: "post",
data: '',
success: function (res) {
window.open(res);
this.disabled=false;
if (res.substr(0,4)!= 'http'){
$('#downloadTrans').click();
}else {
window.open(res);
}
}
});
}
@@ -133,11 +142,20 @@
async: false,
data: {"userId": userId, "topicId": topicId},
success: function (data) {
console.log(data);
$('#id_star_refresh').html(data);
}
});
}
function comment(){
let content = $('#content').val();
if (!content){
layer.open({ content: '评论内容不能为空', skin: 'msg', time: 2 });
return;
}
this.submit();
}
</script>
</body>
</html>