fix language

This commit is contained in:
2025-12-05 02:13:05 +08:00
parent 00dd4fa958
commit ac50b3fccd
7 changed files with 206 additions and 54 deletions

View File

@@ -23,7 +23,7 @@ namespace Atomx.Admin.Client.Models
public string Title { get; set; } = string.Empty;
/// <summary>
/// 语言名称
/// 语言文化
/// </summary>
public string Culture { get; set; } = string.Empty;

View File

@@ -1,5 +1,4 @@
@page "/admin/list"
@using Atomx.Common.Constants
@inject ILogger<AdminList> Logger
@* @attribute [Authorize] *@
@@ -41,10 +40,10 @@
<ColumnDefinitions>
<PropertyColumn Property="c => c.Username" Title="帐号">
</PropertyColumn>
<PropertyColumn Property="c => c.Email" Title="邮件" Width="80px" Align="ColumnAlign.Center">
<PropertyColumn Property="c => c.Email" Title="邮件">
</PropertyColumn>
<PropertyColumn Property="c => c.Mobile" Title="手机号" Width="100px" />
<PropertyColumn Property="c => c.Mobile" Title="手机号" />
<PropertyColumn Property="c => c.Status" Title="状态" Width="80px" Align="ColumnAlign.Center">
@if (context.Status == 1)
{
@@ -56,8 +55,8 @@
<Icon Type="close" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" />
}
</PropertyColumn>
<PropertyColumn Property="c => c.LastLogin" Title="最后登录" Width="190px" />
<PropertyColumn Property="c => c.UpdateTime" Title="最后更新" Width="190px" />
<PropertyColumn Property="c => c.LastLogin" Title="最后登录" Width="120px" />
<PropertyColumn Property="c => c.UpdateTime" Title="最后更新" />
<ActionColumn Title="操作" Align="ColumnAlign.Right" Width="160px">
<Space>
<SpaceItem>
@@ -326,7 +325,7 @@
{
CloseDrawer();
LoadList();
_= LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
}
else

View File

