Kaynağa Gözat

异步加载一些步骤

harry 3 yıl önce
ebeveyn
işleme
18f1dfe751

+ 13 - 12
Introduce/Aarchitecture/AppDelegate.swift

@@ -17,8 +17,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
     var notificationUserInfo: [String: Any]?
     
     func application(_: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
-        // 初始化配置
-        INAppConfigUtil.pageConfig()
         if launchOptions?.keys.contains(UIApplication.LaunchOptionsKey.remoteNotification) ?? false {
             notificationUserInfo = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any]
             if notificationUserInfo != nil && notificationUserInfo?.keys.contains("type") ?? false {
@@ -26,7 +24,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
             }
         }
         // 配置启动项
-        INAppConfigUtil.applicationConfig(launchOptions:launchOptions)
+        DispatchQueue.global().async {
+            // 初始化配置
+        #if DEBUG
+        #else
+            INAppConfigUtil.pageConfig()
+            INAppConfigUtil.applicationConfig(launchOptions:launchOptions)
+        #endif
+
+        }
 //        BFMaterialConfig.shared.choseType = .single
         return true
     }
@@ -38,8 +44,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
     func applicationDidEnterBackground(_: UIApplication) {
         // 热启动重新生成SubSesstionId
         isEnterBack = true
-        PQSingletoMemoryUtil.shared.createSubSesstionId()
-        BFConfig.shared.subSessionId = PQSingletoMemoryUtil.shared.subSessionid
+        DispatchQueue.global().async {
+            PQSingletoMemoryUtil.shared.createSubSesstionId()
+            BFConfig.shared.subSessionId = PQSingletoMemoryUtil.shared.subSessionid
+        }
     }
 
     func application(_: UIApplication, supportedInterfaceOrientationsFor _: UIWindow?) -> UIInterfaceOrientationMask {
@@ -56,12 +64,5 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
             INAppConfigUtil.appLaunchReportUpload(isHotLaunch: true)
             isEnterBack = false
         }
-        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {
-            if #available(iOS 14, *) {
-                ATTrackingManager.requestTrackingAuthorization { status in
-                    
-                }
-            }
-        }
     }
 }

+ 6 - 3
Introduce/Record/INAppConfigUtil.swift

@@ -69,14 +69,17 @@ class INAppConfigUtil: NSObject {
         buglyConfig.reportLogLevel = .warn
         #if DEBUG
             buglyConfig.version = versionName + ".6666"
-            buglyConfig.debugMode = true
+            buglyConfig.debugMode = false
+            buglyConfig.unexpectedTerminatingDetectionEnable = false
+            buglyConfig.blockMonitorEnable = false
+        
         #else
             buglyConfig.version = versionName + "." + versionCode
+            buglyConfig.unexpectedTerminatingDetectionEnable = true
+            buglyConfig.blockMonitorEnable = true
         #endif
         buglyConfig.channel = channel
         buglyConfig.deviceIdentifier = deviceId ?? ""
-        buglyConfig.unexpectedTerminatingDetectionEnable = true
-        buglyConfig.blockMonitorEnable = true
         buglyConfig.blockMonitorTimeout = 2
         Bugly.start(withAppId: appID, config: buglyConfig)
     }

+ 5 - 5
Introduce/Record/INRecorderController.swift

@@ -105,7 +105,6 @@ class INRecorderController: BFBaseViewController {
  
     lazy var protocolLab: TYAttributedLabel = {
    
-        
         let protocolLab = TYAttributedLabel()
         protocolLab.highlightedLinkBackgroundColor = UIColor.clear
         protocolLab.backgroundColor = UIColor.clear
@@ -203,9 +202,10 @@ class INRecorderController: BFBaseViewController {
     }
     
     override func viewDidLoad() {
-        
-        if #available(iOS 14, *) {
-            ATTrackingManager.requestTrackingAuthorization { [weak self] _ in
+        DispatchQueue.global().async {[weak self] in
+            if #available(iOS 14, *) {
+                ATTrackingManager.requestTrackingAuthorization { [weak self] _ in
+                }
             }
         }
         super.viewDidLoad()
@@ -220,7 +220,7 @@ class INRecorderController: BFBaseViewController {
 
         view.addSubview(centerView)
         centerView.snp.makeConstraints { make in
-            make.width.equalTo(140)
+            make.width.equalToSuperview()
             make.height.equalTo(209)
             make.center.equalToSuperview()
         }

+ 12 - 16
Introduce/Record/INVideoExportController.swift

@@ -237,22 +237,20 @@ class INVideoExportController: BFBaseViewController {
         let export = BFRecordExport()
 
         export.progress = { [weak self] progress in
-            DispatchQueue.main.async { [weak self] in
-                if let wself = self {
-//                    let width = export.data?.first?.width ?? 0
-                    wself.progressL.text = String(format: "%d%%", Int(progress * 100))
-                    wself.progressView.snp.updateConstraints { make in
-                        make.width.equalTo(wself.playerLayer.bounds.width * CGFloat(progress))
-                    }
+            DispatchQueue.main.async {[weak self] in
+                guard let wself = self else { return }
+                
+                wself.progressL.text = String(format: "%d%%", Int(progress * 100))
+                wself.progressView.snp.updateConstraints { make in
+                    make.width.equalTo(wself.playerLayer.bounds.width * CGFloat(progress))
                 }
             }
         }
 
         export.exportCompletion = { [weak self] error, url in
             DispatchQueue.main.async { [weak self] in
-                guard let wself = self else {
-                    return
-                }
+                guard let wself = self else { return }
+                
                 UIApplication.shared.isIdleTimerDisabled = false
 
                 wself.resetViewStatus()
@@ -653,13 +651,11 @@ class INVideoExportController: BFBaseViewController {
             PHPhotoLibrary.shared().performChanges {
                 PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: url)
             } completionHandler: { [weak self] isFinished, _ in
-                guard let wself = self else {
-                    return
-                }
+                guard let wself = self else { return }
+                
                 if isFinished {
-                    DispatchQueue.main.async {
-                        cShowHUB(superView: nil, msg: "compose_tips_successfully".BFLocale, style: 1)
-                    }
+                    cShowHUB(superView: nil, msg: "compose_tips_successfully".BFLocale, style: 1)
+                    
                     if wself.saveAllBtn.isSelected {
                         wself.hasSaveAll = true
                     } else if wself.saveOnlyBtn.isSelected {