fix language edit

This commit is contained in:
2025-12-05 12:22:51 +08:00
parent ac50b3fccd
commit cb881ae1e1
5 changed files with 51 additions and 21 deletions

View File

@@ -1,15 +1,10 @@
using System.ComponentModel.DataAnnotations; namespace Atomx.Admin.Client.Models
using System.ComponentModel.DataAnnotations.Schema;
namespace Atomx.Admin.Client.Models
{ {
public class LanguageModel public class LanguageModel
{ {
/// <summary> /// <summary>
/// 数据ID /// 数据ID
/// </summary> /// </summary>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Key]
public int Id { get; set; } public int Id { get; set; }
/// <summary> /// <summary>
@@ -41,15 +36,5 @@ namespace Atomx.Admin.Client.Models
/// 是否可用,系统面 /// 是否可用,系统面
/// </summary> /// </summary>
public bool Enabled { get; set; } public bool Enabled { get; set; }
/// <summary>
/// 多语言资源的版本,可以是时间戳或哈希
/// </summary>
public string ResourceVersion { get; set; } = string.Empty;
/// <summary>
/// 是否编辑
/// </summary>
public bool IsEdit { get; set; }
} }
} }

View File

@@ -0,0 +1,11 @@
namespace Atomx.Admin.Client.Models
{
public class LocaleResourceSearch
{
public int LanguageId { get; set; }
public string? ResourceName { get; set; }
public string? ResourceValue { get; set; }
}
}

View File

@@ -33,10 +33,13 @@
<Icon Type="close" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" /> <Icon Type="close" Theme="IconThemeType.Outline" Width="1.3em" Height="1.3em" />
} }
</PropertyColumn> </PropertyColumn>
<PropertyColumn Property="c => c.ResourceVersion" Title="资源版本" Width="190px" /> <PropertyColumn Property="c => c.ResourceVersion" Title="资源版本"/>
<PropertyColumn Property="c => c.UpdateTime" Title="最后更新" Width="190px" /> <PropertyColumn Property="c => c.UpdateTime" Title="最后更新" />
<ActionColumn Title="操作" Align="ColumnAlign.Right" Width="160px"> <ActionColumn Title="操作" Align="ColumnAlign.Right">
<Space> <Space>
<SpaceItem>
<a href="@($"/system/locale/resource/list/{context.Id}")"> <Icon Type="@IconType.Outline.Edit" /> 语言资源</a>
</SpaceItem>
<SpaceItem> <SpaceItem>
<Dropdown Trigger="@(new Trigger[] { Trigger.Click })"> <Dropdown Trigger="@(new Trigger[] { Trigger.Click })">
<Overlay> <Overlay>

View File

@@ -2,10 +2,41 @@
@inject ILogger<LocaleResourceList> Logger @inject ILogger<LocaleResourceList> Logger
<PageTitle>本地化语言资源</PageTitle> <PageTitle>本地化语言资源</PageTitle>
<Title Level="4">多语言本地资源管理</Title>
<Spin Spinning="loading"> <Spin Spinning="loading">
</Spin> </Spin>
@code { @code {
[Parameter] [Parameter]
public long Id { get; set; } public int Id { get; set; }
bool loading = false; bool loading = false;
[SupplyParameterFromForm]
LocaleResourceSearch search { get; set; } = default!;
[SupplyParameterFromForm]
LocaleResourceModel model { get; set; } = default!;
protected override void OnInitialized()
{
search ??= new LocaleResourceSearch();
model ??= new LocaleResourceModel();
base.OnInitialized();
}
protected override async Task OnParametersSetAsync()
{
await LoadList();
}
private async Task LoadList()
{
loading = true;
var url = $"/api/locale/resource/search/{Id}";
loading = false;
StateHasChanged();
}
} }

View File

@@ -147,7 +147,7 @@ namespace Atomx.Admin.Controllers
result = result.IsFail("语言文化已存在,请更换!"); result = result.IsFail("语言文化已存在,请更换!");
return new JsonResult(result); return new JsonResult(result);
} }
if (model.IsEdit) if (model.Id > 0)
{ {
data = _dbContext.Languages.SingleOrDefault(p => p.Id == model.Id); data = _dbContext.Languages.SingleOrDefault(p => p.Id == model.Id);
if (data == null) if (data == null)