killapp/Assets/Scripts/UI/Pages/HomePage/CheckPasswordPage.cs
“虞渠成” 36e8055c26 feat: 添加自动锁定功能与配置页面
1.  新增自动锁定相关数据存储与逻辑,支持配置锁定间隔
2.  添加个人页安全设置入口与自动锁定设置页面
3.  重构主页自动锁定检测逻辑,替换原有临时计时变量
4.  更新多语言文案与项目版本号
2026-09-17 08:41:18 +08:00

74 lines
2.4 KiB
C#
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.

using System.Collections;
using System.Collections.Generic;
using Kill.Managers;
using Kill.Network;
using Kill.UI.Components;
using UnityEngine;
using UnityEngine.UI;
namespace Kill.UI.Pages
{
public class CheckPasswordPage : MonoBehaviour
{
class PasswordRequest
{
public string password;
}
public InputField passwordInput;
public Text errorText;
public GameObject plane;
public void OnEnable()
{
errorText.text="";
}
public async void OnConfirm()
{
errorText.text="";
LoadingUI.Show();
try
{
string password = passwordInput != null ? passwordInput.text : "";
if (string.IsNullOrEmpty(password))
{
errorText.text = LanguageManager.Instance.GetLanguage("home_password_check_failed");
return;
}
PasswordRequest requestData=new PasswordRequest
{
password=passwordInput.text
};
var response = await NetworkCtrl.Instance.Post<LoginResponse>("/api/v1/auth/password/verify", requestData);
if (response != null && response.Data != null && response.Data.code == 200)
{
plane.SetActive(false);
gameObject.SetActive(false);
errorText.text="";
passwordInput.text="";
UIManager.Instance.isFirstTime=false;
// 解锁成功,记录解锁时间(自动锁定倒计时起点)
DataManager.Instance.RecordUnlock();
}
else
{
errorText.text = LanguageManager.Instance.GetLanguage("home_password_check_failed");
passwordInput.text="";
}
}
catch (System.Exception ex)
{
Debug.LogError($"[CheckPasswordPage] 校验密码异常: {ex.Message}");
errorText.text = LanguageManager.Instance.GetLanguage("home_password_check_failed");
if (passwordInput != null) passwordInput.text = "";
}
finally
{
// 无论成功/失败/异常都关闭 Loading避免一直挂着
LoadingUI.Hide();
}
}
}
}