import SwiftUI import WebKit struct SVGImage: UIViewRepresentable { let svgName: String var shouldFill: Bool = false func makeUIView(context: Context) -> WKWebView { let webView = WKWebView() webView.isOpaque = false webView.backgroundColor = .clear webView.scrollView.isScrollEnabled = false webView.scrollView.contentInsetAdjustmentBehavior = .never guard let path = Bundle.main.path(forResource: svgName, ofType: "svg") else { print("❌ 无法找到 SVG 文件: \(svgName).svg") return webView } let fileURL = URL(fileURLWithPath: path) let svgStyle = shouldFill ? """ width: 100%; height: 100%; object-fit: cover; """ : """ max-width: 100%; max-height: 100%; object-fit: contain; """ let htmlString = """