chore
This commit is contained in:
@@ -26,10 +26,5 @@
|
|||||||
/// 资源内容值
|
/// 资源内容值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Value { get; set; } = string.Empty;
|
public string Value { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 是否编辑
|
|
||||||
/// </summary>
|
|
||||||
public bool IsEdit { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
{
|
{
|
||||||
public int LanguageId { get; set; }
|
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>
|
<FormItem>
|
||||||
<Button Type="ButtonType.Primary" HtmlType="submit" Class="submit" Size="ButtonSize.Large" Block>登录</Button>
|
<Button Type="ButtonType.Primary" HtmlType="submit" Class="submit" Size="ButtonSize.Large" Block>登录</Button>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
<FormItem>
|
||||||
|
<a @onclick="setAccount">
|
||||||
|
设置开发帐号
|
||||||
|
</a>
|
||||||
|
</FormItem>
|
||||||
</Form>
|
</Form>
|
||||||
</Card>
|
</Card>
|
||||||
</GridCol>
|
</GridCol>
|
||||||
@@ -185,6 +190,12 @@ else
|
|||||||
await LoginAsync();
|
await LoginAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setAccount()
|
||||||
|
{
|
||||||
|
login.Account = "admin";
|
||||||
|
login.Password = "admin888";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@* 页面内 JS 辅助:用于在 Server 模式下从浏览器发起 POST 并携带凭证,使浏览器接收 Set-Cookie *@
|
@* 页面内 JS 辅助:用于在 Server 模式下从浏览器发起 POST 并携带凭证,使浏览器接收 Set-Cookie *@
|
||||||
|
|||||||
@@ -112,10 +112,10 @@
|
|||||||
int? PageSize { get; set; }
|
int? PageSize { get; set; }
|
||||||
|
|
||||||
[SupplyParameterFromForm]
|
[SupplyParameterFromForm]
|
||||||
LanguageSearch search { get; set; } = new();
|
LanguageSearch search { get; set; } = default!;
|
||||||
|
|
||||||
[SupplyParameterFromForm]
|
[SupplyParameterFromForm]
|
||||||
LanguageModel model { get; set; } = new();
|
LanguageModel model { get; set; } = default!;
|
||||||
Form<LanguageModel> editform = null!;
|
Form<LanguageModel> editform = null!;
|
||||||
|
|
||||||
Dictionary<string, string> LanguageCultures = LanguageCulture.Descriptions.ToDictionary();
|
Dictionary<string, string> LanguageCultures = LanguageCulture.Descriptions.ToDictionary();
|
||||||
@@ -127,6 +127,8 @@
|
|||||||
|
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
|
search ??= new LanguageSearch();
|
||||||
|
model ??= new LanguageModel();
|
||||||
base.OnInitialized();
|
base.OnInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,23 +6,129 @@
|
|||||||
<PageTitle>本地化语言资源</PageTitle>
|
<PageTitle>本地化语言资源</PageTitle>
|
||||||
<Title Level="4">多语言本地资源管理</Title>
|
<Title Level="4">多语言本地资源管理</Title>
|
||||||
<Spin Spinning="loading">
|
<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>
|
</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 {
|
@code {
|
||||||
|
|
||||||
|
bool loading = false;
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
bool loading = false;
|
|
||||||
|
[SupplyParameterFromQuery]
|
||||||
|
int? Page { get; set; }
|
||||||
|
|
||||||
|
[SupplyParameterFromQuery(Name = "size")]
|
||||||
|
int? PageSize { get; set; }
|
||||||
|
|
||||||
[SupplyParameterFromForm]
|
[SupplyParameterFromForm]
|
||||||
LocaleResourceSearch search { get; set; } = default!;
|
LocaleResourceSearch search { get; set; } = default!;
|
||||||
|
Form<LocaleResourceSearch> searchForm = null!;
|
||||||
|
|
||||||
[SupplyParameterFromForm]
|
[SupplyParameterFromForm]
|
||||||
LocaleResourceModel model { get; set; } = default!;
|
LocaleResourceModel model { get; set; } = default!;
|
||||||
|
Form<LocaleResourceModel> editform = null!;
|
||||||
|
|
||||||
|
PagingList<LocaleResource> PagingList = new();
|
||||||
|
|
||||||
|
bool modalVisible = false;
|
||||||
|
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
search ??= new LocaleResourceSearch();
|
search ??= new LocaleResourceSearch() { LanguageId = Id };
|
||||||
model ??= new LocaleResourceModel();
|
model ??= new LocaleResourceModel() { LanguageId = Id };
|
||||||
base.OnInitialized();
|
base.OnInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,10 +141,125 @@
|
|||||||
{
|
{
|
||||||
loading = true;
|
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;
|
loading = false;
|
||||||
StateHasChanged();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ namespace Atomx.Admin.Controllers
|
|||||||
private readonly IMapper _mapper;
|
private readonly IMapper _mapper;
|
||||||
private readonly JwtSetting _jwtSettings;
|
private readonly JwtSetting _jwtSettings;
|
||||||
private readonly ICacheService _cacheService;
|
private readonly ICacheService _cacheService;
|
||||||
private readonly LocalizationFileService _localizationFileService;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -36,7 +35,7 @@ namespace Atomx.Admin.Controllers
|
|||||||
/// <param name="mapper"></param>
|
/// <param name="mapper"></param>
|
||||||
/// <param name="jwtSettings"></param>
|
/// <param name="jwtSettings"></param>
|
||||||
/// <param name="cacheService"></param>
|
/// <param name="cacheService"></param>
|
||||||
public LocaleResourceController(ILogger<LocaleResourceController> logger, IIdCreatorService idCreator, IIdentityService identityService, DataContext dbContext, IMapper mapper, JwtSetting jwtSettings, ICacheService cacheService, LocalizationFileService localizationFileService)
|
public LocaleResourceController(ILogger<LocaleResourceController> logger, IIdCreatorService idCreator, IIdentityService identityService, DataContext dbContext, IMapper mapper, JwtSetting jwtSettings, ICacheService cacheService)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_idCreator = idCreator;
|
_idCreator = idCreator;
|
||||||
@@ -45,41 +44,45 @@ namespace Atomx.Admin.Controllers
|
|||||||
_mapper = mapper;
|
_mapper = mapper;
|
||||||
_jwtSettings = jwtSettings;
|
_jwtSettings = jwtSettings;
|
||||||
_cacheService = cacheService;
|
_cacheService = cacheService;
|
||||||
_localizationFileService = localizationFileService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分页获取多语言资源列表
|
/// 分页获取列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="page"></param>
|
/// <param name="page"></param>
|
||||||
/// <param name="languageId"></param>
|
|
||||||
/// <param name="name"></param>
|
/// <param name="name"></param>
|
||||||
|
/// <param name="start"></param>
|
||||||
|
/// <param name="end"></param>
|
||||||
/// <param name="size"></param>
|
/// <param name="size"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("list")]
|
[HttpPost("search")]
|
||||||
public IActionResult GetList(int page, int languageId, string? name, int size = 20)
|
public IActionResult LanguageList(LocaleResourceSearch search, int page, int size = 20)
|
||||||
{
|
{
|
||||||
if (page < 1)
|
if (page < 1)
|
||||||
{
|
{
|
||||||
page = 1;
|
page = 1;
|
||||||
}
|
}
|
||||||
var result = new Result<PagingList<LocaleResource>>();
|
var result = new ApiResult<PagingList<LocaleResource>>();
|
||||||
var list = new PagingList<LocaleResource>() { Index = page, Size = size };
|
var list = new PagingList<LocaleResource>() { Index = page, Size = size };
|
||||||
var query = from p in _dbContext.LocaleResources
|
var query = from p in _dbContext.LocaleResources
|
||||||
where p.LanguageId == languageId
|
|
||||||
select p;
|
select p;
|
||||||
|
if (search.LanguageId > 0)
|
||||||
if (!string.IsNullOrEmpty(name))
|
|
||||||
{
|
{
|
||||||
query = from p in query
|
query = query.Where(p => p.LanguageId == search.LanguageId);
|
||||||
where p.Name.Contains(name)
|
}
|
||||||
select p;
|
if (!string.IsNullOrEmpty(search.Name))
|
||||||
|
{
|
||||||
|
query = query.Where(p => p.Name.Contains(search.Name));
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(search.Value))
|
||||||
|
{
|
||||||
|
query = query.Where(p => p.Value.Contains(search.Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
list.Count = query.Count();
|
list.Count = query.Count();
|
||||||
list.Items = query.OrderByDescending(p => p.Name).Skip((page - 1) * size).Take(size).ToList();
|
list.Items = query.OrderByDescending(p => p.UpdateTime).Skip((page - 1) * size).Take(size).ToList();
|
||||||
|
|
||||||
result.Data = list;
|
result = result.IsSuccess(list);
|
||||||
|
|
||||||
return new JsonResult(result);
|
return new JsonResult(result);
|
||||||
}
|
}
|
||||||
@@ -126,7 +129,7 @@ namespace Atomx.Admin.Controllers
|
|||||||
result = result.IsFail(ModelState.Values.First().Errors[0].ErrorMessage);
|
result = result.IsFail(ModelState.Values.First().Errors[0].ErrorMessage);
|
||||||
return new JsonResult(result);
|
return new JsonResult(result);
|
||||||
}
|
}
|
||||||
if (model.IsEdit)
|
if (model.Id > 0)
|
||||||
{
|
{
|
||||||
var data = _dbContext.LocaleResources.SingleOrDefault(p => p.Id == model.Id);
|
var data = _dbContext.LocaleResources.SingleOrDefault(p => p.Id == model.Id);
|
||||||
if (data == null)
|
if (data == null)
|
||||||
|
|||||||
Reference in New Issue
Block a user