This commit is contained in:
CortexCore
2023-10-06 23:43:19 +08:00
parent ebf9c1f526
commit 2c4710bc5d
186 changed files with 111802 additions and 764 deletions

8
Src/Core/Auth/Core.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b869357f0380e864eb445105d35c68b7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,87 @@
using System;
using Cysharp.Threading.Tasks;
namespace BITKit.Auth
{
/// <summary>
/// 授权服务
/// </summary>
public interface IAuthService
{
/// <summary>
/// 是否已授权
/// </summary>
bool IsAuthorized { get; }
/// <summary>
/// 是否正在授权
/// </summary>
bool IsAuthorizing { get; }
/// <summary>
/// 异步开始授权
/// </summary>
/// <param name="token">令牌</param>
UniTask AuthorizeAsync(string token);
/// <summary>
/// 异步取消授权
/// </summary>
/// <returns></returns>
UniTask CancelAuthorizationAsync();
/// <summary>
/// 开始授权的回调
/// </summary>
event Action<string> OnAuthorize;
/// <summary>
/// 已授权的回调
/// </summary>
event Action<string> OnAuthorized;
/// <summary>
/// 取消授权的回调
/// </summary>
event Action<string> UnAuthorize;
/// <summary>
/// 授权失败的回调
/// </summary>
event Action<string> OnAuthorizeFailure;
}
public abstract class AuthServiceImplement:IAuthService
{
protected abstract IAuthService service { get; }
bool IAuthService.IsAuthorized => service.IsAuthorized;
bool IAuthService.IsAuthorizing => service.IsAuthorizing;
UniTask IAuthService.AuthorizeAsync(string token)
{
return service.AuthorizeAsync(token);
}
UniTask IAuthService.CancelAuthorizationAsync()
{
return service.CancelAuthorizationAsync();
}
event Action<string> IAuthService.OnAuthorize
{
add => service.OnAuthorize += value;
remove => service.OnAuthorize -= value;
}
event Action<string> IAuthService.OnAuthorized
{
add => service.OnAuthorized += value;
remove => service.OnAuthorized -= value;
}
event Action<string> IAuthService.UnAuthorize
{
add => service.UnAuthorize += value;
remove => service.UnAuthorize -= value;
}
event Action<string> IAuthService.OnAuthorizeFailure
{
add => service.OnAuthorizeFailure += value;
remove => service.OnAuthorizeFailure -= value;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: df16dad99b7205a40b655489e7f19076
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: