Browse Source

Merge pull request #19 from JadynWong/jadyn/feat

Synchronizing some abp changes
pull/29/head
liangshiwei 3 years ago
committed by GitHub
parent
commit
df664a1fff
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      modules/AntDesignTheme/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/MainMenu.razor.cs
  2. 12
      modules/AntDesignTheme/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/NavToolbar.razor.cs
  3. 3
      modules/AntDesignTheme/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/AntDesignThemeToolbarContributor.cs
  4. 16
      modules/AntDesignTheme/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Pages/Authentication.razor
  5. 26
      modules/AntDesignTheme/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Themes/AntDesignTheme/LoginDisplay.razor.cs
  6. 3
      modules/IdentityManagement/Lsw.Abp.IdentityManagement.Blazor.AntDesignUI/Pages/UserManagement.razor.cs
  7. 1
      modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/AbpSettingManagementBlazorAntDesignModule.cs
  8. 2
      modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/Pages/SettingManagement/EmailSettingGroup/EmailSettingGroupViewComponent.razor
  9. 20
      modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/Pages/SettingManagement/TimeZoneSettingGroup/TimeZoneSettingGroupViewComponent.razor
  10. 61
      modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/Pages/SettingManagement/TimeZoneSettingGroup/TimeZoneSettingGroupViewComponent.razor.cs
  11. 38
      modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/Settings/AntDesignTimeZonePageContributor.cs
  12. 1433
      samples/BookStore/src/BookStore.Blazor/wwwroot/global.css
  13. 4
      samples/BookStore/src/BookStore.Blazor/wwwroot/global.js
  14. 4
      samples/BookStore/src/BookStore.Blazor/wwwroot/index.html
  15. 21
      samples/BookStore/src/BookStore.BlazorServer/BookStoreBlazorModule.cs
  16. 8
      samples/BookStore/src/BookStore.DbMigrator/BookStore.DbMigrator.csproj
  17. 10
      samples/BookStore/src/BookStore.DbMigrator/Properties/launchSettings.json
  18. 14
      samples/BookStore/src/BookStore.Domain.Shared/BookStoreModuleExtensionConfigurator.cs
  19. 7
      samples/BookStore/src/BookStore.Domain.Shared/Identity/IdentityUserType.cs
  20. 5
      samples/BookStore/src/BookStore.Domain.Shared/Localization/BookStore/en.json
  21. 17
      samples/BookStore/src/BookStore.Domain.Shared/Localization/BookStore/zh-Hans.json
  22. 4
      src/Lsw.Abp.AntDesignUI/AbpCrudPageBase.cs
  23. 28
      src/Lsw.Abp.AntDesignUI/Components/ObjectExtending/EnumHelper.cs
  24. 4
      src/Lsw.Abp.AntDesignUI/Components/ObjectExtending/ExtensionPropertyComponentBase.cs
  25. 2
      src/Lsw.Abp.AntDesignUI/Components/ObjectExtending/SelectExtensionProperty.razor.cs

11
modules/AntDesignTheme/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/MainMenu.razor.cs

@ -5,6 +5,7 @@ using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Settings;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.Options;
using Volo.Abp.AspNetCore.Components.Web.Security;
using Volo.Abp.UI.Navigation;
namespace Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Themes.AntDesignTheme;
@ -17,7 +18,7 @@ public partial class MainMenu : IDisposable
protected IMenuManager MenuManager { get; set; }
[Inject]
protected AuthenticationStateProvider AuthenticationStateProvider { get; set; }
protected ApplicationConfigurationChangedService ApplicationConfigurationChangedService { get; set; }
[Parameter]
public MenuPlacement Placement { get; set; }
@ -31,15 +32,15 @@ public partial class MainMenu : IDisposable
protected override async Task OnInitializedAsync()
{
await GetMenuAsync();
AuthenticationStateProvider.AuthenticationStateChanged += AuthenticationStateProviderOnAuthenticationStateChanged;
ApplicationConfigurationChangedService.Changed += ApplicationConfigurationChanged;
}
private async Task GetMenuAsync()
{
Menu = await MenuManager.GetMainMenuAsync();
}
private async void AuthenticationStateProviderOnAuthenticationStateChanged(Task<AuthenticationState> task)
private async void ApplicationConfigurationChanged()
{
await GetMenuAsync();
await InvokeAsync(StateHasChanged);
@ -47,6 +48,6 @@ public partial class MainMenu : IDisposable
public void Dispose()
{
AuthenticationStateProvider.AuthenticationStateChanged -= AuthenticationStateProviderOnAuthenticationStateChanged;
ApplicationConfigurationChangedService.Changed -= ApplicationConfigurationChanged;
}
}

