1
0
mirror of https://gitee.com/bookshelfplus/bookshelfplus synced 2025-09-01 22:53:29 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
bookshelfplus/bookshelfplus-frontend/views/book.html

87 lines
3.1 KiB
HTML

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%- include("./component/header.html"); %>
<style>
.main {
width: 80vw !important;
max-width: initial !important;
}
#bookImage {
/* width: 100%; */
height: auto;
max-height: 300px;
margin-bottom: 20px;
}
</style>
</head>
<body>
<%- include("./component/navbar.html"); %>
<main class="main">
<!-- <h1><%= title %></h1> -->
<div id="container">
</div>
</main>
<%- include("./component/footer.html"); %>
<!-- 获取参数 -->
<script src="./assets/javascripts/getParams.js"></script>
<script>
var requestParams = getParams();
var searchbox = document.getElementById("searchInput");
var bookId = Number(requestParams["id"]) ?? "";
if (bookId === "") {
location.href = "/search";
}
</script>
<script>
getRequest("/book/get", { id: bookId })
.then(function (response) {
var axiosData = response.data;
var status = axiosData.status;
var data = axiosData.data;
if (status === "success") {
console.log(data)
data.thumbnail = "https://img14.360buyimg.com/pop/jfs/t1/141705/31/25225/853702/61a85f89Ef68c838b/929ded96a4a7579e.png";
if(data.description == ""){
data.description = "暂无描述";
}
document.getElementById("container").innerHTML =`
<div class="grid">
<div class="grid-item">
<img id="bookImage" src="${data.thumbnail}" alt="书籍缩略图">
</div>
<div class="grid-item">
<h1>${data.bookName}</h1>
</div>
<div class="grid-item">
<a href="/download/?bookId=${data.id}">下载这本书</a>
</div>
<div class="grid-item">
<p>作者:${data.author}</p>
<p>所属分类:<a href="/category?id=${data.category.id}">${data.category.name}</a></p>
<p>语言:${data.language}</p>
<p>出版社:${data.publishingHouse}</p>
<p></p>
</div>
</div>
<div>
<h2>书本介绍</h2>
<p>${data.description}</p>
<h2>版权信息</h2>
<p>${data.copyright}</p>
</div>`;
// 渲染后重新获取一次字体
fontmin(getPageText());
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
}
}).catch(function (error) {
console.log(error);
});
</script>
</body>
</html>