SceneDelegate.swift 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // SceneDelegate.swift
  3. // VenusKitto
  4. //
  5. // Created by Neoa on 2025/8/21.
  6. //
  7. import UIKit
  8. class SceneDelegate: UIResponder, UIWindowSceneDelegate {
  9. var window: UIWindow?
  10. func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
  11. // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
  12. // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
  13. // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
  14. guard let windowScene = (scene as? UIWindowScene) else { return }
  15. window = UIWindow(windowScene: windowScene)
  16. let isLogggedIn = UserDefaults.standard.bool(forKey: "isLogggedIn")
  17. // let startVC = LoginViewController()
  18. // let startVC = HomeViewController()
  19. // self.window?.rootViewController = UINavigationController(rootViewController: startVC)
  20. // UIView.transition(with: window!, duration: 0.2, options: .transitionCrossDissolve, animations: {
  21. // if isLogggedIn {
  22. // 用户已登录,显示主界面
  23. let mainVC = HomeViewController()
  24. self.window?.rootViewController = UINavigationController(rootViewController: mainVC)
  25. // } else {
  26. // // 用户未登录,显示登录界面
  27. // let loginVC = LoginViewController()
  28. // self.window?.rootViewController = UINavigationController(rootViewController: loginVC)
  29. // }
  30. // }, completion: nil)
  31. window?.makeKeyAndVisible()
  32. }
  33. func sceneDidDisconnect(_ scene: UIScene) {
  34. // Called as the scene is being released by the system.
  35. // This occurs shortly after the scene enters the background, or when its session is discarded.
  36. // Release any resources associated with this scene that can be re-created the next time the scene connects.
  37. // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
  38. }
  39. func sceneDidBecomeActive(_ scene: UIScene) {
  40. // Called when the scene has moved from an inactive state to an active state.
  41. // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
  42. }
  43. func sceneWillResignActive(_ scene: UIScene) {
  44. // Called when the scene will move from an active state to an inactive state.
  45. // This may occur due to temporary interruptions (ex. an incoming phone call).
  46. }
  47. func sceneWillEnterForeground(_ scene: UIScene) {
  48. // Called as the scene transitions from the background to the foreground.
  49. // Use this method to undo the changes made on entering the background.
  50. }
  51. func sceneDidEnterBackground(_ scene: UIScene) {
  52. // Called as the scene transitions from the foreground to the background.
  53. // Use this method to save data, release shared resources, and store enough scene-specific state information
  54. // to restore the scene back to its current state.
  55. }
  56. }