add all
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using IchniOnline.Online.Logic;
|
||||
using TapSDK.Login;
|
||||
using IchniOnline.Online.Network.Models;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -58,46 +58,43 @@ namespace Ichni.UI
|
||||
Debug.LogWarning("[LoginPage] tapTapButton 未赋值");
|
||||
}
|
||||
|
||||
// 在 Start 中订阅事件(确保 ThirdPartyServiceManager.Instance 已初始化)
|
||||
SubscribeThirdPartyEvents();
|
||||
// 在 Start 中订阅 AuthService 事件
|
||||
SubscribeAuthEvents();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
UnsubscribeThirdPartyEvents();
|
||||
UnsubscribeAuthEvents();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
// 每次启用时重新订阅(处理 DontDestroyOnLoad 场景切换等情况)
|
||||
SubscribeThirdPartyEvents();
|
||||
SubscribeAuthEvents();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
UnsubscribeThirdPartyEvents();
|
||||
UnsubscribeAuthEvents();
|
||||
}
|
||||
|
||||
#region ThirdPartyServiceManager Event Subscription
|
||||
#region IchniOnlineAuthService Event Subscription
|
||||
|
||||
private void SubscribeThirdPartyEvents()
|
||||
private void SubscribeAuthEvents()
|
||||
{
|
||||
if (ThirdPartyServiceManager.Instance == null) return;
|
||||
ThirdPartyServiceManager.Instance.OnLoginSuccess -= OnTapTapLoginSuccess;
|
||||
ThirdPartyServiceManager.Instance.OnLoginCanceled -= OnTapTapLoginCanceled;
|
||||
ThirdPartyServiceManager.Instance.OnLoginFailed -= OnTapTapLoginFailed;
|
||||
IchniOnlineAuthService.OnLoginSuccess -= OnAuthLoginSuccess;
|
||||
IchniOnlineAuthService.OnLoginFailed -= OnAuthLoginFailed;
|
||||
IchniOnlineAuthService.OnLoginCanceled -= OnAuthLoginCanceled;
|
||||
|
||||
ThirdPartyServiceManager.Instance.OnLoginSuccess += OnTapTapLoginSuccess;
|
||||
ThirdPartyServiceManager.Instance.OnLoginCanceled += OnTapTapLoginCanceled;
|
||||
ThirdPartyServiceManager.Instance.OnLoginFailed += OnTapTapLoginFailed;
|
||||
IchniOnlineAuthService.OnLoginSuccess += OnAuthLoginSuccess;
|
||||
IchniOnlineAuthService.OnLoginFailed += OnAuthLoginFailed;
|
||||
IchniOnlineAuthService.OnLoginCanceled += OnAuthLoginCanceled;
|
||||
}
|
||||
|
||||
private void UnsubscribeThirdPartyEvents()
|
||||
private void UnsubscribeAuthEvents()
|
||||
{
|
||||
if (ThirdPartyServiceManager.Instance == null) return;
|
||||
ThirdPartyServiceManager.Instance.OnLoginSuccess -= OnTapTapLoginSuccess;
|
||||
ThirdPartyServiceManager.Instance.OnLoginCanceled -= OnTapTapLoginCanceled;
|
||||
ThirdPartyServiceManager.Instance.OnLoginFailed -= OnTapTapLoginFailed;
|
||||
IchniOnlineAuthService.OnLoginSuccess -= OnAuthLoginSuccess;
|
||||
IchniOnlineAuthService.OnLoginFailed -= OnAuthLoginFailed;
|
||||
IchniOnlineAuthService.OnLoginCanceled -= OnAuthLoginCanceled;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -111,7 +108,7 @@ namespace Ichni.UI
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 点击 TapTap 按钮:发起 TapTap 登录
|
||||
/// 点击 TapTap 按钮:通过 AuthService 发起 TapTap 登录
|
||||
/// </summary>
|
||||
private void OnTapTapClicked()
|
||||
{
|
||||
@@ -121,39 +118,48 @@ namespace Ichni.UI
|
||||
tapTapButton.interactable = false;
|
||||
if (closeButton != null) closeButton.interactable = false;
|
||||
|
||||
ThirdPartyServiceManager.Instance?.StartTapTapLogin();
|
||||
Debug.Log("[LoginPage] 正在登录...");
|
||||
IchniOnlineAuthService.LoginWithTapTap();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TapTap 登录成功回调
|
||||
/// AuthService 登录成功回调
|
||||
/// </summary>
|
||||
private void OnTapTapLoginSuccess(TapTapAccount account)
|
||||
private void OnAuthLoginSuccess(LoginResponseDto response)
|
||||
{
|
||||
_isLoggingIn = false;
|
||||
Debug.Log($"[LoginPage] TapTap 登录成功,用户:{account.name}");
|
||||
|
||||
if (response == null || response.User == null)
|
||||
{
|
||||
Debug.Log("[LoginPage] 登录成功(无用户详情)");
|
||||
FadeOut(0.5f, false, RestoreStartPage);
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log($"[LoginPage] 登录成功,用户:{response.User.DisplayName}(ID: {response.User.UserId})");
|
||||
|
||||
// 登录成功后淡出登录页
|
||||
FadeOut(0.5f, false, RestoreStartPage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TapTap 登录取消回调
|
||||
/// AuthService 登录失败回调
|
||||
/// </summary>
|
||||
private void OnTapTapLoginCanceled()
|
||||
private void OnAuthLoginFailed(string error)
|
||||
{
|
||||
_isLoggingIn = false;
|
||||
RestoreButtons();
|
||||
Debug.Log("[LoginPage] 用户取消了 TapTap 登录");
|
||||
Debug.LogError($"[LoginPage] 登录失败:{error}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TapTap 登录失败回调
|
||||
/// AuthService 登录取消回调
|
||||
/// </summary>
|
||||
private void OnTapTapLoginFailed(string error)
|
||||
private void OnAuthLoginCanceled()
|
||||
{
|
||||
_isLoggingIn = false;
|
||||
RestoreButtons();
|
||||
Debug.LogError($"[LoginPage] TapTap 登录失败:{error}");
|
||||
Debug.Log("[LoginPage] 用户取消了登录");
|
||||
}
|
||||
|
||||
private void RestoreButtons()
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Ichni.UI
|
||||
AudioManager.Post(AK.EVENTS.TOUCHTOSTART);
|
||||
|
||||
// 已有登录缓存 → 跳过 LoginPage,直接进入章节选择
|
||||
if (LoginCacheManager.HasCachedLogin)
|
||||
if (LoginCacheManager.HasValidSession)
|
||||
{
|
||||
FadeOut();
|
||||
floatingParticles.GetComponent<Renderer>().material.DOColor(Color.clear, "_BaseColor", 0.5f).Play();
|
||||
|
||||
Reference in New Issue
Block a user