12
modules/AntDesignTheme/Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme/Themes/AntDesignTheme/NavToolbar.razor.cs

@ -3,24 +3,24 @@ 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;
using Volo.Abp.AspNetCore.Components.Web.Security;
namespace Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Themes.AntDesignTheme;
public partial class NavToolbar: IDisposable
public partial class NavToolbar : IDisposable
{
[Inject]
private IToolbarManager ToolbarManager { get; set; }
[Inject]
private AuthenticationStateProvider AuthenticationStateProvider { get; set; }
private ApplicationConfigurationChangedService ApplicationConfigurationChangedService { get; set; }
private List<RenderFragment> ToolbarItemRenders { get; set; } = new();
protected override async Task OnInitializedAsync()
{
await GetToolbarItemRendersAsync();
AuthenticationStateProvider.AuthenticationStateChanged += AuthenticationStateProviderOnAuthenticationStateChanged;
ApplicationConfigurationChangedService.Changed += ApplicationConfigurationChanged;
}
private async Task GetToolbarItemRendersAsync()
@ -40,7 +40,7 @@ public partial class NavToolbar: IDisposable
}
}
private async void AuthenticationStateProviderOnAuthenticationStateChanged(Task<AuthenticationState> task)
private async void ApplicationConfigurationChanged()
{
await GetToolbarItemRendersAsync();
await InvokeAsync(StateHasChanged);
@ -48,6 +48,6 @@ public partial class NavToolbar: IDisposable
public void Dispose()
{
AuthenticationStateProvider.AuthenticationStateChanged -= AuthenticationStateProviderOnAuthenticationStateChanged;
ApplicationConfigurationChangedService.Changed -= ApplicationConfigurationChanged;
}
}

3
modules/AntDesignTheme/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/AntDesignThemeToolbarContributor.cs

