AppDelegate.swift 2.52 KB
//
//  AppDelegate.swift
//  metaCode
//
//  Created by iOS on 2023/5/30.
//

import UIKit
import CNLiveRequestBastKit
import IQKeyboardManagerSwift
import SwiftyUserDefaults

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?
    

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
        // Override point for customization after application launch.
        
        window = UIWindow.init(frame: UIScreen.main.bounds)
        window?.backgroundColor = KVCBackgroupColor
        window?.rootViewController = UserInfoManager.shared.is_login ? CNLiveBaseTabBarViewController.init() : CNLiveLoginViewController.init()
        window?.makeKeyAndVisible()
        
        
        AppDelegate_configRequestManager()
        AppDelegate_configIQKeyboardManager()
        
        return true
    }
    
    // MARK: - 键盘处理
    func AppDelegate_configIQKeyboardManager() {
        IQKeyboardManager.shared.enable = true
        IQKeyboardManager.shared.enableAutoToolbar = true //工具条
        IQKeyboardManager.shared.shouldResignOnTouchOutside = true //点击背景收回键盘
        IQKeyboardManager.shared.toolbarDoneBarButtonItemText = "完成"
        //        IQKeyboardManager.shared.preventShowingBottomBlankSpace = true
        //        IQKeyboardManager.shared.preventShowingBottomBlankSpace = false
        IQKeyboardManager.shared.toolbarTintColor = .lightGray
        IQKeyboardManager.shared.keyboardDistanceFromTextField = 5.0
    }
    
    // MARK: - 网络请求通用参数
    func AppDelegate_configRequestManager() {
        let kAppBundleID = Bundle.main.bundleIdentifier ?? ""
        let uuid : String = UIDevice.current.identifierForVendor?.uuidString.replacingOccurrences(of: "-", with: "") ?? ""
        let ver : String = Bundle.main.infoDictionary?["CFBundleVersion"] as! String
        let p : Dictionary = ["platform_id":kAppBundleID,"uuid":uuid,"plat":"i","ver":ver,"appId":"802_li40qhp922","timestamp":String(NSNumber(floatLiteral: Date().timeIntervalSince1970).intValue),"clientPlat":"i","frmId":"ios"]
        CNLiveNetworking.setupDefaultParam(p)
        CNLiveNetworking.setupShowDataResult(false)
        CNLiveNetworking.setupSignKey("ae3a7ad3e4b9beb7cfe2078db648ebb89aa249ca2e82ac")
        CNLiveNetworking.setAllowRequestDefaultArgument(true)
        CNLiveNetworking.setResponseSerializerType(.JSON)
        CNLiveNetworking.setupBaseURL("https://api.cnlive.com")
    }


}