杨锴
2024-11-11 9e77b0f9014653255eb51e81b8a8ba719443839d
XQMuse/Root/Other/WebVC.swift
@@ -16,6 +16,7 @@
            private(set) var url:String?
            private(set) var htmlText:String?
            private(set) var baseUrl:URL?
    private var showHelp = false
            private var progressView = UIProgressView()
            private let jsCode = """
                        var meta = document.createElement('meta');"
@@ -27,9 +28,10 @@
            public var tintColor = UIColor.blue
    private var subVC:Bool = false
            public convenience init(url:String) {
    public convenience init(url:String,showHelp:Bool = false) {
                        self.init()
                        self.url = url
        self.showHelp = showHelp
            }
    public convenience init(type:AgreementType,subVC:Bool = false){
@@ -45,6 +47,17 @@
            public override func viewDidLoad() {
                        super.viewDidLoad()
        if showHelp{
            let btn = UIButton(type: .custom)
            btn.setTitle("我的助力", for: .normal)
            btn.setTitleColor(UIColor(hexString: "#353535"), for: .normal)
            btn.titleLabel?.font = .systemFont(ofSize: 15)
            btn.addTarget(self, action: #selector(myHelpAction), for: .touchUpInside)
            navigationItem.rightBarButtonItem = UIBarButtonItem(customView: btn)
        }
                        let config = WKWebViewConfiguration()
                        let userScript = WKUserScript(source: jsCode, injectionTime: .atDocumentStart, forMainFrameOnly: true)
@@ -106,6 +119,12 @@
                        }
            }
    @objc func myHelpAction(){
        let vc = WebVC(url: ShareUrl + "/ranking/recommend?userId=\(UserViewModel.getAvatarInfo().id)")
        vc.title = "我的助力"
        push(vc: vc)
    }
            deinit {
                        webView?.removeObserver(self, forKeyPath: "estimatedProgress")
            }