杨锴
2025-06-04 ac84f81ca2311300b431c1bfb9f71253b59073f2
DolphinEnglishLearnStudent/Config/Config.swift
@@ -19,117 +19,123 @@
let ShareAppleKey = "af37e916cd2b4a0293e37ac405ba4f1c"
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)
}()
struct Config {
            static let ThemeBGColor:UIColor = UIColor(hexStr: "#C3BFB3")
            static let ThemeColor:UIColor = UIColor(hexStr: "#4195D3")
            static let NavFontColor = UIColor.black.withAlphaComponent(0.8)
            static let NavFont = UIFont.systemFont(ofSize: 15, weight: .medium)
    static let ThemeBGColor:UIColor = UIColor(hexStr: "#C3BFB3")
    static let ThemeColor:UIColor = UIColor(hexStr: "#4195D3")
    static let NavFontColor = UIColor.black.withAlphaComponent(0.8)
    static let NavFont = UIFont.systemFont(ofSize: 15, weight: .medium)
            static var RatioW:Double{get{return JQ_ScreenW / 810.0}}
            static var RatioH:Double{get{return JQ_ScreenH / 1080.0}}
    static var RatioW:Double{get{return JQ_ScreenW / 810.0}}
    static var RatioH:Double{get{return JQ_ScreenH / 1080.0}}
}
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: "English", 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: "English", 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: "English", 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: "English", 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: "English", 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: "English", 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{
            public func openCountDown(_ t:Int = 59,defultTitle:String = "获取验证码",textColor:UIColor,unenableColor:UIColor){
                        var time = t //倒计时时间
                        let queue = DispatchQueue.main
                        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(textColor, for: .normal)
                                                            self.isUserInteractionEnabled = true
                                                });
                                    }else {
                                                self.setTitle("\(time)s", for: .normal)
                                                self.setTitleColor(unenableColor, for: .normal)
                                                self.isUserInteractionEnabled = false
                                    }
                                    time -= 1
                        });
                        timer.resume()
            }
    public func openCountDown(_ t:Int = 59,defultTitle:String = "获取验证码",textColor:UIColor,unenableColor:UIColor){
        var time = t //倒计时时间
        let queue = DispatchQueue.main
        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(textColor, for: .normal)
                    self.isUserInteractionEnabled = true
                });
            }else {
                self.setTitle("\(time)s", for: .normal)
                self.setTitleColor(unenableColor, for: .normal)
                self.isUserInteractionEnabled = false
            }
            time -= 1
        });
        timer.resume()
    }
}
extension UIImage{
    var themeGreen:UIImage{
        return self.withTintColor(UIColor(hexStr: "#51aaed"))
    }
}