Skip to content

Commit 4fc7e23

Browse files
committed
feat(微信登录): 实现IMopShareSDKHandler接口并添加初始化检查
在WeChatLoginComponent中实现IMopShareSDKHandler接口以支持分享功能 在WeChatLoginManager中添加_isInit标志防止重复初始化
1 parent 115f4b6 commit 4fc7e23

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Runtime/WeChatLoginComponent.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
using System;
3333
using GameFrameX.Runtime;
34+
using GameFrameX.ShareSdk.Runtime;
3435
using UnityEngine;
3536

3637
namespace GameFrameX.Login.WeChat.Runtime
@@ -42,7 +43,7 @@ namespace GameFrameX.Login.WeChat.Runtime
4243
[RequireComponent(typeof(GameFrameXWeChatLoginCroppingHelper))]
4344
[AddComponentMenu("Game Framework/WeChat Login")]
4445
[UnityEngine.Scripting.Preserve]
45-
public class WeChatLoginComponent : GameFrameworkComponent
46+
public class WeChatLoginComponent : GameFrameworkComponent, IMopShareSDKHandler
4647
{
4748
private IWeChatLoginManager _weChatLoginManager = null;
4849

Runtime/WeChatLoginManager.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,16 @@ public WeChatLoginManager()
5050

5151
private EventComponent _eventComponent;
5252
private ShareSDK _shareSDK;
53+
private bool _isInit;
5354

5455
[UnityEngine.Scripting.Preserve]
5556
public void Init(string appId, string appKey)
5657
{
58+
if (_isInit)
59+
{
60+
return;
61+
}
62+
5763
_eventComponent = GameEntry.GetComponent<EventComponent>();
5864
_eventComponent.CheckSubscribe(AuthEventArgs.EventId, OnAuthEventArgs);
5965
_shareSDK = Object.FindObjectOfType<ShareSDK>();
@@ -65,6 +71,7 @@ public void Init(string appId, string appKey)
6571

6672
_shareSDK.devInfo.wechatMoments.AppId = appId;
6773
_shareSDK.devInfo.wechatMoments.AppSecret = appKey;
74+
_isInit = true;
6875
}
6976

7077
private void OnAuthEventArgs(object sender, GameEventArgs e)

0 commit comments

Comments
 (0)