ζ-1 abgeschlossen: DeepLinkRouter + Web-Header-Hide
- DeepLinkRouter als pure-Logic-Enum aus RootView extrahiert (resolveToWebURL, isExplorePath, route) - 11 DeepLinkRouterTests grün: custom-scheme, https passthrough, Erkunden-vs-Lesen-Routing, Substring-Guard - WebShellScripts.hideWebHeader: WKUserScript injiziert at document.start CSS, das den zitare-Web-Header (body header:has(a.brand)) ausblendet. Native TabBar übernimmt globale Navigation, Content bleibt sichtbar. - Simulator-Verifikation: Quote rendert ohne doppelte Nav-Leiste, 17 (UI + Unit) Tests grün Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
75b5e7113f
commit
dd10f85cca
6 changed files with 166 additions and 36 deletions
30
Sources/Features/WebShell/WebShellScripts.swift
Normal file
30
Sources/Features/WebShell/WebShellScripts.swift
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import Foundation
|
||||
import WebKit
|
||||
|
||||
/// User-Scripts, die in jeden `WKWebView` injiziert werden.
|
||||
///
|
||||
/// `WKUserScript` ist MainActor-isolated; deshalb sind die Factory-
|
||||
/// Methoden hier ebenfalls MainActor. Aufrufer leben sowieso auf Main
|
||||
/// (SwiftUI `makeUIView`/`makeNSView` sind MainActor).
|
||||
@MainActor
|
||||
enum WebShellScripts {
|
||||
/// Versteckt den zitare-Web-Header (`<header>` mit `<a class="brand">`),
|
||||
/// weil die native TabBar bereits global navigiert. Footer und
|
||||
/// Hauptinhalt bleiben sichtbar.
|
||||
///
|
||||
/// CSS wird at document.start als `<style>`-Tag injiziert — vor dem
|
||||
/// First Paint, kein Flicker.
|
||||
static let hideWebHeader: WKUserScript = .init(
|
||||
source: """
|
||||
(function() {
|
||||
var css = 'body header:has(a.brand) { display: none !important; }';
|
||||
var style = document.createElement('style');
|
||||
style.setAttribute('data-zitare-native', 'hide-web-header');
|
||||
style.textContent = css;
|
||||
(document.head || document.documentElement).appendChild(style);
|
||||
})();
|
||||
""",
|
||||
injectionTime: .atDocumentStart,
|
||||
forMainFrameOnly: true
|
||||
)
|
||||
}
|
||||
|
|
@ -102,6 +102,7 @@ final class WebNavState {
|
|||
let config = WKWebViewConfiguration()
|
||||
config.websiteDataStore = .default()
|
||||
config.applicationNameForUserAgent = "ZitareNative/0.1 (iOS)"
|
||||
config.userContentController.addUserScript(WebShellScripts.hideWebHeader)
|
||||
let webView = WKWebView(frame: .zero, configuration: config)
|
||||
webView.navigationDelegate = context.coordinator
|
||||
webView.uiDelegate = context.coordinator
|
||||
|
|
@ -149,6 +150,7 @@ final class WebNavState {
|
|||
let config = WKWebViewConfiguration()
|
||||
config.websiteDataStore = .default()
|
||||
config.applicationNameForUserAgent = "ZitareNative/0.1 (macOS)"
|
||||
config.userContentController.addUserScript(WebShellScripts.hideWebHeader)
|
||||
let webView = WKWebView(frame: .zero, configuration: config)
|
||||
webView.navigationDelegate = context.coordinator
|
||||
webView.uiDelegate = context.coordinator
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue