| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- //
- // LNConfigManager.swift
- // Lanu
- //
- // Created by OneeChan on 2025/12/25.
- //
- import Foundation
- enum LNBannerAdSlot: Int {
- case homeAd = 1
- case roomAd = 2
- case walletAd = 3
- }
- class LNConfigManager {
- static let shared = LNConfigManager()
- private(set) var commonConfig = LNConfigResponse()
-
- var isBeanAvailable: Bool {
- guard let version = commonConfig.appReviewSpecialVersionConfig?.ios else { return false }
- if version.isEmpty { return true }
-
- guard let iVersion = Int(version) else { return false }
- if iVersion == 0 { return true }
-
- guard let curVersion = Int(curBuildVersion) else { return false }
- return curVersion < iVersion
- }
-
- private init() {
- LNEventDeliver.addObserver(self)
- }
-
- func reloadCommonConfig() {
- LNHttpManager.shared.getCommonConfig { [weak self] res, err in
- guard let self else { return }
- guard let res else { return }
-
- commonConfig = res
- }
- }
-
- func getCountryCodeList(queue: DispatchQueue = .main, handler: @escaping ([LNCountryCodeVO]?) -> Void) {
- LNHttpManager.shared.getCountryCodeList { res, err in
- queue.asyncIfNotGlobal {
- handler(res?.list)
- }
- if let err {
- showToast(err.errorDesc)
- }
- }
- }
-
- func getBannerList(adSlot: LNBannerAdSlot, queue: DispatchQueue = .main, handler: @escaping ([LNBannerInfoVO]?) -> Void) {
- LNHttpManager.shared.getBannerList(adSlot: adSlot.rawValue) { res, err in
- queue.asyncIfNotGlobal {
- handler(res?.list)
- }
- }
- }
- func getUpdateInfo(queue: DispatchQueue = .main, handler: @escaping (LNForceUpdateConfigResponse?) -> Void) {
- LNHttpManager.shared.getUpdateInfo { res, err in
- queue.asyncIfNotGlobal {
- handler(res)
- }
- }
- }
- }
- extension LNConfigManager: LNAccountManagerNotify {
- func onUserLogin() {
- reloadCommonConfig()
- }
- }
|