✨ (search): 搜索书目带上译者

This commit is contained in:
Garfield committed 2026-11-30 21:07:54 +08:00
1 parent fb35a0560d
commit 69a72f63c0
3 files changed
+17 -1

No files matched your search

+13
View File
@@ -14,6 +14,19 @@ package.preload["source.contract"] = nil
local Mapper = require("moonsource_weread.mapper")
-- 搜索书目带译者。没有 translator 的书给空串,公众号条目丢掉。
do
local books = Mapper.searchBooks({ books = {
{ type = 0, bookInfo = { bookId = 31503072, title = "地下室手记(果麦经典)", author = "[俄]陀思妥耶夫斯基", translator = "曾思艺" } },
{ type = 0, bookInfo = { bookId = 3300154232, title = "地下室手记(经典译本无删减)", author = "[俄]陀思妥耶夫斯基著" } },
{ type = 3, mpInfo = { title = "公众号" } },
} })
Assert.len(books, 2)
Assert.eq(books[1].translator, "曾思艺")
Assert.eq(books[1].author, "[俄]陀思妥耶夫斯基")
Assert.eq(books[2].translator, "", "接口没给译者")
end
do
local _b, cover = Mapper.book({ bookId = "wx-2", cover = "https://cdn.weread.qq.com/weread/cover/80/y_1/s_y_1.jpg" })
Assert.eq(cover, "https://cdn.weread.qq.com/weread/cover/80/y_1/t7_y_1.jpg")
+2 -1
View File
@@ -1373,7 +1373,7 @@ do
fake_client.searchAsync = function(_self, word, cb, author)
keyword, got_author = word, author
cb({ books = {
{ type = 0, bookInfo = { bookId = 834464, title = "活着", author = "余华", publisher = "作家" } },
{ type = 0, bookInfo = { bookId = 834464, title = "活着", author = "余华", translator = "曾思艺", publisher = "作家" } },
{ type = 3, mpInfo = { title = "公众号" } },
} })
return { cancel = function() end }
@@ -1385,6 +1385,7 @@ do
Assert.len(found, 1)
Assert.eq(found[1].book_id, "834464")
Assert.eq(found[1].author, "余华")
Assert.eq(found[1].translator, "曾思艺", "搜索书目带译者")
end
-- pushNotesAsync 中途取消:在途请求被取消,迟到回包不回调、不再发后续请求。