fix: 修复首页一直跳转问题
This commit is contained in:
parent
5c7b29ee04
commit
7465b7f890
|
@ -6,15 +6,17 @@ using BootstrapAdmin.Web.Core;
|
||||||
using BootstrapAdmin.Web.Services;
|
using BootstrapAdmin.Web.Services;
|
||||||
using BootstrapAdmin.Web.Utils;
|
using BootstrapAdmin.Web.Utils;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace BootstrapAdmin.Web.Pages.Home;
|
namespace BootstrapAdmin.Web.Pages.Home;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 返回前台页面
|
/// 返回前台页面
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("/")]
|
[Route("")]
|
||||||
[Route("/Index")]
|
[Route("Home")]
|
||||||
[Route("/Home/Index")]
|
[Route("Index")]
|
||||||
|
[Route("Home/Index")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class Index : ComponentBase
|
public class Index : ComponentBase
|
||||||
{
|
{
|
||||||
|
@ -46,7 +48,7 @@ public class Index : ComponentBase
|
||||||
Url = LoginHelper.GetDefaultUrl(Context, null, null, UsersService, DictsService);
|
Url = LoginHelper.GetDefaultUrl(Context, null, null, UsersService, DictsService);
|
||||||
|
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
Navigation.NavigateTo(Url, true);
|
Redirect();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +59,17 @@ public class Index : ComponentBase
|
||||||
/// <param name="firstRender"></param>
|
/// <param name="firstRender"></param>
|
||||||
protected override void OnAfterRender(bool firstRender)
|
protected override void OnAfterRender(bool firstRender)
|
||||||
{
|
{
|
||||||
Navigation.NavigateTo(Url, true);
|
Redirect();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
private void Redirect()
|
||||||
|
{
|
||||||
|
var url = Navigation.ToBaseRelativePath(Navigation.Uri).TrimEnd('/');
|
||||||
|
var routes = GetType().GetCustomAttributes<RouteAttribute>();
|
||||||
|
if (!routes.Any(i => i.Template.Equals(url, StringComparison.OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
|
Navigation.NavigateTo(Url, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue