diff --git a/src/blazor/admin/BootstrapAdmin.Web/Pages/Home/Index.cs b/src/blazor/admin/BootstrapAdmin.Web/Pages/Home/Index.cs
index fcb27fea..6a9307ed 100644
--- a/src/blazor/admin/BootstrapAdmin.Web/Pages/Home/Index.cs
+++ b/src/blazor/admin/BootstrapAdmin.Web/Pages/Home/Index.cs
@@ -6,15 +6,17 @@ using BootstrapAdmin.Web.Core;
using BootstrapAdmin.Web.Services;
using BootstrapAdmin.Web.Utils;
using Microsoft.AspNetCore.Authorization;
+using System.Reflection;
namespace BootstrapAdmin.Web.Pages.Home;
///
/// 返回前台页面
///
-[Route("/")]
-[Route("/Index")]
-[Route("/Home/Index")]
+[Route("")]
+[Route("Home")]
+[Route("Index")]
+[Route("Home/Index")]
[Authorize]
public class Index : ComponentBase
{
@@ -46,7 +48,7 @@ public class Index : ComponentBase
Url = LoginHelper.GetDefaultUrl(Context, null, null, UsersService, DictsService);
#if !DEBUG
- Navigation.NavigateTo(Url, true);
+ Redirect();
#endif
}
@@ -57,7 +59,17 @@ public class Index : ComponentBase
///
protected override void OnAfterRender(bool firstRender)
{
- Navigation.NavigateTo(Url, true);
+ Redirect();
}
#endif
+
+ private void Redirect()
+ {
+ var url = Navigation.ToBaseRelativePath(Navigation.Uri).TrimEnd('/');
+ var routes = GetType().GetCustomAttributes();
+ if (!routes.Any(i => i.Template.Equals(url, StringComparison.OrdinalIgnoreCase)))
+ {
+ Navigation.NavigateTo(Url, true);
+ }
+ }
}