@ -14,8 +14,9 @@ public class AntDesignThemeToolbarContributor: IToolbarContributor
{
context.Toolbar.Items.Add(new ToolbarItem(typeof(LanguageSwitch)));
//TODO: Can we find a different way to understand if authentication was configured or not?
var authenticationStateProvider = context.ServiceProvider
.GetRequiredService<AuthenticationStateProvider>();
.GetService<AuthenticationStateProvider>();
if (authenticationStateProvider != null)
{

16
modules/AntDesignTheme/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Pages/Authentication.razor

@ -1,7 +1,21 @@
@page "/authentication/{action}"
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
<RemoteAuthenticatorView Action="@Action" />
@using Volo.Abp.AspNetCore.Components.Web.Security
@using Volo.Abp.AspNetCore.Components.WebAssembly
<RemoteAuthenticatorView Action="@Action" OnLogInSucceeded="OnLogInSucceeded" OnLogOutSucceeded="OnLogOutSucceeded" />
@inject WebAssemblyCachedApplicationConfigurationClient WebAssemblyCachedApplicationConfigurationClient
@code{
[Parameter] public string Action { get; set; }
private async Task OnLogInSucceeded(RemoteAuthenticationState state)
{
await WebAssemblyCachedApplicationConfigurationClient.InitializeAsync();
}
private async Task OnLogOutSucceeded(RemoteAuthenticationState state)
{
await WebAssemblyCachedApplicationConfigurationClient.InitializeAsync();
}
}

26
modules/AntDesignTheme/Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme/Themes/AntDesignTheme/LoginDisplay.razor.cs

@ -1,11 +1,10 @@
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.AspNetCore.Components.Web.Security;
using Volo.Abp.UI.Navigation;
namespace Lsw.Abp.AspnetCore.Components.WebAssembly.AntDesignTheme.Themes.AntDesignTheme;
@ -16,10 +15,7 @@ public partial class LoginDisplay : IDisposable
protected IMenuManager MenuManager { get; set; }
[Inject]
public AuthenticationStateProvider AuthenticationStateProvider { get; set; }
[CanBeNull]
protected SignOutSessionStateManager SignOutManager;
protected ApplicationConfigurationChangedService ApplicationConfigurationChangedService { get; set; }
protected ApplicationMenu Menu { get; set; }
@ -29,10 +25,7 @@ public partial class LoginDisplay : IDisposable
Navigation.LocationChanged += OnLocationChanged;
LazyGetService(ref SignOutManager);
AuthenticationStateProvider.AuthenticationStateChanged +=
AuthenticationStateProviderOnAuthenticationStateChanged;
ApplicationConfigurationChangedService.Changed += ApplicationConfigurationChanged;
}
protected virtual void OnLocationChanged(object sender, LocationChangedEventArgs e)
@ -40,7 +33,7 @@ public partial class LoginDisplay : IDisposable
InvokeAsync(StateHasChanged);
}
private async void AuthenticationStateProviderOnAuthenticationStateChanged(Task<AuthenticationState> task)
private async void ApplicationConfigurationChanged()
{
Menu = await MenuManager.GetAsync(StandardMenus.User);
await InvokeAsync(StateHasChanged);
@ -49,8 +42,7 @@ public partial class LoginDisplay : IDisposable
public void Dispose()
{
Navigation.LocationChanged -= OnLocationChanged;
AuthenticationStateProvider.AuthenticationStateChanged -=
AuthenticationStateProviderOnAuthenticationStateChanged;
ApplicationConfigurationChangedService.Changed -= ApplicationConfigurationChanged;
}
private async Task NavigateToAsync(string uri, string target = null)
@ -65,12 +57,8 @@ public partial class LoginDisplay : IDisposable
}
}
private async Task BeginSignOut()
private void BeginSignOut()
{
if (SignOutManager != null)
{
await SignOutManager.SetSignOutState();
await NavigateToAsync("authentication/logout");
}
Navigation.NavigateToLogout("authentication/logout");
}
}

3
modules/IdentityManagement/Lsw.Abp.IdentityManagement.Blazor.AntDesignUI/Pages/UserManagement.razor.cs

@ -144,7 +144,8 @@ public partial class UserManagement
Clicked = async (data) =>
{
await PermissionManagementModal.OpenAsync(PermissionProviderName,
data.As<IdentityUserDto>().Id.ToString());
data.As<IdentityUserDto>().Id.ToString(),
data.As<IdentityUserDto>().UserName);
}
},
new EntityAction

1
modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/AbpSettingManagementBlazorAntDesignModule.cs

@ -40,6 +40,7 @@ public class AbpSettingManagementBlazorAntDesignModule : AbpModule
Configure<SettingManagementComponentOptions>(options =>
{
options.Contributors.Add(new AntDesignSettingDefultPageContributor());
options.Contributors.Add(new AntDesignTimeZonePageContributor());
});
}
}

2
modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/Pages/SettingManagement/EmailSettingGroup/EmailSettingGroupViewComponent.razor

