Files
yingmeng-ios-switf/yinmeng-ios/AppDelegate.swift

50 lines
1.3 KiB
Swift
Raw Normal View History

2024-02-21 21:30:13 +08:00
//
// AppDelegate.swift
// yinmeng-ios
//
// Created by MaiMang on 2024/1/30.
//
import UIKit
2024-02-24 13:49:51 +08:00
import DeviceKit
2024-02-25 12:53:56 +08:00
import NSObject_Rx
2024-02-21 21:30:13 +08:00
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UIApplication.shared.applicationIconBadgeNumber = 0
self.window = UIWindow.init(frame: UIScreen.main.bounds)
self.window?.backgroundColor = UIColor.white
2024-02-22 19:59:38 +08:00
self.window?.rootViewController = BaseNavigationViewController(rootViewController:AuthLoginVC())
2024-02-25 12:53:56 +08:00
loginStateListener()
2024-02-21 21:30:13 +08:00
return true
}
2024-02-24 13:49:51 +08:00
2024-02-25 12:53:56 +08:00
private func loginStateListener() {
2024-02-25 23:11:02 +08:00
AuthViewModel.authVM.appClientConfig()
///
AuthViewModel.authVM.checkUserIsLogin()
2024-02-25 12:53:56 +08:00
AuthViewModel.authVM.loginSuccess.subscribe(onNext: { result in
print("是否登录成功\(result)")
if result == true {
///tabbar
2024-02-25 13:10:44 +08:00
self.window?.rootViewController = BaseTabBarViewController()
2024-02-25 23:11:02 +08:00
if let uid = LoginTokenConfig.config.getAccountInfo()?.uid {
UserViewModel.userVM.getUserInfo(uid: uid)
}
2024-02-25 12:53:56 +08:00
} else {
///
self.window?.rootViewController = BaseNavigationViewController(rootViewController:AuthLoginVC())
}
}).disposed(by: rx.disposeBag)
2024-02-25 23:11:02 +08:00
2024-02-25 12:53:56 +08:00
}
2024-02-21 21:30:13 +08:00
}
2024-02-24 13:49:51 +08:00