.net-core - 如何更改 Blazor PWA 应用程序刷新时出现的 "Authorising..."消息?

标签 .net-core blazor progressive-web-apps

当使用浏览器刷新刷新 asp 网络托管的 BLAZOR 渐进式 Web 应用程序时,PWA 应用程序执行身份验证往返。在此时间跨度内,主要内容 div 显示文本:“Authorising...”。这个消息来自哪里?我的目标是与此消息一起显示微调边框,以便用户体验动画。这是我所知道的:

  • wwwroot 中的索引页面出现初始“正在加载...”消息。
  • 对于每个 AutherizeView,授权部分可用于显示自定义消息。

  • 但我无法找到默认“授权...”消息的来源。

    最佳答案

    有两个地方需要你的意图。
    首先是在您的 App.razor . AuthorizeRouteView有一个名为 Authorizing 的属性,您可以在其中添加任何 RenderFragement您想在授权期间显示。 HereAuthorizing...所在的行设置。

    <CascadingAuthenticationState>
        <Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true">
            <Found Context="routeData">
                <AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
                    <Authorizing>
                        <span>Your spinner goes here</span>
                    </Authorizing>
                    <NotAuthorized>
                        @if (!context.User.Identity.IsAuthenticated)
                        {
                            <RedirectToLogin />
                        }
                        else
                        {
                            <p>You are not authorized to access this resource.</p>
                        }
                    </NotAuthorized>
                </AuthorizeRouteView>
            </Found>
            <NotFound>
                <LayoutView Layout="@typeof(MainLayout)">
                    <p>Sorry, there's nothing at this address.</p>
                </LayoutView>
            </NotFound>
        </Router>
    </CascadingAuthenticationState>
    
    
    如果您使用默认模板创建了应用程序,您应该会看到 AuthenticationPage .本页有路线@page "/authentication/{action}" .
    此页面内容看起来像
    @page "/authentication/{action}"
    @using Microsoft.AspNetCore.Components.WebAssembly.Authentication
    <RemoteAuthenticatorView Action="@Action" />
    
    @code{
        [Parameter] public string Action { get; set; }
    }
    
    您可以通过添加相应的 RenderFragments 来更改整个模板。可以找到 here
    这是一个示例,其中每个片段都有一个非默认值
    @page "/authentication/{action}"
    @using Microsoft.AspNetCore.Components.WebAssembly.Authentication
    <RemoteAuthenticatorView Action="@Action">
        <LoggingIn>
            <span>LoggingIn</span>
        </LoggingIn>
        <Registering>
            <span>Registering</span>
        </Registering>
        <Registering>
            <span>LoggingIn</span>
        </Registering>
        <UserProfile>
            <span>UserProfile is loaded....</span>
        </UserProfile>
        <CompletingLoggingIn>
            <span>CompletingLoggingIn</span>
        </CompletingLoggingIn>
        <LogInFailed>
            <span>Login failed. Reason: @context</span>
        </LogInFailed>
        <LogOut>
            <span>Logout from the application</span>
        </LogOut>
        <LogOut>
            <span>CompletingLogOut</span>
        </LogOut>
        <LogOutFailed>
            <span>Logout failed. Reason: @context</span>
        </LogOutFailed>
        <LogOut>
            <span>LogOutSucceeded</span>
        </LogOut>
    </RemoteAuthenticatorView>
    
    @code{
        [Parameter] public string Action { get; set; }
    }
    

    关于.net-core - 如何更改 Blazor PWA 应用程序刷新时出现的 "Authorising..."消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66310829/

    相关文章:

    .net-core - ef-core 添加迁移不起作用

    .net - 在 Teamcity 上构建混合解决方案(.NET Framework 和 .NET Core)时找不到包

    .net-core - 在类库中创建UserManager

    c# - 如何为 blazor 应用程序以像素为单位查找 svg 文本大小?

    c# - 如何在Blazor中实现路由动画?

    oauth - Google 登录 JavaScript 客户端无法在 PWA 应用程序上运行

    linux - Linux 下带 dotnet 核心的 LDAP

    flurl - Blazor 0.6.0 "wipes"Flurl 兼容性?

    Angular 9 PWA 哈希不匹配(cacheBustedFetchFromNetwork)

    safari - Angular 6 应用程序在 safari 浏览器中不起作用