This commit is contained in:
limqhz
2022-05-03 21:15:47 +08:00
parent 0eed40c97e
commit cf985bd44f
11 changed files with 155 additions and 44 deletions

View File

@@ -14,7 +14,7 @@
<main role="main" class="mt-3">
<div class="container">
<form action="/source">
<form action="javascript:navChange(0);" method="post">
<div class="form-row align-items-center">
<div class="col-auto">
<label class="sr-only" for="name">KEYWORD</label>
@@ -31,7 +31,8 @@
<div class="input-group-prepend">
<div class="input-group-text">类别</div>
</div>
<select id="category" name="category" class="form-control">
<select id="category" name="category" class="form-control custom-select">
<option th:value=-1 th:text="请选择"></option>
<option th:each="category:${categoryList}" th:value="${category.getId()}" th:text="${category.getCategory()}"></option>
</select>
</div>
@@ -43,13 +44,13 @@
</div>
</form>
</div>
<div class="container">
<div class="container" th:fragment="s_table_refresh" th:id="id_s_table_refresh">
<table class="table">
<thead class="thead-light">
<tr>
<th scope="col">#</th>
<th scope="col">资源名</th>
<th scope="col">资源内容</th>
<th scope="col">资源简介</th>
<th scope="col">资源类型</th>
<th scope="col">去下载</th>
</tr>
@@ -58,7 +59,7 @@
<tr th:each="source:${sourceList}">
<td th:text="${source.getId()}"></td>
<td th:text="${source.getSourceName()}"></td>
<td th:text="${source.getSourceContent()}"></td>
<td th:text="${source.getDetail()}"></td>
<td th:text="${source.getCategoryName()}"></td>
<td th:name="${source.getId()}">
<a style="color: white" th:href="@{'/source/view/'+${source.getId()}}" class="btn btn-sm btn-primary">详情</a>
@@ -66,6 +67,25 @@
</tr>
</tbody>
</table>
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center">
<li th:class="${pageParam.hasPrevious()==true?'page-item':'page-item disabled'}">
<a class="page-link" href="javascript:navChange(-1);" tabindex="">Previous</a>
</li>
<li class="page-item" th:if="${pageParam.hasPrevious()}">
<a class="page-link" href="javascript:navChange(-1);" th:text="${pageParam.getCurrent()-1}"></a>
</li>
<li class="page-item active">
<a id = "current" class="page-link" href="javascript:navChange(0);" th:text="${pageParam.getCurrent()}"></a>
</li>
<li class="page-item" th:if="${pageParam.hasNext()}">
<a class="page-link" href="javascript:navChange(1);" th:text="${pageParam.getCurrent()+1}"></a>
</li>
<li th:class="${pageParam.hasNext()==true?'page-item':'page-item disabled'}">
<a class="page-link" href="javascript:navChange(1);">Next</a>
</li>
</ul>
</nav>
</div>
</main>
@@ -77,6 +97,21 @@
<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 type="text/javascript">
function navChange(page){
var name = $('#name').attr("value");
var category = $('#category').val();
var current = $('#current').text();
var pageNum = parseInt(current) + page;
$.ajax({
url: "/source/page",
type: "post",
data: {"name": name, "category": category, "pageNum": pageNum, "limit": 10},
success: function (data) {
$('#id_s_table_refresh').html(data);
}
});
}
</script>
</body>
</html>