Commit be463285584fb29f51759470e2c7d561ab1e9b50

Authored by “张旭”
1 parent 1b2ce5b2

根据版本号动态控制忽必烈gift开关

metaCode.xcodeproj/project.pbxproj
@@ -2968,7 +2968,7 @@ @@ -2968,7 +2968,7 @@
2968 CODE_SIGN_ENTITLEMENTS = metaCode/metaCode.entitlements; 2968 CODE_SIGN_ENTITLEMENTS = metaCode/metaCode.entitlements;
2969 CODE_SIGN_IDENTITY = "Apple Development"; 2969 CODE_SIGN_IDENTITY = "Apple Development";
2970 CODE_SIGN_STYLE = Automatic; 2970 CODE_SIGN_STYLE = Automatic;
2971 - CURRENT_PROJECT_VERSION = 1.1.7.25.04.26.16; 2971 + CURRENT_PROJECT_VERSION = 1.1.8.25.04.27.12;
2972 DEBUG_INFORMATION_FORMAT = dwarf; 2972 DEBUG_INFORMATION_FORMAT = dwarf;
2973 DEVELOPMENT_TEAM = 94X49GG3ZW; 2973 DEVELOPMENT_TEAM = 94X49GG3ZW;
2974 ENABLE_BITCODE = NO; 2974 ENABLE_BITCODE = NO;
@@ -3041,7 +3041,7 @@ @@ -3041,7 +3041,7 @@
3041 "$(inherited)", 3041 "$(inherited)",
3042 "@executable_path/Frameworks", 3042 "@executable_path/Frameworks",
3043 ); 3043 );
3044 - MARKETING_VERSION = 1.1.7; 3044 + MARKETING_VERSION = 1.1.8;
3045 OTHER_LDFLAGS = ( 3045 OTHER_LDFLAGS = (
3046 "$(inherited)", 3046 "$(inherited)",
3047 "-all_load", 3047 "-all_load",
@@ -3224,7 +3224,7 @@ @@ -3224,7 +3224,7 @@
3224 CODE_SIGN_ENTITLEMENTS = metaCode/metaCode.entitlements; 3224 CODE_SIGN_ENTITLEMENTS = metaCode/metaCode.entitlements;
3225 CODE_SIGN_IDENTITY = "Apple Development"; 3225 CODE_SIGN_IDENTITY = "Apple Development";
3226 CODE_SIGN_STYLE = Automatic; 3226 CODE_SIGN_STYLE = Automatic;
3227 - CURRENT_PROJECT_VERSION = 1.1.7.25.04.26.16; 3227 + CURRENT_PROJECT_VERSION = 1.1.8.25.04.27.12;
3228 DEVELOPMENT_TEAM = 94X49GG3ZW; 3228 DEVELOPMENT_TEAM = 94X49GG3ZW;
3229 ENABLE_BITCODE = NO; 3229 ENABLE_BITCODE = NO;
3230 ENABLE_MODULE_VERIFIER = NO; 3230 ENABLE_MODULE_VERIFIER = NO;
@@ -3296,7 +3296,7 @@ @@ -3296,7 +3296,7 @@
3296 "$(inherited)", 3296 "$(inherited)",
3297 "@executable_path/Frameworks", 3297 "@executable_path/Frameworks",
3298 ); 3298 );
3299 - MARKETING_VERSION = 1.1.7; 3299 + MARKETING_VERSION = 1.1.8;
3300 OTHER_LDFLAGS = ( 3300 OTHER_LDFLAGS = (
3301 "$(inherited)", 3301 "$(inherited)",
3302 "-all_load", 3302 "-all_load",
metaCode/Classes/Extensions/String+Extension.swift
@@ -10,6 +10,27 @@ import UIKit @@ -10,6 +10,27 @@ import UIKit
10 import CommonCrypto 10 import CommonCrypto
11 11
12 extension String { 12 extension String {
  13 + //比较两个版本号 //.orderedDescending前者version1版本更大 //.orderedAscending前者版本更小 //.orderedSame版本相等
  14 + func compareVersion(_ version2: String) -> ComparisonResult {
  15 + let v1Components = self.components(separatedBy: ".")
  16 + let v2Components = version2.components(separatedBy: ".")
  17 + let maxLength = max(v1Components.count, v2Components.count)
  18 +
  19 + for i in 0..<maxLength {
  20 + // 处理空位补 0
  21 + let v1 = i < v1Components.count ? (Int(v1Components[i]) ?? 0) : 0
  22 + let v2 = i < v2Components.count ? (Int(v2Components[i]) ?? 0) : 0
  23 +
  24 + if v1 > v2 {
  25 + return .orderedDescending // 当前版本更大
  26 + } else if v1 < v2 {
  27 + return .orderedAscending // 当前版本更小
  28 + }
  29 + }
  30 + return .orderedSame // 版本相等
  31 + }
  32 +
  33 +
13 /// Calculate text's height from `width` and `front`. 34 /// Calculate text's height from `width` and `front`.
14 func calculateHeightWith(width: CGFloat, font: UIFont)-> CGFloat { 35 func calculateHeightWith(width: CGFloat, font: UIFont)-> CGFloat {
15 let attr = [NSAttributedString.Key.font: font] 36 let attr = [NSAttributedString.Key.font: font]
metaCode/Classes/Main/MinePage/ViewModel/CNLiveMineViewModel.swift
@@ -882,8 +882,17 @@ class CNLiveMineViewModel: NSObject { @@ -882,8 +882,17 @@ class CNLiveMineViewModel: NSObject {
882 let userInfoModel = dictionaryToModel(resp as! [String : Any], UpdateInfoModel.self,"data") as! UpdateInfoModel 882 let userInfoModel = dictionaryToModel(resp as! [String : Any], UpdateInfoModel.self,"data") as! UpdateInfoModel
883 let ver1 = "\(userInfoModel.version.split(separator: "_").last ?? "0")" 883 let ver1 = "\(userInfoModel.version.split(separator: "_").last ?? "0")"
884 let ver2 = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as! String 884 let ver2 = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as! String
885 - print("获取的新版本号=>\(ver1),原来的版本号=>\(ver2)")  
886 - metaAppDelegate.isGift = userInfoModel.gift 885 + print("获取的新版本号=>\(ver1),本版本号=>\(ver2)")
  886 + //ver1后台版本 ver2本版本
  887 + let compareResult = ver1.compareVersion(ver2)
  888 + if compareResult == .orderedAscending{
  889 + //ver1后台版本 < ver2本版本
  890 + metaAppDelegate.isGift = false
  891 + }else{
  892 + //ver1后台版本 >= ver2本版本
  893 + metaAppDelegate.isGift = userInfoModel.gift
  894 + }
  895 +
887 if CNLiveMineViewModel.compare(v1: ver1, v2: ver2) { 896 if CNLiveMineViewModel.compare(v1: ver1, v2: ver2) {
888 resultBlock(userInfoModel,.success) 897 resultBlock(userInfoModel,.success)
889 } else { 898 } else {