Files
real-e-party-iOS/YuMi/E-P/NewLogin/Services/EPLoginManager.swift
edwinQQQ a0e83658c6 chore: 更新 .gitignore 文件并删除过时的文档
主要变更:
1. 在 .gitignore 中添加了 Docs/ 文件夹,以忽略文档相关文件。
2. 删除了多个过时的文档,包括构建指南、编译修复指南和当前状态报告等。

此更新旨在清理项目文件,确保版本控制的整洁性。
2025-10-16 16:04:15 +08:00

150 lines
5.5 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// EPLoginManager.swift
// YuMi
//
// Created by AI on 2025-01-27.
//
import UIKit
/// Swift
/// PILoginManager
@objc class EPLoginManager: NSObject {
// MARK: - Login Success Navigation
///
/// - Parameter viewController:
static func jumpToHome(from viewController: UIViewController) {
// 1.
guard let accountModel = AccountInfoStorage.instance().getCurrentAccountInfo() else {
print("[EPLoginManager] 账号信息不完整,无法继续")
return
}
let accessToken = accountModel.access_token
guard !accessToken.isEmpty else {
print("[EPLoginManager] access_token 为空,无法继续")
return
}
// 2. ticket
let loginService = EPLoginService()
loginService.requestTicket(accessToken: accessToken) { ticket in
// 3. ticket
AccountInfoStorage.instance().saveTicket(ticket)
// 4. EPTabBarController
DispatchQueue.main.async {
let epTabBar = EPTabBarController.create()
epTabBar.refreshTabBarWithIsLogin(true)
//
if let window = getKeyWindow() {
window.rootViewController = epTabBar
window.makeKeyAndVisible()
//
DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) {
Self.checkAndShowSignatureColorGuide(in: window)
}
}
print("[EPLoginManager] 登录成功,已切换到 EPTabBarController")
}
} failure: { code, msg in
print("[EPLoginManager] 请求 Ticket 失败: \(code) - \(msg)")
// Ticket
DispatchQueue.main.async {
let epTabBar = EPTabBarController.create()
epTabBar.refreshTabBarWithIsLogin(true)
if let window = getKeyWindow() {
window.rootViewController = epTabBar
window.makeKeyAndVisible()
//
DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) {
Self.checkAndShowSignatureColorGuide(in: window)
}
}
print("[EPLoginManager] Ticket 请求失败,仍跳转到首页")
}
}
}
/// Apple Login
/// - Parameter viewController:
static func loginWithApple(from viewController: UIViewController) {
print("[EPLoginManager] Apple Login - 占位Phase 2 实现")
// log
}
// MARK: - Helper Methods
/// keyWindowiOS 13+
private static func getKeyWindow() -> UIWindow? {
if #available(iOS 13.0, *) {
for windowScene in UIApplication.shared.connectedScenes {
if let windowScene = windowScene as? UIWindowScene,
windowScene.activationState == .foregroundActive {
for window in windowScene.windows {
if window.isKeyWindow {
return window
}
}
// keyWindow window
return windowScene.windows.first
}
}
} else {
// iOS 13 使
return UIApplication.shared.keyWindow
}
return nil
}
///
private static func checkAndShowSignatureColorGuide(in window: UIWindow) {
let hasSignatureColor = EPEmotionColorStorage.hasUserSignatureColor()
// #if DEBUG
print("[EPLoginManager] Debug 模式:显示专属颜色引导页(已有颜色: \(hasSignatureColor)")
let guideView = EPSignatureColorGuideView()
//
guideView.onColorConfirmed = { (hexColor: String) in
EPEmotionColorStorage.saveUserSignatureColor(hexColor)
print("[EPLoginManager] 用户选择专属颜色: \(hexColor)")
}
// Skip
if hasSignatureColor {
guideView.onSkipTapped = {
print("[EPLoginManager] 用户跳过专属颜色选择")
}
}
// Skip
guideView.show(in: window, showSkipButton: hasSignatureColor)
// #else
// // Release
// if !hasSignatureColor {
// let guideView = EPSignatureColorGuideView()
// guideView.onColorConfirmed = { (hexColor: String) in
// EPEmotionColorStorage.saveUserSignatureColor(hexColor)
// }
// guideView.show(in: window)
// }
// #endif
}
}