1
0
mirror of https://gitee.com/bookshelfplus/bookshelfplus synced 2025-10-21 22:56:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

完成书名搜索功能

This commit is contained in:
2022-03-15 23:51:23 +08:00
parent 4ceb7578b8
commit 174d24d5d0
5 changed files with 40 additions and 15 deletions

View File

@@ -52,7 +52,7 @@
}
function search(searchboxValue) {
getRequest("/book/search", { bookName: encodeURIComponent(searchboxValue) })
getRequest("/book/search", { bookName: searchboxValue })
.then(function (responseData) {
var axiosData = responseData.data;
var status = axiosData.status;
@@ -66,12 +66,12 @@
var mainDivWidth = 80/*vw*/; // 定义div的宽度用于计算表格中的数据的显示长度
var columnWidth = [23, 17, 30, 10, 20];
renderData.push({
书名: ` <a href="/book?id=${element.category.id}">
书名: ` <a target="_blank" href="/book?id=${element.category.id}">
<span class="overflow-omit" style="max-width: ${columnWidth[0] * mainDivWidth / 100}vw; max-height: 2em; margin: 0 auto;">
${element.bookName}
</span>
</a>`,
分类: ` <a href="/category?id=${element.category.id}">
分类: ` <a target="_blank" href="/category?id=${element.category.id}">
<span class="overflow-omit" style="max-width: ${columnWidth[1] * mainDivWidth / 100}vw; max-height: 2em; margin: 0 auto;">
${element.category.name}
</span>
@@ -89,7 +89,7 @@
});
if(renderData.length == 0) {
renderTable({ data: "没有搜索到相关书籍", tableId: "result-table", renderTableHead: true });
renderTable({ data: `没有搜索到与 <span style="color: red;">${searchboxValue}</span> 相关书籍,请换个关键词再试试吧`, tableId: "result-table", renderTableHead: true });
} else {
renderTable({ data: renderData, tableId: "result-table", renderTableHead: true });
}