Visual_Novel_iOS/crush/Crush/AppLaunchInitial.swift

84 lines
2.2 KiB
Swift
Raw Normal View History

2025-10-09 10:29:35 +00:00
//
// AppLaunchInitial.swift
// Crush
//
// Created by Leon on 2025/7/19.
//
import Foundation
//import IQKeyboardManagerSwift
import IQKeyboardToolbarManager
import IQKeyboardManagerSwift
class AppLaunchInitial{
public func setupCommon(){
// User
UserCore.shared.autoLoginTry()
setupUIAbout()
LTNetworkManage.ltManage.netWorkReachability(reachabilityStatus: nil)
IAPCore.shared.check()
IMManager.shared.setupNIM()
H5BaseViewController.clearCache()
loadApis(excludeNoNeedLogin: false)
setupEvent()
}
/// excludeNoNeedLogin, 使false
private func loadApis(excludeNoNeedLogin : Bool){
// Req Dict Data
if excludeNoNeedLogin == false{
AppDictManager.shared.loadRequiredDict()
}
WalletCore.shared.refreshWallet(block: nil)
IMManager.shared.regetNoticeUnread()
}
private func setupEvent(){
NotificationCenter.default.addObserver(self, selector: #selector(notifyNetworkRestore), name: AppNotificationName.networkRestored.notificationName, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(loginIn), name: AppNotificationName.userLoginSuccess.notificationName, object: nil)
}
// MARK: - Functions
private func setupUIAbout(){
setupIQKeyboard()
CLPopoverListView.setupCLStyle()
UICommonSetup.setupCLStyle()
}
// MARK: Helper
private func setupIQKeyboard(){
DispatchQueue.main.async {
IQKeyboardToolbarManager.shared.isEnabled = true
IQKeyboardToolbarManager.shared.toolbarConfiguration.tintColor = .c.cpn
IQKeyboardManager.shared.isEnabled = true
IQKeyboardManager.shared.disabledDistanceHandlingClasses = [SessionController.self]
}
}
// MARK: - Notification
@objc private func notifyNetworkRestore(){
dlog("🛜网络恢复")
loadApis(excludeNoNeedLogin: false)
}
@objc private func loginIn(){
loadApis(excludeNoNeedLogin: true)
}
}