Reorganize docs and update reader search flows
This commit is contained in:
@@ -53,8 +53,20 @@ final class RDEPUBReaderLocationCoordinator {
|
||||
let readerView = context.readerView else {
|
||||
return nil
|
||||
}
|
||||
let pageNumber = readerView.currentPage + 1
|
||||
if (context.textBook != nil || context.bookPageMap != nil), readerView.currentPage >= 0 {
|
||||
return controller.resolvedTextLocation(forPageNumber: readerView.currentPage + 1)
|
||||
if let location = controller.resolvedTextLocation(forPageNumber: pageNumber) {
|
||||
return location
|
||||
}
|
||||
// resolvedTextLocation 可能因章节数据未加载而返回 nil,
|
||||
// 通过 readingSession 的 activePages 构建回退位置
|
||||
if let readingSession = context.readingSession,
|
||||
readingSession.activePages.indices.contains(readerView.currentPage) {
|
||||
return readingSession.fallbackLocation(
|
||||
for: readingSession.activePages[readerView.currentPage],
|
||||
bookIdentifier: context.currentBookIdentifier
|
||||
)
|
||||
}
|
||||
}
|
||||
return context.readingSession?.currentReadingLocation(bookIdentifier: context.currentBookIdentifier)
|
||||
}
|
||||
|
||||
@@ -103,8 +103,11 @@ final class RDEPUBReaderSearchCoordinator {
|
||||
|
||||
private func resolvedSearchMatches(for keyword: String) -> [RDEPUBSearchMatch] {
|
||||
guard let controller else { return [] }
|
||||
if let textBook = controller.textBook, let publication = controller.publication {
|
||||
return RDEPUBTextSearchEngine(textBook: textBook, publication: publication).search(keyword: keyword)
|
||||
if let textBook = controller.textBook {
|
||||
if let publication = controller.publication {
|
||||
return RDEPUBTextSearchEngine(textBook: textBook, publication: publication).search(keyword: keyword)
|
||||
}
|
||||
return RDEPUBTextSearchEngine.searchWithoutPublication(textBook: textBook, keyword: keyword)
|
||||
}
|
||||
if let parser = controller.parser, let publication = controller.publication {
|
||||
return RDEPUBHTMLSearchEngine(parser: parser, publication: publication).search(keyword: keyword)
|
||||
|
||||
Reference in New Issue
Block a user