feat: EPUB阅读器搜索、注释、CFI模块及大书远距跳转优化

- 实现EPUB阅读器搜索功能及选中注释功能
- 优化CFI模块,修复代码审查发现的11个问题
- 实现大书远距目录跳转与后台补全优化方案
- 优化设置面板与章节运行时联动
- 重构及大量改进优化
This commit is contained in:
shenlei
2026-06-22 20:26:34 +08:00
parent f50495ad91
commit c65c190b71
178 changed files with 11380 additions and 6728 deletions
@@ -1,34 +1,28 @@
// RDEPUBAssetRepository.swift
// EPUBCore
// EPUB JS HTML
// {{token}}
import Foundation
/// EPUB
enum RDEPUBAsset: String {
/// Rangy core Web range/selection
case rangyCoreScript = "rangy-core"
/// Rangy serializer DOM range /
case rangySerializerScript = "rangy-serializer"
/// WXRead CSS
case cssInjectorScript = "cssInjector"
/// WXRead WeReadApi JS-Native
case weReadAPIScript = "WeReadApi"
/// JS epub-bridge.js WebView -JS
case bridgeScript = "epub-bridge"
/// HTML epub-fixed-layout.html pre-paginated EPUB
case fixedLayoutTemplate = "epub-fixed-layout"
/// WXRead default.css
case wxReadDefaultCSS = "wxread-default"
/// WXRead replace.css
case wxReadReplaceCSS = "wxread-replace"
/// WXRead dark.css
case wxReadDarkCSS = "wxread-dark"
/// WXRead replaceForLatinLanguageBook.css
case wxReadLatinReplaceCSS = "wxread-replace-latin"
///
var fileExtension: String {
switch self {
case .rangyCoreScript, .rangySerializerScript, .cssInjectorScript, .weReadAPIScript, .bridgeScript:
@@ -41,13 +35,8 @@ enum RDEPUBAsset: String {
}
}
///
enum RDEPUBAssetRepository {
/// {{key}}
/// - Parameters:
/// - asset:
/// - replacements: key value
/// - Returns:
static func string(for asset: RDEPUBAsset, replacements: [String: String] = [:]) -> String {
guard let url = resourceBundle.url(forResource: asset.rawValue, withExtension: asset.fileExtension),
var content = try? String(contentsOf: url, encoding: .utf8) else {
@@ -61,7 +50,6 @@ enum RDEPUBAssetRepository {
return content
}
/// Bundle使 bundle宿 bundle
private static var resourceBundle: Bundle {
if let bundle = resolvedBundle {
return bundle
@@ -69,7 +57,6 @@ enum RDEPUBAssetRepository {
return Bundle(for: RDEPUBAssetBundleToken.self)
}
/// RDReaderViewAssets.bundle 宿 bundle framework
private static var resolvedBundle: Bundle? = {
let hostBundles = [Bundle(for: RDEPUBAssetBundleToken.self), Bundle.main] + Bundle.allFrameworks + Bundle.allBundles
for hostBundle in hostBundles {
@@ -82,5 +69,4 @@ enum RDEPUBAssetRepository {
}()
}
/// Bundle
private final class RDEPUBAssetBundleToken {}