- 拆分 ContentDelegates/TextContentView 为独立协调器(InteractionCoordinator、LocationResolution、ExternalLinks、AttachmentTooltip) - 新增 RDEPUBAttachmentTooltipView/OverlayView 附件气泡提示 - 新增 RDEPUBDarkImageAdjuster 暗色模式图片亮度适配 - 新增 RDEPUBSelectionLoupeView 选区放大镜 - 新增 MetadataParseWorker/CancellationController 元数据解析取消机制 - 重构 PresentationRuntime/PaginationCoordinator 精简职责 - 优化 ChapterLoader/WarmupOrchestrator 异步章节加载 - CFI 模块微调与 NoteModels 更新 - 清理冗余文档,更新架构/UML/业务逻辑文档 Co-Authored-By: Claude <noreply@anthropic.com>
36 lines
1.2 KiB
Swift
36 lines
1.2 KiB
Swift
|
|
import UIKit
|
|
|
|
extension RDEPUBReaderController {
|
|
|
|
func openExternalURLIfAllowed(_ url: URL) {
|
|
guard shouldAllowExternalURL(url) else { return }
|
|
if configuration.requiresExternalLinkConfirmation {
|
|
presentExternalLinkConfirmation(for: url)
|
|
} else {
|
|
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
|
}
|
|
}
|
|
|
|
private func shouldAllowExternalURL(_ url: URL) -> Bool {
|
|
guard let scheme = url.scheme?.lowercased() else { return false }
|
|
if delegate?.epubReader(self, shouldOpenExternalURL: url) == false {
|
|
return false
|
|
}
|
|
return configuration.allowedExternalURLSchemes.contains(scheme)
|
|
}
|
|
|
|
private func presentExternalLinkConfirmation(for url: URL) {
|
|
let alert = UIAlertController(
|
|
title: "打开外部链接",
|
|
message: url.absoluteString,
|
|
preferredStyle: .alert
|
|
)
|
|
alert.addAction(UIAlertAction(title: "取消", style: .cancel))
|
|
alert.addAction(UIAlertAction(title: "打开", style: .default) { _ in
|
|
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
|
})
|
|
present(alert, animated: true)
|
|
}
|
|
}
|