chore
This commit is contained in:
@@ -26,10 +26,5 @@
|
||||
/// 资源内容值
|
||||
/// </summary>
|
||||
public string Value { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 是否编辑
|
||||
/// </summary>
|
||||
public bool IsEdit { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
{
|
||||
public int LanguageId { get; set; }
|
||||
|
||||
public string? ResourceName { get; set; }
|
||||
public string? Name { get; set; }
|
||||
|
||||
public string? ResourceValue { get; set; }
|
||||
public string? Value { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,11 @@ else
|
||||
<FormItem>
|
||||
<Button Type="ButtonType.Primary" HtmlType="submit" Class="submit" Size="ButtonSize.Large" Block>登录</Button>
|
||||
</FormItem>
|
||||
<FormItem>
|
||||
<a @onclick="setAccount">
|
||||
设置开发帐号
|
||||
</a>
|
||||
</FormItem>
|
||||
</Form>
|
||||
</Card>
|
||||
</GridCol>
|
||||
@@ -185,6 +190,12 @@ else
|
||||
await LoginAsync();
|
||||
}
|
||||
}
|
||||
|
||||
void setAccount()
|
||||
{
|
||||
login.Account = "admin";
|
||||
login.Password = "admin888";
|
||||
}
|
||||
}
|
||||
|
||||
@* 页面内 JS 辅助:用于在 Server 模式下从浏览器发起 POST 并携带凭证,使浏览器接收 Set-Cookie *@
|
||||
|
||||
@@ -112,10 +112,10 @@
|
||||
int? PageSize { get; set; }
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
LanguageSearch search { get; set; } = new();
|
||||
LanguageSearch search { get; set; } = default!;
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
LanguageModel model { get; set; } = new();
|
||||
LanguageModel model { get; set; } = default!;
|
||||
Form<LanguageModel> editform = null!;
|
||||
|
||||
Dictionary<string, string> LanguageCultures = LanguageCulture.Descriptions.ToDictionary();
|
||||
@@ -127,6 +127,8 @@
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
search ??= new LanguageSearch();
|
||||
model ??= new LanguageModel();
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,23 +6,129 @@
|
||||
<PageTitle>本地化语言资源</PageTitle>
|
||||
<Title Level="4">多语言本地资源管理</Title>
|
||||
<Spin Spinning="loading">
|
||||
<Card>
|
||||
<Form @ref="searchForm" Model="search" Layout="FormLayout.Inline" Class="search-form" OnFinish="OnSearchFinish">
|
||||
<Row Justify="RowJustify.Start" Gutter="16">
|
||||
<Col>
|
||||
<FormItem Label="名称">
|
||||
<Input @bind-Value="search.Name" Placeholder="名称" AllowClear />
|
||||
</FormItem>
|
||||
</Col>
|
||||
<Col>
|
||||
<FormItem Label="内容">
|
||||
<Input @bind-Value="search.Value" Placeholder="名称" AllowClear />
|
||||
</FormItem>
|
||||
</Col>
|
||||
<Col>
|
||||
<div class="ant-form-item" style="width:200px;display:flex;">
|
||||
<Button Type="ButtonType.Primary" HtmlType="submit">查询</Button>
|
||||
<Button Style="margin: 0 8px;" OnClick="OnSearchReset">重置</Button>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Form>
|
||||
</Card>
|
||||
<br />
|
||||
<Card Class="mt-3">
|
||||
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true" Resizable>
|
||||
<TitleTemplate>
|
||||
<Flex Justify="FlexJustify.SpaceBetween">
|
||||
多语言列表
|
||||
<div>
|
||||
<Button Class="me-3" OnClick="OnCreateClick" Type="ButtonType.Primary">新增</Button>
|
||||
</div>
|
||||
</Flex>
|
||||
</TitleTemplate>
|
||||
<ColumnDefinitions>
|
||||
<PropertyColumn Property="c => c.Name" Title="资源Key">
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="c => c.Value" Title="内容">
|
||||
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="c => c.UpdateTime" Title="最后更新" />
|
||||
<ActionColumn Title="操作" Align="ColumnAlign.Right">
|
||||
<Space>
|
||||
<SpaceItem>
|
||||
<a href="@($"/system/locale/resource/list/{context.Id}")"> <Icon Type="@IconType.Outline.Edit" /> 语言资源</a>
|
||||
</SpaceItem>
|
||||
<SpaceItem>
|
||||
<Dropdown Trigger="@(new Trigger[] { Trigger.Click })">
|
||||
<Overlay>
|
||||
<Menu>
|
||||
|
||||
<MenuItem>
|
||||
<a @onclick="(e) => OnEditClick(context)"> <Icon Type="@IconType.Outline.Edit" /> 编辑</a>
|
||||
</MenuItem>
|
||||
<MenuDivider />
|
||||
<MenuItem>
|
||||
<Popconfirm Placement="@Placement.Left" Title="@("删除这条数据无法恢复,您确定要删除吗?")"
|
||||
OnConfirm="@(e=>HandleDeleteConfirmAsync(e,context.Id))"
|
||||
OkText="确定"
|
||||
CancelText="取消">
|
||||
<a> <Icon Type="@IconType.Outline.Delete" /> 删除</a>
|
||||
</Popconfirm>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</Overlay>
|
||||
<ChildContent>
|
||||
<a class="ant-dropdown-link" @onclick:preventDefault>
|
||||
<Icon Type="@IconType.Outline.Menu" />
|
||||
</a>
|
||||
</ChildContent>
|
||||
</Dropdown>
|
||||
</SpaceItem>
|
||||
</Space>
|
||||
</ActionColumn>
|
||||
</ColumnDefinitions>
|
||||
</Table>
|
||||
<br />
|
||||
<Row Justify="RowJustify.End">
|
||||
<Pagination PageIndex="pager.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
|
||||
</Row>
|
||||
</Card>
|
||||
</Spin>
|
||||
|
||||
<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>
|
||||
<FormItem Label="消息内容">
|
||||
<TextArea Placeholder="消息内容" @bind-Value="@context.Value" />
|
||||
</FormItem>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
@code {
|
||||
|
||||
bool loading = false;
|
||||
|
||||
[Parameter]
|
||||
public int Id { get; set; }
|
||||
bool loading = false;
|
||||
|
||||
[SupplyParameterFromQuery]
|
||||
int? Page { get; set; }
|
||||
|
||||
[SupplyParameterFromQuery(Name = "size")]
|
||||
int? PageSize { get; set; }
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
LocaleResourceSearch search { get; set; } = default!;
|
||||
Form<LocaleResourceSearch> searchForm = null!;
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
LocaleResourceModel model { get; set; } = default!;
|
||||
Form<LocaleResourceModel> editform = null!;
|
||||
|
||||
PagingList<LocaleResource> PagingList = new();
|
||||
|
||||
bool modalVisible = false;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
search ??= new LocaleResourceSearch();
|
||||
model ??= new LocaleResourceModel();
|
||||
search ??= new LocaleResourceSearch() { LanguageId = Id };
|
||||
model ??= new LocaleResourceModel() { LanguageId = Id };
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
@@ -35,10 +141,125 @@
|
||||
{
|
||||
loading = true;
|
||||
|
||||
var url = $"/api/locale/resource/search/{Id}";
|
||||
var url = $"/api/localeresource/search";
|
||||
|
||||
var apiResult = await HttpService.GetPagingList<LocaleResource>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
|
||||
if (apiResult.Success)
|
||||
{
|
||||
if (apiResult.Data != null)
|
||||
{
|
||||
PagingList = apiResult.Data;
|
||||
}
|
||||
}
|
||||
|
||||
loading = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
void OnSearchFinish()
|
||||
{
|
||||
Page = Page.GetValueOrDefault(1) - 1;
|
||||
|
||||
OnSearch(Page.Value);
|
||||
}
|
||||
|
||||
void OnSearchReset()
|
||||
{
|
||||
search = new() { LanguageId = Id };
|
||||
searchForm?.Reset();
|
||||
OnSearchFinish();
|
||||
}
|
||||
|
||||
void OnCreateClick()
|
||||
{
|
||||
model = new() { Culture = LanguageCulture.zhHans };
|
||||
}
|
||||
|
||||
void OnEditClick(LocaleResource data)
|
||||
{
|
||||
this.model = data.Adapt<LocaleResourceModel>();
|
||||
// drawerVisible = true;
|
||||
}
|
||||
|
||||
async Task HandleDeleteConfirmAsync(MouseEventArgs e, long id)
|
||||
{
|
||||
var url = $"/api/language/delete/{id}";
|
||||
var apiResult = await HttpService.Post<ApiResult<string>>(url, new());
|
||||
if (apiResult.Success)
|
||||
{
|
||||
_ = LoadList();
|
||||
await ModalService.InfoAsync(new ConfirmOptions() { Title = "操作提示", Content = "删除数据成功" });
|
||||
}
|
||||
else
|
||||
{
|
||||
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "操作提示", Content = $"数据删除失败.{apiResult.Message}" });
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
if (string.IsNullOrEmpty(queryString))
|
||||
{
|
||||
if (page > 1)
|
||||
{
|
||||
Navigation.NavigateTo($"/system/locale/resource/list/{Id}?page={page}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Navigation.NavigateTo($"/system/locale/resource/list/{Id}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (page > 1)
|
||||
{
|
||||
Navigation.NavigateTo($"/system/locale/resource/list/{Id}?page={page}&{queryString}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Navigation.NavigateTo($"/system/locale/resource/list/{Id}?{queryString}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPageChanged(PaginationEventArgs args)
|
||||
{
|
||||
OnSearch(args.Page);
|
||||
}
|
||||
|
||||
void CloseDrawer()
|
||||
{
|
||||
// drawerVisible = false;
|
||||
editform.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user