@ -25,7 +25,7 @@
<Checkbox @bind-Value="context.SmtpUseDefaultCredentials">@L["SmtpUseDefaultCredentials"]</Checkbox>
</FormItem>
@if (EmailSettings.SmtpUseDefaultCredentials)
@if (!EmailSettings.SmtpUseDefaultCredentials)
{
<FormItem Label="@L["SmtpDomain"]">
<Input @bind-Value="@context.SmtpDomain"/>

20
modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/Pages/SettingManagement/TimeZoneSettingGroup/TimeZoneSettingGroupViewComponent.razor

@ -0,0 +1,20 @@
@using Volo.Abp.SettingManagement.Localization
@inherits Volo.Abp.AspNetCore.Components.AbpComponentBase
@inject AbpBlazorMessageLocalizerHelper<AbpSettingManagementResource> LH
<Form Layout="@FormLayout.Vertical" Model="@TimezoneSettings">
<FormItem Label="@L["DisplayName:Timezone"]">
<Select DataSource="@context.TimeZoneItems"
ValueName="@nameof(Volo.Abp.NameValue.Value)"
LabelName="@nameof(Volo.Abp.NameValue.Name)"
@bind-Value="@context.Timezone">
</Select>
</FormItem>
<FormItem WrapperColOffset="8">
<Button Type="@ButtonType.Primary" HtmlType="submit" OnClick="@UpdateSettingsAsync">
@L["Submit"]
</Button>
</FormItem>
</Form>

61
modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/Pages/SettingManagement/TimeZoneSettingGroup/TimeZoneSettingGroupViewComponent.razor.cs

@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using Volo.Abp;
using Volo.Abp.AspNetCore.Components.Web.Configuration;
using Volo.Abp.SettingManagement;
using Volo.Abp.SettingManagement.Localization;
namespace Lsw.Abp.SettingManagement.Blazor.AntDesignUI.Pages.SettingManagement.TimeZoneSettingGroup;
public partial class TimeZoneSettingGroupViewComponent
{
[Inject]
protected ITimeZoneSettingsAppService TimeZoneSettingsAppService { get; set; }
[Inject]
protected ICurrentApplicationConfigurationCacheResetService CurrentApplicationConfigurationCacheResetService { get; set; }
protected UpdateTimezoneSettingsViewModel TimezoneSettings = new();
public TimeZoneSettingGroupViewComponent()
{
ObjectMapperContext = typeof(AbpSettingManagementBlazorAntDesignModule);
LocalizationResource = typeof(AbpSettingManagementResource);
}
protected override async Task OnInitializedAsync()
{
try
{
TimezoneSettings.Timezone = await TimeZoneSettingsAppService.GetAsync();
TimezoneSettings.TimeZoneItems = await TimeZoneSettingsAppService.GetTimezonesAsync();
}
catch (Exception ex)
{
await HandleErrorAsync(ex);
}
}
protected virtual async Task UpdateSettingsAsync()
{
try
{
await TimeZoneSettingsAppService.UpdateAsync(TimezoneSettings.Timezone);
await CurrentApplicationConfigurationCacheResetService.ResetAsync();
await Message.Success(L["SuccessfullySaved"]);
}
catch (Exception ex)
{
await HandleErrorAsync(ex);
}
}
public class UpdateTimezoneSettingsViewModel
{
public string Timezone { get; set; }
public List<NameValue> TimeZoneItems { get; set; }
}
}

38
modules/SettingManagement/Lsw.Abp.SettingManagement.Blazor.AntDesignUI/Settings/AntDesignTimeZonePageContributor.cs

@ -0,0 +1,38 @@
using System.Threading.Tasks;
using Lsw.Abp.SettingManagement.Blazor.AntDesignUI.Pages.SettingManagement.TimeZoneSettingGroup;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using Volo.Abp.SettingManagement;
using Volo.Abp.SettingManagement.Blazor;
using Volo.Abp.SettingManagement.Localization;
using Volo.Abp.Timing;
namespace Lsw.Abp.SettingManagement.Blazor.AntDesignUI.Settings;
public class AntDesignTimeZonePageContributor : ISettingComponentContributor
{
public virtual async Task<bool> CheckPermissionsAsync(SettingComponentCreationContext context)
{
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>();
return await authorizationService.IsGrantedAsync(SettingManagementPermissions.TimeZone);
}
public virtual Task ConfigureAsync(SettingComponentCreationContext context)
{
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<AbpSettingManagementResource>>();
if (context.ServiceProvider.GetRequiredService<IClock>().SupportsMultipleTimezone)
{
context.Groups.Add(
new SettingComponentGroup(
"Volo.Abp.TimeZone",
l["Menu:TimeZone"],
typeof(TimeZoneSettingGroupViewComponent)
)
);
}
return Task.CompletedTask;
}
}

1433
samples/BookStore/src/BookStore.Blazor/wwwroot/global.css

File diff suppressed because it is too large

4
samples/BookStore/src/BookStore.Blazor/wwwroot/global.js

File diff suppressed because one or more lines are too long

4
samples/BookStore/src/BookStore.Blazor/wwwroot/index.html

@ -8,7 +8,7 @@
<base href="/" />
<!--ABP:Styles-->
<link href="global.css?_v=638094004787675581" rel="stylesheet"/>
<link href="global.css?_v=638340104034572936" rel="stylesheet"/>
<link href="main.css" rel="stylesheet"/>
<!--/ABP:Styles-->
<link href="BookStore.Blazor.styles.css" rel="stylesheet"/>
@ -23,7 +23,7 @@
</div>
<!--ABP:Scripts-->
<script src="global.js?_v=638094004788749541"></script>
<script src="global.js?_v=638340104035506905"></script>
<!--/ABP:Scripts-->
</body>
</html>

21
samples/BookStore/src/BookStore.BlazorServer/BookStoreBlazorModule.cs

@ -34,6 +34,7 @@ using Volo.Abp.Swashbuckle;
using Volo.Abp.UI.Navigation;
using Volo.Abp.UI.Navigation.Urls;
using Volo.Abp.VirtualFileSystem;
using Volo.Abp.Timing;
namespace BookStore.Blazor;
@ -73,6 +74,8 @@ public class BookStoreBlazorModule : AbpModule
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
Configure<AbpClockOptions>(options => options.Kind = DateTimeKind.Utc);
ConfigureUrls(configuration);
ConfigureBundles();
ConfigureAuthentication(context, configuration);
@ -107,15 +110,15 @@ public class BookStoreBlazorModule : AbpModule
);
//BLAZOR UI
options.StyleBundles.Configure(
BlazorAntDesignThemeBundles.Styles.Global,
bundle =>
{
bundle.AddFiles("/blazor-global-styles.css");
//You can remove the following line if you don't use Blazor CSS isolation for components
bundle.AddFiles("/BookStore.BlazorServer.styles.css");
}
);
options.StyleBundles.Configure(
BlazorAntDesignThemeBundles.Styles.Global,
bundle =>
{
bundle.AddFiles("/blazor-global-styles.css");
//You can remove the following line if you don't use Blazor CSS isolation for components
bundle.AddFiles("/BookStore.BlazorServer.styles.css");
}
);
});
}

