XuqmGroup-iOSSDK/Sources/XuqmWebViewSDK/XWebViewTypes.swift
XuqmGroup 85dd1b2b99 feat: iOS SDK 完善 — XWebView 双桥接 + BugCollect/Update macOS 兼容 + CI 流水线
XuqmCoreSDK
- 新增 userId / token(nonisolated) / deviceId 公开属性,对齐 BugCollectSDK / WebViewSDK 引用

XuqmWebViewSDK
- XWebViewTypes:新增 jsBridgeName / onClose / onPageError / onProgressChanged / onNavigationChanged
- XWebViewView:注册双 bridge(ReactNativeWebView 内部 + 自定义 jsBridgeName)、KVO progress、nav delegate
- XWebViewStandardHandlers:@MainActor,injectedJavaScript 改 nonisolated,兼容 macOS
- 新增 import XuqmCoreSDK

XuqmBugCollectSDK
- 全局 #if canImport(UIKit) 兼容 macOS 编译
- isReady 从 computed var 改为 func 消除歧义
- LogQueue 修正 LogStorage 为 enum 静态方法调用

XuqmUpdateSDK
- getDeviceInfo() #if canImport(UIKit) 兼容 macOS

XuqmLicenseSDK
- ensureInitializedFromSDK() 用 DispatchQueue.main.sync 访问 @MainActor 属性

CI
- 重写 Jenkinsfile:增加 SNAPSHOT/Release 模式,统一版本号管理,修正 git URL,对齐 Android 流水线
- 新增 version.properties:统一追踪 SDK_VERSION
- 更新 .gitignore:移除 JS/Java 噪音,补 Swift/Xcode 规则

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 11:28:18 +08:00

68 行
2.7 KiB
Swift

import Foundation
import XuqmFileSDK
public struct XWebViewConfig: Sendable {
public var url: String
public var title: String
public var hideToolbar: Bool
public var hideStatusBar: Bool
public var userAgent: String?
public var injectedJavaScript: String?
/// Native message handler name registered in WKUserContentController.
/// H5 side calls `window.webkit.messageHandlers.<jsBridgeName>.postMessage(json)`.
public var jsBridgeName: String
/// Where intercepted WebView downloads are saved.
public var downloadDestination: FileDownloadDestination
/// Custom message callback receives raw JSON string from H5 via jsBridgeName bridge.
public var onMessage: (@Sendable (String) -> Void)?
/// Called when the WebView container should close (xuqm.closeWebView JSBridge command).
public var onClose: (@Sendable () -> Void)?
/// Called on page load error. Receives a human-readable error description.
public var onPageError: (@Sendable (String) -> Void)?
/// Called as the page loads. Progress is 0100.
public var onProgressChanged: (@Sendable (Int) -> Void)?
/// Called when the navigation stack changes. (canGoBack, canGoForward)
public var onNavigationChanged: (@Sendable (Bool, Bool) -> Void)?
public init(
url: String = "",
title: String = "",
hideToolbar: Bool = false,
hideStatusBar: Bool = false,
userAgent: String? = nil,
injectedJavaScript: String? = nil,
jsBridgeName: String = "SZYX_APP",
downloadDestination: FileDownloadDestination = .sandbox,
onMessage: (@Sendable (String) -> Void)? = nil,
onClose: (@Sendable () -> Void)? = nil,
onPageError: (@Sendable (String) -> Void)? = nil,
onProgressChanged: (@Sendable (Int) -> Void)? = nil,
onNavigationChanged: (@Sendable (Bool, Bool) -> Void)? = nil
) {
self.url = url
self.title = title
self.hideToolbar = hideToolbar
self.hideStatusBar = hideStatusBar
self.userAgent = userAgent
self.injectedJavaScript = injectedJavaScript
self.jsBridgeName = jsBridgeName
self.downloadDestination = downloadDestination
self.onMessage = onMessage
self.onClose = onClose
self.onPageError = onPageError
self.onProgressChanged = onProgressChanged
self.onNavigationChanged = onNavigationChanged
}
}
public protocol XWebViewController: AnyObject {
func canGoBack() -> Bool
func canGoForward() -> Bool
func currentUrl() -> String?
func goBack()
func goForward()
func reload()
func load(url: String)
func postMessageToWeb(js: String)
}