杨锴
2024-10-24 e821bea13d9f20905bba3972c4e9c4964994db5d
XQMuse/Config/Def.swift
@@ -12,7 +12,8 @@
import QMUIKit
import OSLog
//https://dummyimage.com/100x100
let WeChatAPPID = "wx4b9c1d814c2902a3"
let WeChatSecrect = "60fed4b6f52603ba6769e1118b4a57ae"
let app = UIApplication.shared.delegate as! AppDelegate
@@ -20,110 +21,110 @@
let ShareAppleKey = ""
var sceneDelegate:SceneDelegate? = {
            var uiScreen:UIScene?
            UIApplication.shared.connectedScenes.forEach { scenes in
                        uiScreen = scenes
            }
            return (uiScreen?.delegate as? SceneDelegate)
    var uiScreen:UIScene?
    UIApplication.shared.connectedScenes.forEach { scenes in
        uiScreen = scenes
    }
    return (uiScreen?.delegate as? SceneDelegate)
}()
func LogSuccess(_ items:Any...,separator:String=" ",file:String=#file,function:String=#function,line:Int=#line){
#if DEBUG
            if #available(iOS 14.0, *) {
                        let logger = Logger(subsystem: "WanPai", category: function)
                        logger.error("\(items)")
            }else{
                        let file = (file as NSString).lastPathComponent.split(separator: ".").first!;
                        print("✅✅✅ SUCCESS: \(file)  \(function) [Line: \(line)]: \(items)",separator);
            }
    if #available(iOS 14.0, *) {
        let logger = Logger(subsystem: "WanPai", category: function)
        logger.error("\(items)")
    }else{
        let file = (file as NSString).lastPathComponent.split(separator: ".").first!;
        print("✅✅✅ SUCCESS: \(file)  \(function) [Line: \(line)]: \(items)",separator);
    }
#endif
}
func LogError(_ items:Any...,separator:String=" ",file:String=#file,function:String=#function,line:Int=#line){
#if DEBUG
            if #available(iOS 14.0, *) {
                        let logger = Logger(subsystem: "WanPai", category: function)
                        logger.error("\(items)")
            }else{
                        let file = (file as NSString).lastPathComponent.split(separator: ".").first!;
                        print("❌❌❌ ERROR: \(file)  \(function) [Line: \(line)]: \(items)",separator);
            }
    if #available(iOS 14.0, *) {
        let logger = Logger(subsystem: "WanPai", category: function)
        logger.error("\(items)")
    }else{
        let file = (file as NSString).lastPathComponent.split(separator: ".").first!;
        print("❌❌❌ ERROR: \(file)  \(function) [Line: \(line)]: \(items)",separator);
    }
#endif
}
func LogInfo(_ items:Any...,separator:String=" ",file:String=#file,function:String=#function,line:Int=#line){
#if DEBUG
            if #available(iOS 14.0, *) {
                        let logger = Logger(subsystem: "WanPai", category: function)
                        logger.error("\(items)")
            }else{
                        let file = (file as NSString).lastPathComponent.split(separator: ".").first!;
                        print("⚠️⚠️⚠️INFO: \(file)  \(function) [Line: \(line)]: \(items)",separator);
            }
    if #available(iOS 14.0, *) {
        let logger = Logger(subsystem: "WanPai", category: function)
        logger.error("\(items)")
    }else{
        let file = (file as NSString).lastPathComponent.split(separator: ".").first!;
        print("⚠️⚠️⚠️INFO: \(file)  \(function) [Line: \(line)]: \(items)",separator);
    }
#endif
}
func LogResponse(_ items:Any...,separator:String=" ",file:String=#file,function:String=#function,line:Int=#line){
#if DEBUG
            print("返回数据")
            print(items);
    print("返回数据")
    print(items);
#endif
}
//提示框
func alert(msg: String) {
            SVProgressHUD.showInfo(withStatus: msg)
    SVProgressHUD.showInfo(withStatus: msg)
}
func alertError(msg:String){
            SVProgressHUD.showError(withStatus: msg)
    SVProgressHUD.showError(withStatus: msg)
}
func alertSuccess(msg:String){
            SVProgressHUD.showSuccess(withStatus: msg)
    SVProgressHUD.showSuccess(withStatus: msg)
}
func showHUD(_ text:String? = nil){
            SVProgressHUD.show(withStatus: text)
    SVProgressHUD.show(withStatus: text)
}
func hiddenHUD(_ delay:TimeInterval? = nil){
            if delay != nil{
                        SVProgressHUD.dismiss(withDelay: delay!)
            }else{
                        SVProgressHUD.dismiss()
            }
    if delay != nil{
        SVProgressHUD.dismiss(withDelay: delay!)
    }else{
        SVProgressHUD.dismiss()
    }
}
extension UIButton {
            func localGradientColor(cornerRadius:Double,bounds:CGRect? = nil){
                        self.layer.sublayers?.removeAll(where: {$0 is CAGradientLayer})
                        self.jq_gradientColor(colorArr: [UIColor(hexStr: "#8EA47A").cgColor,UIColor(hexStr: "#AFCA98").cgColor], cornerRadius: cornerRadius, startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0, y: 1), bounds: bounds)
            }
    func localGradientColor(cornerRadius:Double,bounds:CGRect? = nil){
        self.layer.sublayers?.removeAll(where: {$0 is CAGradientLayer})
        self.jq_gradientColor(colorArr: [UIColor(hexStr: "#8EA47A").cgColor,UIColor(hexStr: "#AFCA98").cgColor], cornerRadius: cornerRadius, startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0, y: 1), bounds: bounds)
    }
            public func openCountDown(_ t:Int = 59,defultTitle:String = "获取验证码"){
                        var time = t //倒计时时间
                        let queue = DispatchQueue.global()
                        let timer = DispatchSource.makeTimerSource(flags: [], queue: queue)
                        timer.schedule(wallDeadline: DispatchWallTime.now(), repeating: .seconds(1));
                        timer.setEventHandler(handler: {
                                    if time <= 0 {
                                                timer.cancel()
                                                DispatchQueue.main.async(execute: {
                                                            self.setTitle(defultTitle, for: .normal)
                                                            self.setTitleColor(UIColor(hexStr: "#63BDDB"), for: .normal)
                                                            self.isUserInteractionEnabled = true
                                                });
                                    }else {
                                                DispatchQueue.main.async(execute: {
                                                            self.setTitle("\(time)s", for: .normal)
                                                            self.setTitleColor(UIColor.gray, for: .normal)
                                                            self.isUserInteractionEnabled = false
                                                });
                                    }
                                    time -= 1
                        });
                        timer.resume()
            }
    public func openCountDown(_ t:Int = 59,defultTitle:String = "获取验证码"){
        var time = t //倒计时时间
        let queue = DispatchQueue.global()
        let timer = DispatchSource.makeTimerSource(flags: [], queue: queue)
        timer.schedule(wallDeadline: DispatchWallTime.now(), repeating: .seconds(1));
        timer.setEventHandler(handler: {
            if time <= 0 {
                timer.cancel()
                DispatchQueue.main.async(execute: {
                    self.setTitle(defultTitle, for: .normal)
                    self.setTitleColor(UIColor(hexStr: "#63BDDB"), for: .normal)
                    self.isUserInteractionEnabled = true
                });
            }else {
                DispatchQueue.main.async(execute: {
                    self.setTitle("\(time)s", for: .normal)
                    self.setTitleColor(UIColor.gray, for: .normal)
                    self.isUserInteractionEnabled = false
                });
            }
            time -= 1
        });
        timer.resume()
    }
}