8
samples/BookStore/src/BookStore.DbMigrator/BookStore.DbMigrator.csproj

@ -5,6 +5,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<UserSecretsId>BookStore-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId>
</PropertyGroup>
<ItemGroup>
@ -40,4 +41,11 @@
<None Remove="Logs\**" />
</ItemGroup>
<ItemGroup>
<None Update="Properties\launchSettings.json">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>

10
samples/BookStore/src/BookStore.DbMigrator/Properties/launchSettings.json

@ -0,0 +1,10 @@
{
"profiles": {
"BookStore.DbMigrator": {
"commandName": "Project",
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
}
}
}
}

14
samples/BookStore/src/BookStore.Domain.Shared/BookStoreModuleExtensionConfigurator.cs

@ -1,4 +1,5 @@
using Volo.Abp.Identity;
using BookStore.Identity;
using Volo.Abp.Identity;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Threading;
@ -66,5 +67,16 @@ public static class BookStoreModuleExtensionConfigurator
* See the documentation for more:
* https://docs.abp.io/en/abp/latest/Module-Entity-Extensions
*/
ObjectExtensionManager.Instance.Modules()
.ConfigureIdentity(identity => {
identity.ConfigureUser(user =>
{
user.AddOrUpdateProperty<IdentityUserType>("IdentityUserType", property =>
{
property.DefaultValue = IdentityUserType.Normal;
});
});
});
}
}

7
samples/BookStore/src/BookStore.Domain.Shared/Identity/IdentityUserType.cs

@ -0,0 +1,7 @@
namespace BookStore.Identity;
public enum IdentityUserType
{
Normal,
Basic
}

5
samples/BookStore/src/BookStore.Domain.Shared/Localization/BookStore/en.json

@ -3,6 +3,9 @@
"texts": {
"Menu:Home": "Home",
"Welcome": "Welcome",
"LongWelcomeMessage": "Welcome to the application. This is a startup project based on the ABP framework. For more information, visit abp.io."
"LongWelcomeMessage": "Welcome to the application. This is a startup project based on the ABP framework. For more information, visit abp.io.",
"IdentityUserType": "User Type",
"Enum:IdentityUserType.Normal": "Normal User",
"Enum:IdentityUserType.Basic": "Basic User"
}
}

