該賞金過期5天。這個問題的答案有資格獲得 50聲望獎勵。 Krzysztof Krysztofczyk正在尋找這個問題的更詳細的答案:
最受歡迎的解決方案是在帳戶管理 (/Identity/Account/Manage) 頁面中使用現有的 blazor 導航欄 (Shared/NavMenu.razor)。當然,也歡迎任何其他允許一致 UI 的解決方案。可以作為示例的專案代碼可以在GitHub上找到(它只是VS生成的標準專案)github.com/kkrysztofczyk/BlazorAuthTemplate.git
在 UI 方面,默認 Blazor 專案非常不一致。對于 blazor 組件,有一個 sidenav。但是對于帳戶管理 /Identity/Account/Manage 沒有 sidenav,因為那是 .cshtml 而不是 .razor 頁面。我知道要擁有一致的用戶界面,我可能必須有兩個側面導航并為它們保持完全相同的布局。不過,也許已經有一些用于 /Identity/Account/Manage 的 sidenav 示例,看起來與可用于 blazor 組件的完全相同?
最受歡迎的解決方案是在帳戶管理 (/Identity/Account/Manage) 頁面中使用現有的 blazor 導航欄 (Shared/NavMenu.razor)
uj5u.com熱心網友回復:
我在 GitHub 上針對您的示例創建了 PR。更改是針對 Identity 使用的 _Layout.cshtml - 它并不完美,但顯示了該技術。
_Layout.cshtml
@using Microsoft.AspNetCore.Hosting
@using Microsoft.AspNetCore.Mvc.ViewEngines
@inject IWebHostEnvironment Environment
@inject ICompositeViewEngine Engine
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - BlazorAuthTemplate</title>
<base href="~/" />
<link rel="stylesheet" href="~/Identity/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/Identity/css/site.css" />
<link href="css/site.css" rel="stylesheet" />
</head>
<body>
<app>
<div class="sidebar">
<component type="typeof(BlazorAuthTemplate.Shared.NavMenu)" render-mode="ServerPrerendered" />
</div>
<div class="main">
<div class="top-row px-4 auth">
<div class="d-sm-inline-flex flex-sm-row-reverse">
@{
var result = Engine.FindView(ViewContext, "_LoginPartial", isMainPage: false);
}
@if (result.Success)
{
await Html.RenderPartialAsync("_LoginPartial");
}
else
{
throw new InvalidOperationException("The default Identity UI layout requires a partial view '_LoginPartial' "
"usually located at '/Pages/_LoginPartial' or at '/Views/Shared/_LoginPartial' to work. Based on your configuration "
$"we have looked at it in the following locations: {System.Environment.NewLine}{string.Join(System.Environment.NewLine, result.SearchedLocations)}.");
}
</div>
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
</div>
<main role="main" class="content px-4 pb-3">
@RenderBody()
</main>
</div>
</app>
<script src="~/Identity/lib/jquery/dist/jquery.min.js"></script>
<script src="~/Identity/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/Identity/js/site.js" asp-append-version="true"></script>
@RenderSection("Scripts", required: false)
<script src="/_framework/blazor.server.js"></script>
</body>
</html>
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/312905.html
