refactor: 添加中文注释 + 优化模块结构
- 给全部 78 个 Swift 源文件添加详细的中文注释(文件级、类级、方法级) - 删除 LegacyRDReaderController/ 死代码目录(16 文件 4592 行) - 根目录翻页容器文件移入 ReaderView/ 目录 - Resources/ 移入 EPUBCore/Resources/(与使用者归属一致) - RDEPUBTextIndexTable.swift 移入 EPUBTextRendering/(消除反向依赖) - RDURLReaderController.swift 移入 EPUBUI/(入口控制器归入 UI 层) - 更新 podspec 资源路径
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
// RDEPUBWebView+Reflowable.swift
|
||||
// RDEPUBWebView 的重排模式渲染扩展
|
||||
// 处理重排(Reflowable)模式的加载流程:构建渲染请求、
|
||||
// 生成加载签名(去重)、通过 JS 桥接应用分页样式和高亮、
|
||||
// 处理重复请求跳过和已有文档复用等优化逻辑。
|
||||
|
||||
import UIKit
|
||||
import WebKit
|
||||
|
||||
extension RDEPUBWebView {
|
||||
/// 便捷方法:加载重排模式的指定页面
|
||||
public func loadPage(
|
||||
parser: RDEPUBParser,
|
||||
spineIndex: Int,
|
||||
@@ -39,6 +46,7 @@ extension RDEPUBWebView {
|
||||
load(publication: parser.makePublication(), request: request)
|
||||
}
|
||||
|
||||
/// 处理重排模式加载:设置状态、去重检查、加载资源或直接应用样式
|
||||
func handleReflowableLoad(
|
||||
publication: RDEPUBPublication,
|
||||
request: RDEPUBReflowableRenderRequest,
|
||||
@@ -83,6 +91,7 @@ extension RDEPUBWebView {
|
||||
webView.load(URLRequest(url: requestURL))
|
||||
}
|
||||
|
||||
/// 生成重排模式加载签名(包含所有渲染参数的哈希,用于去重)
|
||||
func reflowableLoadSignature(publicationKey: String, request: RDEPUBReflowableRenderRequest) -> String {
|
||||
let targetSignature = [
|
||||
request.targetLocation?.href ?? "",
|
||||
@@ -116,6 +125,7 @@ extension RDEPUBWebView {
|
||||
].joined(separator: "#")
|
||||
}
|
||||
|
||||
/// 应用分页展示样式:通过 JS 桥接注入 CSS、设置分页参数和高亮,然后触发渲染完成
|
||||
func applyPresentation() {
|
||||
guard let webView, let currentRenderRequest else { return }
|
||||
guard case .reflowable(let request) = currentRenderRequest else {
|
||||
|
||||
Reference in New Issue
Block a user