mirror of https://github.com/abpframework/abp.git
4 changed files with 62 additions and 83 deletions
@ -1,41 +0,0 @@ |
|||||
@page "/" |
|
||||
@namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Pages |
|
||||
@using System.Globalization |
|
||||
@using Volo.Abp.AspNetCore.Components.Web.LeptonXLiteTheme.Themes.LeptonXLite |
|
||||
@using Volo.Abp.AspNetCore.Components.Server.LeptonXLiteTheme.Bundling |
|
||||
@using Volo.Abp.Localization |
|
||||
@using Microsoft.AspNetCore.Components.Web |
|
||||
@{ |
|
||||
Layout = null; |
|
||||
var rtl = CultureHelper.IsRtl ? "rtl" : string.Empty; |
|
||||
} |
|
||||
|
|
||||
<!DOCTYPE html> |
|
||||
<html lang="@CultureInfo.CurrentCulture.Name" dir="@rtl"> |
|
||||
<head> |
|
||||
<meta charset="utf-8" /> |
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
|
||||
<title>MyCompanyName.MyProjectName.Blazor.Server</title> |
|
||||
<base href="~/" /> |
|
||||
|
|
||||
<abp-style-bundle name="@BlazorLeptonXLiteThemeBundles.Styles.Global"/> |
|
||||
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" /> |
|
||||
</head> |
|
||||
<body class="abp-application-layout bg-light @rtl"> |
|
||||
|
|
||||
<component type="typeof(App)" render-mode="Server" /> |
|
||||
|
|
||||
<div id="blazor-error-ui"> |
|
||||
<environment include="Staging,Production"> |
|
||||
An error has occurred. This application may no longer respond until reloaded. |
|
||||
</environment> |
|
||||
<environment include="Development"> |
|
||||
An unhandled exception has occurred. See browser dev tools for details. |
|
||||
</environment> |
|
||||
<a href="" class="reload">Reload</a> |
|
||||
<a class="dismiss">🗙</a> |
|
||||
</div> |
|
||||
|
|
||||
<abp-script-bundle name="@BlazorLeptonXLiteThemeBundles.Scripts.Global" /> |
|
||||
</body> |
|
||||
</html> |
|
||||
@ -0,0 +1,61 @@ |
|||||
|
@page "/books" |
||||
|
|
||||
|
@using Volo.Abp.MultiTenancy |
||||
|
@inject PersistentComponentState ApplicationState |
||||
|
@inject ICurrentTenant CurrentTenant |
||||
|
|
||||
|
<p role="status">Current count: @currentCount</p> |
||||
|
|
||||
|
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button> |
||||
|
|
||||
|
<p>Hello by @Token</p> |
||||
|
|
||||
|
@code { |
||||
|
|
||||
|
private int currentCount; |
||||
|
|
||||
|
private string? Token { get; set; } = default!; |
||||
|
|
||||
|
|
||||
|
protected override async Task OnInitializedAsync() |
||||
|
{ |
||||
|
ApplicationState.RegisterOnPersisting(OnPersistingAsync, RenderMode.InteractiveServer); |
||||
|
ApplicationState.RegisterOnPersisting(PersistCount); |
||||
|
|
||||
|
if (ApplicationState.TryTakeFromJson<string> ("name", out var restored)) |
||||
|
{ |
||||
|
Token = $"Token is restored: {restored}"; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
Token = "Token is not restored"; |
||||
|
} |
||||
|
|
||||
|
if (!ApplicationState.TryTakeFromJson<int>(nameof(currentCount), out var restoredCount)) |
||||
|
{ |
||||
|
currentCount = Random.Shared.Next(100); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
currentCount = restoredCount!; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private Task PersistCount() |
||||
|
{ |
||||
|
ApplicationState.PersistAsJson(nameof(currentCount), currentCount); |
||||
|
|
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
private void IncrementCount() => currentCount++; |
||||
|
|
||||
|
async Task OnPersistingAsync() |
||||
|
{ |
||||
|
ApplicationState.PersistAsJson("name", "hemant"); |
||||
|
|
||||
|
await Task.CompletedTask; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -1,41 +0,0 @@ |
|||||
@page "/" |
|
||||
@namespace MyCompanyName.MyProjectName.Blazor.Server.Pages |
|
||||
@using System.Globalization |
|
||||
@using Volo.Abp.AspNetCore.Components.Web.LeptonXLiteTheme.Themes.LeptonXLite |
|
||||
@using Volo.Abp.AspNetCore.Components.Server.LeptonXLiteTheme.Bundling |
|
||||
@using Volo.Abp.Localization |
|
||||
@using Microsoft.AspNetCore.Components.Web |
|
||||
@{ |
|
||||
Layout = null; |
|
||||
var rtl = CultureHelper.IsRtl ? "rtl" : string.Empty; |
|
||||
} |
|
||||
|
|
||||
<!DOCTYPE html> |
|
||||
<html lang="@CultureInfo.CurrentCulture.Name" dir="@rtl"> |
|
||||
<head> |
|
||||
<meta charset="utf-8" /> |
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
|
||||
<title>MyCompanyName.MyProjectName.Blazor.Server</title> |
|
||||
<base href="~/" /> |
|
||||
|
|
||||
<abp-style-bundle name="@BlazorLeptonXLiteThemeBundles.Styles.Global" /> |
|
||||
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" /> |
|
||||
</head> |
|
||||
<body class="abp-application-layout bg-light @rtl"> |
|
||||
|
|
||||
<component type="typeof(App)" render-mode="Server" /> |
|
||||
|
|
||||
<div id="blazor-error-ui"> |
|
||||
<environment include="Staging,Production"> |
|
||||
An error has occurred. This application may no longer respond until reloaded. |
|
||||
</environment> |
|
||||
<environment include="Development"> |
|
||||
An unhandled exception has occurred. See browser dev tools for details. |
|
||||
</environment> |
|
||||
<a href="" class="reload">Reload</a> |
|
||||
<a class="dismiss">🗙</a> |
|
||||
</div> |
|
||||
|
|
||||
<abp-script-bundle name="@BlazorLeptonXLiteThemeBundles.Scripts.Global" /> |
|
||||
</body> |
|
||||
</html> |
|
||||
Loading…
Reference in new issue