17
samples/BookStore/src/BookStore.Domain.Shared/Localization/BookStore/zh-Hans.json

@ -1,8 +1,11 @@
{
"culture": "zh-Hans",
"texts": {
"Menu:Home": "首页",
"Welcome": "欢迎",
"LongWelcomeMessage": "欢迎来到该应用程序. 这是一个基于ABP框架的启动项目. 有关更多信息, 请访问 abp.io."
}
}
"culture": "zh-Hans",
"texts": {
"Menu:Home": "首页",
"Welcome": "欢迎",
"LongWelcomeMessage": "欢迎来到该应用程序. 这是一个基于ABP框架的启动项目. 有关更多信息, 请访问 abp.io.",
"IdentityUserType": "用户类型",
"Enum:IdentityUserType.Normal": "标准用户",
"Enum:IdentityUserType.Basic": "基础用户"
}
}

4
src/Lsw.Abp.AntDesignUI/AbpCrudPageBase.cs

@ -178,6 +178,8 @@ public abstract class AbpCrudPageBase<
[Inject] protected IStringLocalizer<AbpUiResource> UiLocalizer { get; set; }
[Inject] protected IAbpEnumLocalizer AbpEnumLocalizer { get; set; }
protected virtual int PageSize { get; } = LimitedResultRequestDto.DefaultMaxResultCount;
protected int CurrentPage = 1;
@ -618,7 +620,7 @@ public abstract class AbpCrudPageBase<
if (propertyInfo.Type.IsEnum)
{
column.ValueConverter = (val) =>
EnumHelper.GetLocalizedMemberName(propertyInfo.Type, val.As<ExtensibleObject>().ExtraProperties[propertyInfo.Name], StringLocalizerFactory);
AbpEnumLocalizer.GetString(propertyInfo.Type, val.As<ExtensibleObject>().ExtraProperties[propertyInfo.Name]);
}
yield return column;

28
src/Lsw.Abp.AntDesignUI/Components/ObjectExtending/EnumHelper.cs

@ -1,28 +0,0 @@
using System;
using Microsoft.Extensions.Localization;
using Volo.Abp.Localization;
namespace Lsw.Abp.AntDesignUI.Components.ObjectExtending;
public static class EnumHelper
{
public static string GetLocalizedMemberName(Type enumType, object value, IStringLocalizerFactory stringLocalizerFactory)
{
var memberName = enumType.GetEnumName(value);
var localizedMemberName = AbpInternalLocalizationHelper.LocalizeWithFallback(
new[]
{
stringLocalizerFactory.CreateDefaultOrNull()
},
new[]
{
$"Enum:{enumType.Name}.{memberName}",
$"{enumType.Name}.{memberName}",
memberName
},
memberName
);
return localizedMemberName;
}
}

4
src/Lsw.Abp.AntDesignUI/Components/ObjectExtending/ExtensionPropertyComponentBase.cs

@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
using Volo.Abp.AspNetCore.Components.Web;
using Volo.Abp.Data;
using Volo.Abp.Localization;
using Volo.Abp.ObjectExtending;
namespace Lsw.Abp.AntDesignUI.Components.ObjectExtending;
@ -13,6 +14,9 @@ public abstract class ExtensionPropertyComponentBase<TEntity, TResourceType> : O
[Inject]
public IStringLocalizerFactory StringLocalizerFactory { get; set; }
[Inject]
public IAbpEnumLocalizer EnumLocalizer { get; set; }
[Parameter]
public TEntity Entity { get; set; }

2
src/Lsw.Abp.AntDesignUI/Components/ObjectExtending/SelectExtensionProperty.razor.cs

@ -22,7 +22,7 @@ public partial class SelectExtensionProperty<TEntity, TResourceType>
selectItems.Add(new SelectItem<int>
{
Value = (int)enumValue,
Text = EnumHelper.GetLocalizedMemberName(PropertyInfo.Type, enumValue, StringLocalizerFactory)
Text = EnumLocalizer.GetString(PropertyInfo.Type, enumValue)
});
}

Loading…
Cancel
Save