Files
quinn-bbc/src/main/resources/templates/source/view.html
2022-05-14 01:14:16 +08:00

162 lines
7.6 KiB
HTML

<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>资源下载-Quinn</title>
<link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}">
<link rel="stylesheet" th:href="@{/wangedit/css/wang.style.css}"/>
<link rel="stylesheet" th:href="@{/css/backgroud.css}">
</head>
<body>
<!-- 导航栏 -->
<div th:replace="~{common/header::header(activeUrl='source')}"></div>
<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 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">
<input type="submit" id="downloadTrans" />
</form>
</div>
<input type="hidden" id="sourceDType" name="sourceDType" th:value="${source.getSourceType()}">
<hr style="margin-top: 18px">
<!--文章主体内容-->
<div id="editor-text-area" style="height: 600px"></div>
<textarea id="content-textarea" th:text="${source.getSourceContent()}" name="content" style="display: none;"></textarea>
</div>
<div class="col-md-12 source-main" style="margin-top: 20px">
<hr>
</div>
<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} ? ${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 id="content" name="content" class="form-control" rows="3" required/>
</div>
<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">
<strong class="d-block text-gray-dark" th:text="${comment.getUsername()} + '&nbsp;&nbsp;&nbsp;&nbsp;' + ${#dates.format(comment.getGmtCreate(),'yyyy-MM-dd HH:mm:ss')}"></strong>
<span th:text="${comment.getContent()}"></span>
</p>
</div>
</div>
</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="pb-2 mb-4 text-center">还没有人评论,抢个沙发?</h6>
</div>
</div>
</div>
</main>
<div th:replace="~{common/footer::footer}"></div>
<a class="to-top badge badge-light">返回顶部</a>
<script th:src="@{/js/jquery-3.5.1.min.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.bundle.min.js}"></script>
<script th:src="@{/js/toTop.js}"></script>
<script th:src="@{/js/jquery-ui.min.js}"></script>
<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(){
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({
url: "/source/download/" + sid,
async: false,
type: "post",
data: '',
success: function (res) {
this.disabled=false;
if (res.substr(0,4)!= 'http'){
$('#downloadTrans').click();
}else {
window.open(res);
}
}
});
}
}
function starFun(btn){
btn.disabled = true;
var userId = $('#userId').val();
var topicId = $('#topicId').val();
$.ajax({
url: "/source/star",
type: "post",
async: false,
data: {"userId": userId, "topicId": topicId},
success: function (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>