@@ -16,12 +16,12 @@
</Flex>
</TitleTemplate>
<ColumnDefinitions>
<PropertyColumn Property="c => c.Name" Title="帐号">
<PropertyColumn Property="c => c.Name" Title="语言名称">
</PropertyColumn>
<PropertyColumn Property="c => c.Title" Title="邮件" Width="80px" Align="ColumnAlign.Center">
<PropertyColumn Property="c => c.Title" Title="语言标题">
</PropertyColumn>
<PropertyColumn Property="c => c.Culture" Title="手机号" Width="100px" />
<PropertyColumn Property="c => c.Culture" Title="语言文化" Width="100px" />
<PropertyColumn Property="c => c.Enabled" Title="状态" Width="80px" Align="ColumnAlign.Center">
@if (context.Enabled)
{
@@ -33,7 +33,7 @@
<Icon Type="close" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" />
}
</PropertyColumn>
<PropertyColumn Property="c => c.ResourceVersion" Title="最后登录" Width="190px" />
<PropertyColumn Property="c => c.ResourceVersion" Title="资源版本" Width="190px" />
<PropertyColumn Property="c => c.UpdateTime" Title="最后更新" Width="190px" />
<ActionColumn Title="操作" Align="ColumnAlign.Right" Width="160px">
<Space>
@@ -69,22 +69,31 @@
</Table>
</Card>
<Drawer Closable="true" Width="520" Visible="drawerVisible" Title='(model.Id == 0 ? "新增帐号" : "编辑帐号")' OnClose="_ => CloseDrawer()">
<Drawer Closable="true" Width="520" Visible="drawerVisible" Title='(model.Id == 0 ? "新增语言" : "编辑语言")' OnClose="_ => CloseDrawer()">
<Form LabelColSpan="5" @ref="@editform" Model="@model" OnFinish="OnFormFinish">
<FluentValidationValidator />
<FormItem Label="语言标题">
<Input @bind-Value="model.Title" For="(()=>model.Title)" Placeholder="语言标题" />
</FormItem>
<FormItem Label="语言名称">
<Input @bind-Value="model.Name" For="(()=>model.Name)" Placeholder="语言名称" />
</FormItem>
<FormItem Label="语言标题">
<Input @bind-Value="model.Culture" For="(()=>model.Culture)" Placeholder="语言标题" />
<FormItem Label="语言文化">
<SimpleSelect @bind-Value="model.Culture" For="(()=>model.Culture)" Placeholder="语言文化">
<SelectOptions>
@foreach (var item in LanguageCultures)
{
<SimpleSelectOption Value="@item.Key" Label="@($"{item.Value} - {item.Key}")"></SimpleSelectOption>
}
</SelectOptions>
</SimpleSelect>
</FormItem>
<FormItem Label="手机号码">
<Input @bind-Value="model.FlagImage" For="(()=>model.FlagImage)" Placeholder="手机号码" />
<FormItem Label="显示排序">
<AntDesign.InputNumber @bind-Value="model.DisplayOrder" For="(()=>model.DisplayOrder)" Placeholder="显示排序" />
</FormItem>
@* <FormItem Label="可用状态">
<FormItem Label="可用状态">
<Checkbox T="bool" Label="启用" @bind-value="model.Enabled" Size="InputSize.Small" Class="ps-0" />
</FormItem> *@
</FormItem>
<FormItem WrapperColOffset="4">
<Button Type="ButtonType.Primary" HtmlType="submit" Style="width: 100%;">保存</Button>
</FormItem>
@@ -105,6 +114,8 @@
LanguageModel model { get; set; } = new();
Form<LanguageModel> editform = null!;
Dictionary<string, string> LanguageCultures = LanguageCulture.Descriptions.ToDictionary();
PagingList<Language> PagingList = new();
bool loading { get; set; } = true;
@@ -117,13 +128,13 @@
protected override void OnParametersSet()
{
LoadList();
_ = LoadList();
base.OnParametersSet();
}
private async void LoadList()
private async Task LoadList()
{
loading = true;
@@ -169,7 +180,7 @@
void OnCreateClick()
{
model = new();
model = new() { Culture = LanguageCulture.zhHans };
drawerVisible = true;
}
@@ -185,7 +196,7 @@
var apiResult = await HttpService.Post<ApiResult<string>>(url, new());
if (apiResult.Success)
{
LoadList();
_ = LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "操作提示", Content = "删除数据成功" });
}
else
@@ -199,25 +210,23 @@
if (editform.Validate())
{
var result = new ApiResult<string>();
if (model.Id > 0)
var url = $"api/language/save";
var result = await HttpService.Post<ApiResult<bool>>(url, model);
if (result.Success)
{
var url = $"api/language/edit";
result = await HttpService.Post<ApiResult<string>>(url, model);
}
else
{
var url = $"api/language/add";
result = await HttpService.Post<ApiResult<string>>(url, model);
if (result.Data)
{
CloseDrawer();
_ = LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });
}
}
if (result.Code == (int)ResultCode.Success)
{
CloseDrawer();
LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });

View File

@@ -1,6 +1,11 @@
@page "/system/locale/resource/list/{culture}"
@page "/system/locale/resource/list/{Id:int}"
@inject ILogger<LocaleResourceList> Logger
<PageTitle>本地化语言资源</PageTitle>
<Spin Spinning="loading">
</Spin>
@code {
[Parameter]
public long Id { get; set; }
bool loading = false;
}

View File

@@ -7,7 +7,9 @@ namespace Atomx.Admin.Client.Validators
{
public LanguageModelValidator()
{
RuleFor(p => p.Title).NotEmpty().WithMessage("请填写语言标题");
RuleFor(p => p.Name).NotEmpty().WithMessage("请填写语言名称");
RuleFor(p => p.Culture).NotEmpty().WithMessage("请选择语言文化");
}
}
}