using AI.Platform.Core;
using Microsoft.JSInterop;

namespace AI.Platform.Web.Components.Pages.Account.Setting;

public partial class Setting
{
    private void SelectKey(MenuItem item)
    {
        TSelectKey = item.Key;
    }

    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();
    }

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            await NavigationManager.RedirectLogin(IJSRuntime);
            Global.CurrentUser = User.GetFirst(x => x.Id == Global.CurrentUser.Id);
        }
    }

    private readonly Dictionary<string, string> _menuMap = new Dictionary<string, string>
        {
            {"base", "基本设置"},
            //{"security", "安全设置"},
            {"binding", "账号绑定"},
            //{"notification", "消息提示"},
        };

    private string TSelectKey = "base";
    /// <summary>
    /// 
    /// </summary>
    [Inject] private SqlSugarRepository<SystemUser> User { get; set; }
    /// <summary>
    /// 
    /// </summary>
    [Inject] NavigationManager NavigationManager { get; set; }
    /// <summary>
    /// 
    /// </summary>
    [Inject] IJSRuntime IJSRuntime { get; set; }
}