feat: EPUB阅读器搜索、注释、CFI模块及大书远距跳转优化
- 实现EPUB阅读器搜索功能及选中注释功能 - 优化CFI模块,修复代码审查发现的11个问题 - 实现大书远距目录跳转与后台补全优化方案 - 优化设置面板与章节运行时联动 - 重构及大量改进优化
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
// RDEPUBWebView+Configuration.swift
|
||||
// RDEPUBWebView 的 WKWebView 配置扩展
|
||||
// 负责按需创建和配置 WKWebView 实例:注册 JS 桥接消息处理器、
|
||||
// 注入用户脚本、设置自定义 URL Scheme 处理器、配置滚动和外观属性。
|
||||
// 同时处理选择菜单(拷贝/高亮/批注)和 WebView 销毁清理。
|
||||
|
||||
import UIKit
|
||||
import WebKit
|
||||
|
||||
extension RDEPUBWebView {
|
||||
/// 按需配置 WKWebView(仅在 Publication 变更或 WebView 不存在时重建)
|
||||
|
||||
func configureWebViewIfNeeded(publication: RDEPUBPublication) {
|
||||
let parser = publication.parser
|
||||
let publicationKey = parser.opfURL?.path ?? parser.extractionRootURL?.path ?? UUID().uuidString
|
||||
@@ -73,18 +68,15 @@ extension RDEPUBWebView {
|
||||
RDEPUBWebViewDebug.log(debugScope, message: "configured webView=\(RDEPUBWebViewDebug.webViewID(webView)) publicationKey=\(publicationKey)")
|
||||
}
|
||||
|
||||
/// 处理选择菜单动作(拷贝/高亮/批注),通知委托并清除选择
|
||||
func handleSelectionMenuAction(_ action: RDEPUBAnnotationMenuAction) {
|
||||
delegate?.epubWebView(self, didRequestSelectionAction: action)
|
||||
clearWebSelection()
|
||||
}
|
||||
|
||||
/// 清除 WebView 中的文本选择
|
||||
func clearWebSelection() {
|
||||
webView?.evaluateJavaScript("window.getSelection && window.getSelection().removeAllRanges();")
|
||||
}
|
||||
|
||||
/// 销毁 WebView,移除所有消息处理器和引用
|
||||
func teardownWebView() {
|
||||
cancelFixedLayoutReadyFallback()
|
||||
if let webView {
|
||||
@@ -106,7 +98,7 @@ extension RDEPUBWebView {
|
||||
}
|
||||
|
||||
extension UIColor {
|
||||
/// 将 UIColor 转换为 CSS 十六进制颜色字符串(如 "#FF0000")
|
||||
|
||||
var ss_hexString: String {
|
||||
var red: CGFloat = 0
|
||||
var green: CGFloat = 0
|
||||
|
||||
Reference in New Issue
Block a user