diff --git a/Assets/Res/language/language.json b/Assets/Res/language/language.json index 96e8d22..3ab8338 100644 --- a/Assets/Res/language/language.json +++ b/Assets/Res/language/language.json @@ -1106,8 +1106,8 @@ }, { "key": "100222", - "zh": "WiFi配置成功", - "en": "Wi-Fi configuration successful" + "zh": "WiFi配置成功,请等待设备上线", + "en": "WiFi configuration succeeded. Please wait for the device to come online." }, { "key": "100223", @@ -1593,6 +1593,11 @@ "key": "100319", "zh": "重置密码成功", "en": "Reset password successfully" + }, + { + "key": "100320", + "zh": "*仅支持 2.4GHz Wi-Fi", + "en": "*Only 2.4GHz Wi-Fi is supported" } diff --git a/Assets/Res/ui/common/选择wifi.prefab b/Assets/Res/ui/common/选择wifi.prefab index d6e85a1..37e4a32 100644 --- a/Assets/Res/ui/common/选择wifi.prefab +++ b/Assets/Res/ui/common/选择wifi.prefab @@ -415,6 +415,99 @@ MonoBehaviour: m_OnClick: m_PersistentCalls: m_Calls: [] +--- !u!1 &4694359929881063008 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8113684184675763967} + - component: {fileID: 8340398492869491780} + - component: {fileID: 5788126856848396414} + - component: {fileID: 3030358004855797205} + m_Layer: 5 + m_Name: tip + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &8113684184675763967 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4694359929881063008} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 8895813539220665191} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 30, y: -194.7} + m_SizeDelta: {x: 300, y: 30} + m_Pivot: {x: 0, y: 0.5} +--- !u!222 &8340398492869491780 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4694359929881063008} + m_CullTransparentMesh: 1 +--- !u!114 &5788126856848396414 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4694359929881063008} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.5411765, g: 0.54901963, b: 0.54509807, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 24 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 2 + m_MaxSize: 40 + m_Alignment: 6 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: "*\u4EC5\u652F\u6301 2.4GHz Wi\u2011Fi" +--- !u!114 &3030358004855797205 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4694359929881063008} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 89f1d49b50a31514787b4e268b1c73bb, type: 3} + m_Name: + m_EditorClassIdentifier: + textKey: 100320 --- !u!1 &4797642664822797758 GameObject: m_ObjectHideFlags: 0 @@ -452,7 +545,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -201} + m_AnchoredPosition: {x: 0, y: -231} m_SizeDelta: {x: -60, y: 100} m_Pivot: {x: 0.5, y: 1} --- !u!222 &5544399545256808103 @@ -768,7 +861,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -325} + m_AnchoredPosition: {x: 0, y: -355} m_SizeDelta: {x: -60, y: 100} m_Pivot: {x: 0.5, y: 1} --- !u!222 &3367125048176631317 @@ -923,6 +1016,7 @@ RectTransform: - {fileID: 7112136920545491980} - {fileID: 8726634204092568047} - {fileID: 7198707897839895149} + - {fileID: 8113684184675763967} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} diff --git a/Assets/Res/ui/connectdevicepage/connectDevicePage.prefab b/Assets/Res/ui/connectdevicepage/connectDevicePage.prefab index 7b13a74..8ad8273 100644 --- a/Assets/Res/ui/connectdevicepage/connectDevicePage.prefab +++ b/Assets/Res/ui/connectdevicepage/connectDevicePage.prefab @@ -1343,7 +1343,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -325} + m_AnchoredPosition: {x: 0, y: -355} m_SizeDelta: {x: -60, y: 100} m_Pivot: {x: 0.5, y: 1} --- !u!222 &7944886465916672701 @@ -1501,7 +1501,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -201} + m_AnchoredPosition: {x: 0, y: -231} m_SizeDelta: {x: -60, y: 100} m_Pivot: {x: 0.5, y: 1} --- !u!222 &721363789362909868 @@ -2835,6 +2835,99 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: textKey: 100077 +--- !u!1 &3316152303714664431 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4066361047121763592} + - component: {fileID: 7645982901015283803} + - component: {fileID: 8788364806159699153} + - component: {fileID: 5690301613137539711} + m_Layer: 5 + m_Name: tip + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &4066361047121763592 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3316152303714664431} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 4343486803298895729} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 30, y: -195} + m_SizeDelta: {x: 300, y: 30} + m_Pivot: {x: 0, y: 0.5} +--- !u!222 &7645982901015283803 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3316152303714664431} + m_CullTransparentMesh: 1 +--- !u!114 &8788364806159699153 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3316152303714664431} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.5411765, g: 0.54901963, b: 0.54509807, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 24 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 2 + m_MaxSize: 40 + m_Alignment: 6 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: "*\u4EC5\u652F\u6301 2.4GHz Wi\u2011Fi" +--- !u!114 &5690301613137539711 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3316152303714664431} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 89f1d49b50a31514787b4e268b1c73bb, type: 3} + m_Name: + m_EditorClassIdentifier: + textKey: 100320 --- !u!1 &3325804653976541888 GameObject: m_ObjectHideFlags: 0 @@ -5498,6 +5591,7 @@ RectTransform: - {fileID: 3732513664857003842} - {fileID: 7881411939462652630} - {fileID: 1518021257232439107} + - {fileID: 4066361047121763592} m_Father: {fileID: 8470092863222596142} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} diff --git a/Assets/Scripts/Bluetooth/BLECommunicationManager.cs b/Assets/Scripts/Bluetooth/BLECommunicationManager.cs index 3e0a774..6d78dc1 100644 --- a/Assets/Scripts/Bluetooth/BLECommunicationManager.cs +++ b/Assets/Scripts/Bluetooth/BLECommunicationManager.cs @@ -58,8 +58,8 @@ namespace Kill.Bluetooth public bool IsWaitingResponse { get; private set; } public byte LastCommand { get; private set; } - // 响应超时设置 (OTA传输需要更长时间,增加到10秒) - public float ResponseTimeout = 10f; + // 响应超时设置(普通指令3秒;OTA传输需要更长时间,由OTAManager临时延长到10秒) + public float ResponseTimeout = 3f; // 数据接收缓冲区 private List _receiveBuffer = new List(); diff --git a/Assets/Scripts/Bluetooth/OTAManager.cs b/Assets/Scripts/Bluetooth/OTAManager.cs index 6b7f815..9dfce79 100644 --- a/Assets/Scripts/Bluetooth/OTAManager.cs +++ b/Assets/Scripts/Bluetooth/OTAManager.cs @@ -387,55 +387,67 @@ namespace Kill.Bluetooth /// public IEnumerator PerformFullUpgrade(byte[] firmwareData, uint firmwareVersion, Action callback = null) { - // 0. 先取消可能存在的未完成升级 - bool cancelSuccess = false; - yield return CancelUpgradeCoroutine((success) => cancelSuccess = success); - if (cancelSuccess) + // OTA 分包传输需要更长的设备响应时间,临时延长超时,结束后恢复默认值 + var comm = BLECommunicationManager.Instance; + float originalTimeout = comm != null ? comm.ResponseTimeout : 10f; + if (comm != null) comm.ResponseTimeout = 10f; + try { - yield return new WaitForSeconds(1f); + // 0. 先取消可能存在的未完成升级 + bool cancelSuccess = false; + yield return CancelUpgradeCoroutine((success) => cancelSuccess = success); + if (cancelSuccess) + { + yield return new WaitForSeconds(1f); + } + + // 1. 查询版本信息 + OTAVersionInfo versionInfo = null; + yield return QueryVersionInfoCoroutine((info) => versionInfo = info); + + if (versionInfo == null) + { + callback?.Invoke(false); + yield break; + } + + // 2. 开始升级 + bool startSuccess = false; + yield return StartUpgradeCoroutine(firmwareData, firmwareVersion, (success) => startSuccess = success); + + if (!startSuccess) + { + callback?.Invoke(false); + yield break; + } + + // 3. 传输数据 + bool transferSuccess = false; + yield return TransferFirmware((success) => transferSuccess = success); + + if (!transferSuccess) + { + callback?.Invoke(false); + yield break; + } + + // 4. 结束传输 + bool endSuccess = false; + yield return EndTransferCoroutine((success) => endSuccess = success); + + if (!endSuccess) + { + callback?.Invoke(false); + yield break; + } + + callback?.Invoke(true); } - - // 1. 查询版本信息 - OTAVersionInfo versionInfo = null; - yield return QueryVersionInfoCoroutine((info) => versionInfo = info); - - if (versionInfo == null) + finally { - callback?.Invoke(false); - yield break; + // 恢复默认响应超时 + if (comm != null) comm.ResponseTimeout = originalTimeout; } - - // 2. 开始升级 - bool startSuccess = false; - yield return StartUpgradeCoroutine(firmwareData, firmwareVersion, (success) => startSuccess = success); - - if (!startSuccess) - { - callback?.Invoke(false); - yield break; - } - - // 3. 传输数据 - bool transferSuccess = false; - yield return TransferFirmware((success) => transferSuccess = success); - - if (!transferSuccess) - { - callback?.Invoke(false); - yield break; - } - - // 4. 结束传输 - bool endSuccess = false; - yield return EndTransferCoroutine((success) => endSuccess = success); - - if (!endSuccess) - { - callback?.Invoke(false); - yield break; - } - - callback?.Invoke(true); } #endregion diff --git a/Assets/Scripts/Managers/DataBase.cs b/Assets/Scripts/Managers/DataBase.cs index 0b191b6..3b791ff 100644 --- a/Assets/Scripts/Managers/DataBase.cs +++ b/Assets/Scripts/Managers/DataBase.cs @@ -125,6 +125,9 @@ namespace Kill.Managers { public string email; public string temp_token; + // 第三方登录未绑定场景:绑定同时设置密码(可选) + public string password; + public int password_type; } /// diff --git a/Assets/Scripts/UI/Pages/Login/LoginPageCtrl.cs b/Assets/Scripts/UI/Pages/Login/LoginPageCtrl.cs index 948aaf3..01b40bd 100644 --- a/Assets/Scripts/UI/Pages/Login/LoginPageCtrl.cs +++ b/Assets/Scripts/UI/Pages/Login/LoginPageCtrl.cs @@ -639,18 +639,13 @@ namespace Kill.UI.Pages onError: (code, message) => { Debug.Log(message); - // 未绑定过第三方帐号 → 使用第三方邮箱直接绑定登录,无需验证码 - BindFireBase("", - onSuccess: (data) => - { - Debug.Log(data.token); - UIManager.Instance.OpenPage(UIManager.PageName.homePage, null, true); - }, - onError: (bindCode, bindMessage) => - { - Debug.LogError($"第三方绑定失败: {bindMessage}"); - ToastUI.Show("100042"); // 登录失败提示 - }); + // 未绑定过第三方帐号 → 进入设置密码流程,绑定同时设置密码(无需验证码) + var setPasswordPanel = GetSubPage(SubPageType.SetPassword) as SetPasswordPanel; + if (setPasswordPanel != null) + { + setPasswordPanel.SetMode(SetPasswordPanel.SetPasswordMode.ThirdPartyBind); + } + ClearHistoryAndShow(SubPageType.SetPassword); }); } @@ -658,7 +653,7 @@ namespace Kill.UI.Pages #endregion #region 绑定第三方帐号 - public async Task BindFireBase(string code, Action onSuccess, Action onError) + public async Task BindFireBase(string code, Action onSuccess, Action onError, string password = null, int password_type = 0) { LoadingUI.Show(); var requestData = new BindFireBaseRequest @@ -666,6 +661,12 @@ namespace Kill.UI.Pages temp_token = currentFireBaseId, email = currentEmail }; + // 第三方登录未绑定场景:绑定同时设置密码 + if (!string.IsNullOrEmpty(password)) + { + requestData.password = password; + requestData.password_type = password_type; + } try { var response = await NetworkCtrl.Instance.Post("/api/v1/auth/firebase/bind", requestData); diff --git a/Assets/Scripts/UI/Pages/Login/SubPages/SetPasswordPanel.cs b/Assets/Scripts/UI/Pages/Login/SubPages/SetPasswordPanel.cs index 98c2751..5bd669e 100644 --- a/Assets/Scripts/UI/Pages/Login/SubPages/SetPasswordPanel.cs +++ b/Assets/Scripts/UI/Pages/Login/SubPages/SetPasswordPanel.cs @@ -48,7 +48,8 @@ namespace Kill.UI.Pages public enum SetPasswordMode { Register, // 注册设置密码 - ResetPassword // 忘记密码重置密码 + ResetPassword, // 忘记密码重置密码 + ThirdPartyBind // 第三方登录绑定设置密码 } protected override void OnInitialize() { @@ -258,6 +259,20 @@ namespace Kill.UI.Pages } ); } + else if (currentMode == SetPasswordMode.ThirdPartyBind) + { + // 第三方登录绑定模式 - 设置密码并绑定第三方账号,无需验证码 + LoginPageCtrl.Instance.BindFireBase("", + onSuccess: (data) => + { + UIManager.Instance.OpenPage(UIManager.PageName.homePage, null, true); + }, + onError: (code, msg) => + { + ToastUI.ShowText(code.ToString()); + }, + newPwd, passwordType); + } else { // 重置密码模式 - 调用重置密码接口