chore fix

This commit is contained in:
2025-12-06 13:30:17 +08:00
parent 2972886576
commit 8aca372fc1
43 changed files with 984 additions and 595 deletions

View File

@@ -33,7 +33,7 @@
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true" Resizable>
<TitleTemplate>
<Flex Justify="FlexJustify.SpaceBetween">
多语言列表
@(@language.Name)语言资源列表
<div>
<Button Class="me-3" OnClick="OnCreateClick" Type="ButtonType.Primary">新增</Button>
</div>
@@ -45,11 +45,11 @@
<PropertyColumn Property="c => c.Value" Title="内容">
</PropertyColumn>
<PropertyColumn Property="c => c.UpdateTime" Title="最后更新" />
<ActionColumn Title="操作" Align="ColumnAlign.Right">
<PropertyColumn Property="c => c.UpdateTime" Title="最后更新" Width="120px" />
<ActionColumn Title="操作" Align="ColumnAlign.Right" Width="120px">
<Space>
<SpaceItem>
<a href="@($"/system/locale/resource/list/{context.Id}")"> <Icon Type="@IconType.Outline.Edit" /> 语言资源</a>
<a @onclick="(e) => OnEditClick(context)"> <Icon Type="@IconType.Outline.Edit" /> 编辑</a>
</SpaceItem>
<SpaceItem>
<Dropdown Trigger="@(new Trigger[] { Trigger.Click })">
@@ -57,7 +57,7 @@
<Menu>
<MenuItem>
<a @onclick="(e) => OnEditClick(context)"> <Icon Type="@IconType.Outline.Edit" /> 编辑</a>
<a href="@($"/system/locale/resource/detail/{context.Name}")"> <Icon Type="@IconType.Outline.Edit" /> 其他语言比对</a>
</MenuItem>
<MenuDivider />
<MenuItem>
@@ -88,14 +88,17 @@
</Card>
</Spin>
<Modal Title="@("消息模版设置")" Visible="@modalVisible" Width="700" MaskClosable="true" OkText="@("保存")" CancelText="@("取消")" OnOk="@HandleModalOk" OnCancel="@HandleCancel">
<Modal Title="@("语言资源设置")" Visible="@modalVisible" Width="700" MaskClosable="true" OkText="@("保存")" CancelText="@("取消")" OnOk="@HandleModalOk" OnCancel="@HandleCancel">
<Form Model="@model" @ref="@editform" LabelCol="new ColLayoutParam { Span = 5 }" WrapperCol="new ColLayoutParam { Span = 15 }" Name="modalForm" OnFinish="OnFormFinish">
<FluentValidationValidator />
<FormItem Label="消息模版名称">
<Input Placeholder="消息模版名称" @bind-Value="@context.Name" />
<FormItem Label="语言文字">
@language.Name
</FormItem>
<FormItem Label="消息内容">
<TextArea Placeholder="消息内容" @bind-Value="@context.Value" />
<FormItem Label="资源名称">
<Input Placeholder="资源名称" @bind-Value="@context.Name" />
</FormItem>
<FormItem Label="资源内容">
<TextArea Placeholder="资源内容" @bind-Value="@context.Value" />
</FormItem>
</Form>
</Modal>
@@ -121,6 +124,7 @@
LocaleResourceModel model { get; set; } = default!;
Form<LocaleResourceModel> editform = null!;
Language language = new();
PagingList<LocaleResource> PagingList = new();
bool modalVisible = false;
@@ -134,9 +138,23 @@
protected override async Task OnParametersSetAsync()
{
await LoadLanguage();
await LoadList();
}
private async Task LoadLanguage()
{
var url = $"/api/language/{Id}";
var apiResult = await HttpService.Get<ApiResult<Language>>(url);
if (apiResult.Success)
{
if (apiResult.Data != null)
{
language = apiResult.Data;
}
}
}
private async Task LoadList()
{
loading = true;
@@ -172,18 +190,20 @@
void OnCreateClick()
{
model = new() { Culture = LanguageCulture.zhHans };
Console.WriteLine("OnCreateClick");
model = new() { Culture = LanguageCulture.zhHans, LanguageId = Id };
modalVisible = true;
}
void OnEditClick(LocaleResource data)
{
this.model = data.Adapt<LocaleResourceModel>();
// drawerVisible = true;
modalVisible = true;
}
async Task HandleDeleteConfirmAsync(MouseEventArgs e, long id)
{
var url = $"/api/language/delete/{id}";
var url = $"/api/localeresource/delete/{id}";
var apiResult = await HttpService.Post<ApiResult<string>>(url, new());
if (apiResult.Success)
{
@@ -196,35 +216,6 @@
}
}
async Task OnFormFinish()
{
if (editform.Validate())
{
var url = $"api/language/save";
var result = await HttpService.Post<ApiResult<bool>>(url, model);
if (result.Success)
{
if (result.Data)
{
// CloseDrawer();
_ = LoadList();
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });
}
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });
}
}
}
private void OnSearch(int page)
{
var queryString = search.BuildQueryString();
@@ -257,9 +248,34 @@
OnSearch(args.Page);
}
void CloseDrawer()
void HandleModalOk()
{
// drawerVisible = false;
editform.Reset();
editform.Submit();
}
async Task OnFormFinish()
{
if (editform.Validate())
{
var result = new ApiResult<bool>();
var url = $"api/localeresource/save";
result = await HttpService.Post<ApiResult<bool>>(url, model);
if (result.Success)
{
modalVisible = false;
_ = LoadList();
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });
}
}
}
void HandleCancel()
{
modalVisible = false;
}
}