diff --git a/README.md b/README.md index 4a9024f..8a8a1e8 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,13 @@ # Lsw.Abp.AntDesignUI - + +## Still in progress! + +An Abp Blazor Theme based [Ant-Design-Blazor](https://github.com/ant-design-blazor/ant-design-blazor) + +![left1](img/left1.png) + +![left2](img/left2.png) + +![top1](img/top1.png) + +![top2](img/top2.png) \ No newline at end of file diff --git a/img/left1.png b/img/left1.png new file mode 100644 index 0000000..6d006a3 Binary files /dev/null and b/img/left1.png differ diff --git a/img/left2.png b/img/left2.png new file mode 100644 index 0000000..1d0b716 Binary files /dev/null and b/img/left2.png differ diff --git a/img/top1.png b/img/top1.png new file mode 100644 index 0000000..0f82b45 Binary files /dev/null and b/img/top1.png differ diff --git a/img/top2.png b/img/top2.png new file mode 100644 index 0000000..b672b70 Binary files /dev/null and b/img/top2.png differ diff --git a/modules/Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme/Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme.csproj b/modules/Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme/Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme.csproj index 7d86637..622c311 100644 --- a/modules/Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme/Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme.csproj +++ b/modules/Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme/Lsw.Abp.AspnetCore.Components.Server.AntDesignTheme.csproj @@ -17,7 +17,7 @@ - + diff --git a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/AbpAntDesignThemeOptions.cs b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/AbpAntDesignThemeOptions.cs index 038c16f..8c1559b 100644 --- a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/AbpAntDesignThemeOptions.cs +++ b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/AbpAntDesignThemeOptions.cs @@ -21,7 +21,7 @@ public class MenuOptions public MenuOptions() { Theme = MenuTheme.Light; - Place = MenuPlace.Top; + Place = MenuPlace.Left; } public MenuMode GetMode() diff --git a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Layout/AbpPageHeader.razor b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Layout/AbpPageHeader.razor index f31a461..772305c 100644 --- a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Layout/AbpPageHeader.razor +++ b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Layout/AbpPageHeader.razor @@ -1,50 +1,50 @@ @using Microsoft.Extensions.Options @inject IOptions Options - - - @if (Options.Value.RenderPageTitle) - { - @PageLayout.Title - } - - @if (Options.Value.RenderBreadcrumbs && PageLayout.BreadcrumbItems.Any()) - { - @if (BreadcrumbShowHome) + + + + @if (Options.Value.RenderBreadcrumbs && PageLayout.BreadcrumbItems.Any()) { - - - - } - @foreach (var item in PageLayout.BreadcrumbItems) - { - - @if (!item.Icon.IsNullOrWhiteSpace()) - { - - } - @item.Text - + @if (BreadcrumbShowHome) + { + + + + } + @foreach (var item in PageLayout.BreadcrumbItems) + { + + @if (!item.Icon.IsNullOrWhiteSpace()) + { + + } + @item.Text + + } } - } - - - @if (Options.Value.RenderToolbar) - { -
+ + + + + @if (Options.Value.RenderToolbar) + { @if (Toolbar == null) { @ChildContent } - @foreach (var toolbarItemRender in ToolbarItemRenders) { -
+
@toolbarItemRender
} -
- } + } +
+@if (Options.Value.RenderPageTitle) +{ +
@PageLayout.Title
+} diff --git a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Layout/PageLayout.cs b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Layout/PageLayout.cs index 4f0a0ff..5a6cfcb 100644 --- a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Layout/PageLayout.cs +++ b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Layout/PageLayout.cs @@ -8,15 +8,15 @@ namespace Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Layout; public class PageLayout : IScopedDependency, INotifyPropertyChanged { - private string title; + private string _title; // TODO: Consider using this property for setting Page Title too. public virtual string Title { - get => title; + get => _title; set { - title = value; + _title = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Title))); } } diff --git a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/Branding.razor b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/Branding.razor index 4baf819..2af5849 100644 --- a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/Branding.razor +++ b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/Branding.razor @@ -1,10 +1,15 @@ @using Volo.Abp.Ui.Branding @inject IBrandingProvider BrandingProvider + - - @if (!BrandingProvider.LogoUrl.IsNullOrWhiteSpace()) - { - @BrandingProvider.AppName - } - @BrandingProvider.AppName - diff --git a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/Branding.razor.cs b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/Branding.razor.cs new file mode 100644 index 0000000..4b4675d --- /dev/null +++ b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/Branding.razor.cs @@ -0,0 +1,9 @@ +using Microsoft.AspNetCore.Components; + +namespace Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Themes.AntDesignTheme; + +public partial class Branding +{ + [Parameter] + public bool Collapsed { get; set; } +} diff --git a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/DefaultLayout.razor b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/DefaultLayout.razor index ba84a2f..6efa5cd 100644 --- a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/DefaultLayout.razor +++ b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/DefaultLayout.razor @@ -2,45 +2,69 @@ @using Microsoft.Extensions.Options @inject IOptions Options +@{ + var sideTheme = Options.Value.Menu.Theme == MenuTheme.Light ? SiderTheme.Light : SiderTheme.Dark; + var light = Options.Value.Menu.Theme == MenuTheme.Light; +} + @if (Options.Value.Menu.Place == MenuOptions.MenuPlace.Top) { + var headerTopClass = light ? "ant-design-header-top ant-design-header-top-light" : "ant-design-header-top"; -
+
- + + + + +
- @Body +
+ @Body +
-
Footer
+
} else { + var headerLeftClass = light ? "ant-design-header-left ant-design-header-left-light" : "ant-design-header-left"; - - + + -
- @if (Collapsed) - { - - } - else - { - - } +
+
+ @if (Collapsed) + { + + } + else + { + + } +
+ + + + +
- @Body +
+ @Body +
diff --git a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/MainMenu.razor b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/MainMenu.razor index 25e58bc..ddc4552 100644 --- a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/MainMenu.razor +++ b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/MainMenu.razor @@ -1,4 +1,4 @@ - + @if (Menu != null) { foreach (var menu in Menu.Items) diff --git a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/MainMenu.razor.cs b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/MainMenu.razor.cs index 5506e88..34c1933 100644 --- a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/MainMenu.razor.cs +++ b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/MainMenu.razor.cs @@ -19,6 +19,9 @@ public partial class MainMenu : IDisposable [Inject] protected AuthenticationStateProvider AuthenticationStateProvider { get; set; } + + [Parameter] + public bool Collapsed { get; set; } protected override async Task OnInitializedAsync() { diff --git a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/MainMenuItem.razor b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/MainMenuItem.razor index 102102b..1d8fa5a 100644 --- a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/MainMenuItem.razor +++ b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/MainMenuItem.razor @@ -7,17 +7,17 @@ if (Menu.IsLeaf && Menu.Url != null) { - + @if (Menu.Icon != null) { } - @Menu.Name + @Menu.Name } else { - + @foreach (var menuItem in Menu.Items) { diff --git a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/NavToolbar.razor b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/NavToolbar.razor new file mode 100644 index 0000000..ffabc44 --- /dev/null +++ b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/NavToolbar.razor @@ -0,0 +1,4 @@ +@foreach (var render in ToolbarItemRenders) +{ + @render +} diff --git a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/NavToolbar.razor.cs b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/NavToolbar.razor.cs new file mode 100644 index 0000000..4407dce --- /dev/null +++ b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/NavToolbar.razor.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Toolbars; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Authorization; + +namespace Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Themes.AntDesignTheme; + +public partial class NavToolbar: IDisposable +{ + [Inject] + private IToolbarManager ToolbarManager { get; set; } + + [Inject] + private AuthenticationStateProvider AuthenticationStateProvider { get; set; } + + private List ToolbarItemRenders { get; set; } = new(); + + protected override async Task OnInitializedAsync() + { + await GetToolbarItemRendersAsync(); + AuthenticationStateProvider.AuthenticationStateChanged += AuthenticationStateProviderOnAuthenticationStateChanged; + } + + private async Task GetToolbarItemRendersAsync() + { + var toolbar = await ToolbarManager.GetAsync(StandardToolbars.Main); + + ToolbarItemRenders.Clear(); + + var sequence = 0; + foreach (var item in toolbar.Items) + { + ToolbarItemRenders.Add(builder => + { + builder.OpenComponent(sequence++, item.ComponentType); + builder.CloseComponent(); + }); + } + } + + private async void AuthenticationStateProviderOnAuthenticationStateChanged(Task task) + { + await GetToolbarItemRendersAsync(); + await InvokeAsync(StateHasChanged); + } + + public void Dispose() + { + AuthenticationStateProvider.AuthenticationStateChanged -= AuthenticationStateProviderOnAuthenticationStateChanged; + } +} diff --git a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/wwwroot/libs/abp/css/theme.css b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/wwwroot/libs/abp/css/theme.css index 4ff87c6..1d1017a 100644 --- a/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/wwwroot/libs/abp/css/theme.css +++ b/modules/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/wwwroot/libs/abp/css/theme.css @@ -6,9 +6,120 @@ body, app { height: 100%; } + .colorWeak { filter: invert(80%); } + .ant-layout { min-height: 100vh; } + +.ant-design-header-top { + background-color: #001529; +} + +.ant-design-header-top-light { + background-color: #fff; +} + +.ant-design-header-left { + background-color: white; + box-shadow: 0 1px 4px rgb(0 21 41 / 8%) +} + +.ant-design-header-left-light { + background-color: #001529; +} + +.ant-design-body-content { + margin: 16px 50px; +} + +.ant-design-footer { + text-align: center; +} + +.page-content { + min-height: 80vh; + background: #fff; + padding: 24px; + margin-top: 8px; +} + +.ant-design-page-title { + font-size: 20px; + font-weight: 600; + margin-top: 8px; +} + +.ant-design-header-left .trigger { + font-size: 18px; + line-height: 64px; + cursor: pointer; + transition: color 0.3s; +} + +.ant-design-header-left .trigger:hover { + color: #1890ff; +} + +.ant-design-header-left-light .trigger { + color: white; +} + +.ant-design-side .ant-design-brand { + font-size: 15px; + font-weight: 600; + display: flex; + padding: 16px 16px; + cursor: pointer; +} + +.ant-design-side .ant-design-brand img { + display: inline-block; + height: 35px +} + +.ant-design-side .ant-design-brand h1 { + display: inline-block; + color: white; + margin: 0 0 0 12px; +} + +.ant-layout-sider-light .ant-design-brand h1 { + color: #001529; +} + +.ant-design-header-top .ant-design-brand img { + display: inline-block; + height: 35px +} + +.ant-design-header-top .ant-design-brand { + position: relative; + float: left; + min-width: 170px; +} + +.ant-design-header-top .ant-design-brand h1 { + display: inline-block; + color: white; + margin: 0 0 0 12px; + font-weight: 400; + font-size: 15px; + vertical-align: top; +} + +.ant-design-header-top-light .ant-design-brand h1 { + color: #001529; +} + +.ant-design-header-top .ant-menu-root{ + margin-left: 20px; + float: left; +} + +.abp-application-layout .ant-menu-sub li{ + min-width: 120px; +} diff --git a/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/AbpAspNetCoreComponentsWebAssemblyAntDesignThemeModule.cs b/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/AbpAspNetCoreComponentsWebAssemblyAntDesignThemeModule.cs index f34b51c..fd31b3f 100644 --- a/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/AbpAspNetCoreComponentsWebAssemblyAntDesignThemeModule.cs +++ b/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/AbpAspNetCoreComponentsWebAssemblyAntDesignThemeModule.cs @@ -1,4 +1,6 @@ using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme; +using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Routing; +using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Toolbars; using Volo.Abp.AspNetCore.Components.WebAssembly; using Volo.Abp.Modularity; @@ -10,5 +12,16 @@ namespace Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme; )] public class AbpAspNetCoreComponentsWebAssemblyAntDesignThemeModule : AbpModule { - + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.AdditionalAssemblies.Add(typeof(AbpAspNetCoreComponentsWebAssemblyAntDesignThemeModule).Assembly); + }); + + Configure(options => + { + options.Contributors.Add(new AntDesignThemeToolbarContributor()); + }); + } } diff --git a/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/AntDesignThemeToolbarContributor.cs b/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/AntDesignThemeToolbarContributor.cs new file mode 100644 index 0000000..3891372 --- /dev/null +++ b/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/AntDesignThemeToolbarContributor.cs @@ -0,0 +1,28 @@ +using System.Threading.Tasks; +using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Toolbars; +using Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme.Themes.AntDesignTheme; +using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.Extensions.DependencyInjection; + +namespace Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme; + +public class AntDesignThemeToolbarContributor: IToolbarContributor +{ + public Task ConfigureToolbarAsync(IToolbarConfigurationContext context) + { + if (context.Toolbar.Name == StandardToolbars.Main) + { + context.Toolbar.Items.Add(new ToolbarItem(typeof(LanguageSwitch))); + + var authenticationStateProvider = context.ServiceProvider + .GetRequiredService(); + + if (authenticationStateProvider != null) + { + context.Toolbar.Items.Add(new ToolbarItem(typeof(LoginDisplay))); + } + } + + return Task.CompletedTask; + } +} diff --git a/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/ComponentsComponentsBundleContributor.cs b/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/ComponentsComponentsBundleContributor.cs index 626474c..fa39885 100644 --- a/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/ComponentsComponentsBundleContributor.cs +++ b/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/ComponentsComponentsBundleContributor.cs @@ -6,7 +6,7 @@ public class ComponentsComponentsBundleContributor : IBundleContributor { public void AddScripts(BundleContext context) { - //context.Add("_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"); + context.Add("_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"); context.Add("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/abp.js"); context.Add("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/lang-utils.js"); context.Add("_content/AntDesign/js/ant-design-blazor.js"); diff --git a/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme.csproj b/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme.csproj index 87781df..6362563 100644 --- a/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme.csproj +++ b/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme.csproj @@ -1,20 +1,21 @@ - + net6.0 - + - - - - + + + + + diff --git a/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Pages/Authentication.razor b/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Pages/Authentication.razor new file mode 100644 index 0000000..e237cea --- /dev/null +++ b/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Pages/Authentication.razor @@ -0,0 +1,7 @@ +@page "/authentication/{action}" +@using Microsoft.AspNetCore.Components.WebAssembly.Authentication + + +@code{ + [Parameter] public string Action { get; set; } +} diff --git a/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Themes/AntDesignTheme/LanguageSwitch.razor b/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Themes/AntDesignTheme/LanguageSwitch.razor new file mode 100644 index 0000000..a9a5aeb --- /dev/null +++ b/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Themes/AntDesignTheme/LanguageSwitch.razor @@ -0,0 +1,79 @@ +@using Volo.Abp.Localization +@using System.Collections.Immutable +@using System.Globalization +@using Microsoft.JSInterop +@inject ILanguageProvider LanguageProvider +@inject IJSRuntime JsRuntime + +@if (_otherLanguages != null && _otherLanguages.Any()) +{ + + + + @foreach (var language in _otherLanguages) + { + + @language.DisplayName + + } + + + + + @_currentLanguage.DisplayName + + + +} + +@code { + private IReadOnlyList _otherLanguages; + private LanguageInfo _currentLanguage; + + protected override async Task OnInitializedAsync() + { + var selectedLanguageName = await JsRuntime.InvokeAsync( + "localStorage.getItem", + "Abp.SelectedLanguage" + ); + + _otherLanguages = await LanguageProvider.GetLanguagesAsync(); + + if (!_otherLanguages.Any()) + { + return; + } + + if (!selectedLanguageName.IsNullOrWhiteSpace()) + { + _currentLanguage = _otherLanguages.FirstOrDefault(l => l.UiCultureName == selectedLanguageName); + } + + if (_currentLanguage == null) + { + _currentLanguage = _otherLanguages.FirstOrDefault(l => l.UiCultureName == CultureInfo.CurrentUICulture.Name); + } + + if (_currentLanguage == null) + { + _currentLanguage = _otherLanguages.FirstOrDefault(); + } + + _otherLanguages = _otherLanguages.Where(l => l != _currentLanguage).ToImmutableList(); + } + + protected virtual async Task ChangeLanguageAsync(LanguageInfo language) + { + await JsRuntime.InvokeVoidAsync( + "localStorage.setItem", + "Abp.SelectedLanguage", language.UiCultureName + ); + + await JsRuntime.InvokeVoidAsync( + "localStorage.setItem", + "Abp.IsRtl", CultureInfo.GetCultureInfo(language.UiCultureName).TextInfo.IsRightToLeft + ); + + await JsRuntime.InvokeVoidAsync("location.reload"); + } +} diff --git a/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Themes/AntDesignTheme/LoginDisplay.razor b/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Themes/AntDesignTheme/LoginDisplay.razor new file mode 100644 index 0000000..6d7d865 --- /dev/null +++ b/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Themes/AntDesignTheme/LoginDisplay.razor @@ -0,0 +1,46 @@ +@using global::Localization.Resources.AbpUi +@using Microsoft.Extensions.Localization +@* @using Microsoft.AspNetCore.Components.Authorization *@ +@using Microsoft.JSInterop +@inherits Volo.Abp.AspNetCore.Components.AbpComponentBase +@inject IJSRuntime JsRuntime +@inject NavigationManager Navigation +@inject IStringLocalizer UiLocalizer + + + + + + + @if (Menu != null) + { + @foreach (var menuItem in Menu.Items) + { + + @menuItem.DisplayName + + } + } + + + @UiLocalizer["Logout"] + + + + + @* @if (CurrentTenant.Name != null) *@ + @* { *@ + @* @CurrentTenant.Name\@CurrentUser.UserName *@ + @* } *@ + @* else *@ + @* { *@ + @* @CurrentUser.UserName *@ + @* } *@ + @* *@ + + + + + @UiLocalizer["Login"] + + diff --git a/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Themes/AntDesignTheme/LoginDisplay.razor.cs b/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Themes/AntDesignTheme/LoginDisplay.razor.cs new file mode 100644 index 0000000..e1e6487 --- /dev/null +++ b/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Themes/AntDesignTheme/LoginDisplay.razor.cs @@ -0,0 +1,76 @@ +using System; +using System.Threading.Tasks; +using JetBrains.Annotations; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.AspNetCore.Components.Routing; +using Microsoft.AspNetCore.Components.WebAssembly.Authentication; +using Microsoft.JSInterop; +using Volo.Abp.UI.Navigation; + +namespace Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme.Themes.AntDesignTheme; + +public partial class LoginDisplay : IDisposable +{ + [Inject] + protected IMenuManager MenuManager { get; set; } + + [Inject] + public AuthenticationStateProvider AuthenticationStateProvider { get; set; } + + [CanBeNull] + protected SignOutSessionStateManager SignOutManager; + + protected ApplicationMenu Menu { get; set; } + + protected override async Task OnInitializedAsync() + { + Menu = await MenuManager.GetAsync(StandardMenus.User); + + Navigation.LocationChanged += OnLocationChanged; + + LazyGetService(ref SignOutManager); + + AuthenticationStateProvider.AuthenticationStateChanged += + AuthenticationStateProviderOnAuthenticationStateChanged; + } + + protected virtual void OnLocationChanged(object sender, LocationChangedEventArgs e) + { + InvokeAsync(StateHasChanged); + } + + private async void AuthenticationStateProviderOnAuthenticationStateChanged(Task task) + { + Menu = await MenuManager.GetAsync(StandardMenus.User); + await InvokeAsync(StateHasChanged); + } + + public void Dispose() + { + Navigation.LocationChanged -= OnLocationChanged; + AuthenticationStateProvider.AuthenticationStateChanged -= + AuthenticationStateProviderOnAuthenticationStateChanged; + } + + private async Task NavigateToAsync(string uri, string target = null) + { + if (target == "_blank") + { + await JsRuntime.InvokeVoidAsync("open", uri, target); + } + else + { + Navigation.NavigateTo(uri); + } + } + + private async Task BeginSignOut() + { + if (SignOutManager != null) + { + await SignOutManager.SetSignOutState(); + await NavigateToAsync("authentication/logout"); + } + } +} diff --git a/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Themes/AntDesignTheme/_Imports.razor b/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Themes/AntDesignTheme/_Imports.razor new file mode 100644 index 0000000..c2316af --- /dev/null +++ b/modules/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Themes/AntDesignTheme/_Imports.razor @@ -0,0 +1,2 @@ +@using Microsoft.AspNetCore.Components.Web +@using AntDesign diff --git a/src/Lsw.Abp.AntDesignUI/AntDesignUiNotificationService.cs b/src/Lsw.Abp.AntDesignUI/AntDesignUiNotificationService.cs index fe6a3d9..165baa8 100644 --- a/src/Lsw.Abp.AntDesignUI/AntDesignUiNotificationService.cs +++ b/src/Lsw.Abp.AntDesignUI/AntDesignUiNotificationService.cs @@ -13,7 +13,7 @@ namespace Lsw.Abp.AntDesignUI; public class AntDesignUiNotificationService: IUiNotificationService, IScopedDependency { [Inject] - protected NotificationService NoticeService { get; set; } + public NotificationService NoticeService { get; set; } private readonly IStringLocalizer _localizer; diff --git a/src/Lsw.Abp.AntDesignUI/Components/EntityAction.razor.cs b/src/Lsw.Abp.AntDesignUI/Components/EntityAction.razor.cs index 3e2de69..dd43c7d 100644 --- a/src/Lsw.Abp.AntDesignUI/Components/EntityAction.razor.cs +++ b/src/Lsw.Abp.AntDesignUI/Components/EntityAction.razor.cs @@ -42,10 +42,10 @@ public partial class EntityAction : ComponentBase public EntityActions ParentActions { get; set; } [Inject] - protected IAuthorizationService AuthorizationService { get; set; } + public IAuthorizationService AuthorizationService { get; set; } [Inject] - protected IUiMessageService UiMessageService { get; set; } + public IUiMessageService UiMessageService { get; set; } protected override async Task OnInitializedAsync() { diff --git a/src/Lsw.Abp.AntDesignUI/Components/PageAlert.razor b/src/Lsw.Abp.AntDesignUI/Components/PageAlert.razor index 1b63288..b00150f 100644 --- a/src/Lsw.Abp.AntDesignUI/Components/PageAlert.razor +++ b/src/Lsw.Abp.AntDesignUI/Components/PageAlert.razor @@ -16,10 +16,10 @@ private readonly List _messages = new(); [Inject] - protected IAlertManager AlertManager { get; set; } + public IAlertManager AlertManager { get; set; } [Inject] - protected NavigationManager NavigationManager { get; set; } + public NavigationManager NavigationManager { get; set; } protected override void OnInitialized() { diff --git a/src/Lsw.Abp.AntDesignUI/Components/ToolbarButton.razor b/src/Lsw.Abp.AntDesignUI/Components/ToolbarButton.razor index 6a36e84..62591eb 100644 --- a/src/Lsw.Abp.AntDesignUI/Components/ToolbarButton.razor +++ b/src/Lsw.Abp.AntDesignUI/Components/ToolbarButton.razor @@ -1,4 +1,4 @@ -
- + diff --git a/test/AntDesignUIApp/wwwroot/logo.svg b/test/AntDesignUIApp/wwwroot/logo.svg new file mode 100644 index 0000000..e9f8c2a --- /dev/null +++ b/test/AntDesignUIApp/wwwroot/logo.svg @@ -0,0 +1,43 @@ + + + + Group 28 Copy 5 + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file