commit 修改web服务部分接口json数据获取格式

pull/66/head
ca1e 5 years ago
parent 3c22a6a02f
commit c38da3abf1
  1. 28
      app/src/main/assets/web/bookshelf.js
  2. 1
      app/src/main/assets/web/index.html
  3. 5
      app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt

@ -45,15 +45,15 @@ var init = () => {
books.forEach(book => { books.forEach(book => {
let bookDiv = $c("div"); let bookDiv = $c("div");
let img = $c("img"); let img = $c("img");
img.src = book.bookInfoBean.coverUrl || randomImg; img.src = book.coverUrl || randomImg;
img.setAttribute("data-series-num", book.serialNumber); img.setAttribute("data-series-num", book.serialNumber);
bookDiv.appendChild(img); bookDiv.appendChild(img);
bookDiv.innerHTML += `<table><tbody> bookDiv.innerHTML += `<table><tbody>
<tr><td>书名</td><td>${book.bookInfoBean.name}</td></tr> <tr><td>书名</td><td>${book.name}</td></tr>
<tr><td>作者</td><td>${book.bookInfoBean.author}</td></tr> <tr><td>作者</td><td>${book.author}</td></tr>
<tr><td>阅读</td><td>${book.durChapterName}<br>${formatTime(book.finalDate)}</td></tr> <tr><td>阅读</td><td>${book.durChapterTitle}<br>${formatTime(book.durChapterTime)}</td></tr>
<tr><td>更新</td><td>${book.lastChapterName}<br>${formatTime(book.finalRefreshData)}</td></tr> <tr><td>更新</td><td>${book.latestChapterTitle}<br>${formatTime(book.latestChapterTime)}</td></tr>
<tr><td>来源</td><td>${book.bookInfoBean.origin}</td></tr> <tr><td>来源</td><td>${book.origin}</td></tr>
</tbody></table>`; </tbody></table>`;
$('#books').appendChild(bookDiv); $('#books').appendChild(bookDiv);
}); });
@ -62,19 +62,19 @@ var init = () => {
$('#allcontent').classList.add("read"); $('#allcontent').classList.add("read");
var book = books[bookImg.getAttribute("data-series-num")]; var book = books[bookImg.getAttribute("data-series-num")];
$("#info").innerHTML = `<img src="${bookImg.src}"> $("#info").innerHTML = `<img src="${bookImg.src}">
<p>  来源${book.bookInfoBean.origin}</p> <p>  来源${book.origin}</p>
<p>  书名${book.bookInfoBean.name}</p> <p>  书名${book.name}</p>
<p>  作者${book.bookInfoBean.author}</p> <p>  作者${book.author}</p>
<p>阅读章节${book.durChapterName}</p> <p>阅读章节${book.durChapterName}</p>
<p>阅读时间${formatTime(book.finalDate)}</p> <p>阅读时间${formatTime(book.durChapterTime)}</p>
<p>最新章节${book.lastChapterName}</p> <p>最新章节${book.latestChapterTitle}</p>
<p>检查时间${formatTime(book.finalRefreshData)}</p> <p>检查时间${formatTime(book.lastCheckTime)}</p>
<p>  简介${book.bookInfoBean.introduce.trim().replace(/\n/g, "<br>")}</p>`; <p>  简介${book.intro.trim().replace(/\n/g, "<br>")}</p>`;
window.location.hash = ""; window.location.hash = "";
window.location.hash = "#info"; window.location.hash = "#info";
$("#content").innerHTML = "章节列表加载中..."; $("#content").innerHTML = "章节列表加载中...";
$("#chapter").innerHTML = ""; $("#chapter").innerHTML = "";
fetch(apiAddress("getChapterList", book.noteUrl), { mode: "cors" }) fetch(apiAddress("getChapterList", book.bookUrl), { mode: "cors" })
.then(res => res.json()) .then(res => res.json())
.then(data => { .then(data => {
if (!data.isSuccess) { if (!data.isSuccess) {

@ -294,6 +294,7 @@
<br>(?i) 前缀表示忽略大小写 <br>(?i) 前缀表示忽略大小写
</div> </div>
<a target="_blank" href="https://www.beta.browxy.com/">代码在线运行工具</a> <a target="_blank" href="https://www.beta.browxy.com/">代码在线运行工具</a>
<a target="_blank" href="/bookshelf.html">阅读书架(测试)</a>
</div> </div>
</div> </div>
</div> </div>

@ -93,9 +93,7 @@ class SearchViewModel(application: Application) : BaseViewModel(application) {
//存在 //存在
for (temp in newDataS) { for (temp in newDataS) {
var hasSame = false var hasSame = false
var i = 0 for (i in copyDataS.indices) {
val size = copyDataS.size
while (i < size) {
val searchBook = copyDataS[i] val searchBook = copyDataS[i]
if (temp.name == searchBook.name if (temp.name == searchBook.name
&& temp.author == searchBook.author && temp.author == searchBook.author
@ -104,7 +102,6 @@ class SearchViewModel(application: Application) : BaseViewModel(application) {
searchBook.addOrigin(temp.bookUrl) searchBook.addOrigin(temp.bookUrl)
break break
} }
i++
} }
if (!hasSame) { if (!hasSame) {
searchBooksAdd.add(temp) searchBooksAdd.add(temp)

Loading…
Cancel
Save