增加app 版本管理

This commit is contained in:
2025-12-17 00:37:57 +08:00
parent 9d396fa96e
commit da8ac8a22b
12 changed files with 751 additions and 452 deletions

View File

@@ -3,20 +3,257 @@
@inject ILogger<CurrencyList> Logger
@attribute [Authorize]
<PageContainer Title="货币管理">
<PageTitle>货币管理</PageTitle>
<PageContainer Title="语言管理">
<Breadcrumb>
<Breadcrumb>
<BreadcrumbItem Href="/">管理后台</BreadcrumbItem>
<BreadcrumbItem Href="/admin/list">系统功能</BreadcrumbItem>
<BreadcrumbItem>Home</BreadcrumbItem>
<BreadcrumbItem>系统配置</BreadcrumbItem>
<BreadcrumbItem>货币管理</BreadcrumbItem>
</Breadcrumb>
</Breadcrumb>
<ChildContent>
<h3>Tools</h3>
<Spin Spinning="pageLoading">
<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>
@if (searchExpand)
{
<AntDesign.Col>
<FormItem Label="发布时间">
<RangePicker @bind-Value="search.RangeTime"></RangePicker>
</FormItem>
</AntDesign.Col>
<AntDesign.Col>
<FormItem Label="状态">
<SimpleSelect DefaultValue="" Style="width:120px;" @bind-Value="@search.Status">
<SelectOptions>
<SimpleSelectOption Value="" Label="全部"></SimpleSelectOption>
<SimpleSelectOption Value="1" Label="草稿"></SimpleSelectOption>
<SimpleSelectOption Value="2" Label="已发布"></SimpleSelectOption>
<SimpleSelectOption Value="3" Label="已删除"></SimpleSelectOption>
</SelectOptions>
</SimpleSelect>
</FormItem>
</AntDesign.Col>
}
<Col>
<div class="ant-form-item">
<Button Type="ButtonType.Primary" HtmlType="submit">查询</Button>
<Button Style="margin: 0 8px;" OnClick="OnSearchReset">重置</Button>
<a style="font-size:12px; display:flex; align-items:center;text-align:center;" @onclick="()=>{searchExpand=!searchExpand;}">
<Icon Type="@(searchExpand?"up":"down")"></Icon> @if (searchExpand)
{
<span>收起</span>
}
else
{
<span>展开</span>
}
</a>
</div>
</Col>
</Row>
</Form>
</Card>
<Card Title="" Class="hideborder">
<Extra>
<div class="extraContent">
<Button Type="ButtonType.Primary" HtmlType="submit" OnClick="HandleAddNew">新增货币</Button>
</div>
</Extra>
<ChildContent>
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true">
<Selection CheckStrictly />
<PropertyColumn Property="c => c.Name" Title="语言" />
<PropertyColumn Property="c => c.CurrencyCode" Title="货币代码" />
<PropertyColumn Property="c => c.Rate" Title="汇率" />
<PropertyColumn Property="c => c.PrimaryCurrency" Title="默认货币">
@if (context.PrimaryCurrency)
{
<AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme="IconThemeType.Outline" /></AntDesign.Text>
}
else
{
<Icon Type="minus" Theme="IconThemeType.Outline" />
}
</PropertyColumn>
<PropertyColumn Property="c => c.Enabled" Title="状态">
@if (context.Enabled)
{
<Text>已激活</text>
}
else
{
<Text>未激活</text>
}
</PropertyColumn>
<PropertyColumn Property="c => c.DisplayOrder" Title="排序" />
<ActionColumn Title="操作" Align="ColumnAlign.Right">
<Space>
<SpaceItem>
<a @onclick="(e)=>HandleEdit(context)">编辑</a>
</SpaceItem>
@*<SpaceItem>
<Popconfirm Placement="@Placement.Left" Title="@("删除这条数据无法恢复,您确定要删除吗?")"
OnConfirm="@(e=>HandleDeleteConfirmAsync(e,context.Id))"
OkText="确定"
CancelText="取消">
<a>删除</a>
</Popconfirm>
</SpaceItem>*@
</Space>
</ActionColumn>
</Table>
<br />
<Row Justify="RowJustify.End">
<Pagination PageIndex="pager.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
</Row>
</ChildContent>
</Card>
</Spin>
</ChildContent>
</PageContainer>
@code {
[Parameter]
public string Locale { get; set; } = string.Empty;
}
[SupplyParameterFromQuery]
int? Page { get; set; }
[SupplyParameterFromQuery(Name = "size")]
int? PageSize { get; set; }
bool pageLoading = false;
bool searchExpand = false;
Form<CurrencySearchModel> searchForm = new();
CurrencySearchModel search = new();
PagingList<CurrencyModel> PagingList = new() { Size = 20 };
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
}
protected override async Task OnParametersSetAsync()
{
loadQueryString();
await LoadListAsync();
await base.OnParametersSetAsync();
}
void loadQueryString()
{
var uri = new Uri(Navigation.Uri);
var query = uri.Query;
search.Name = query.GetQueryString("Name");
search.Status = query.GetQueryString("Status");
var data = query.GetQueryString("RangeTime");
if (!string.IsNullOrEmpty(data))
{
var rangetime = data.Split("-");
if (rangetime != null && rangetime.Length > 0)
{
searchExpand = true;
search.RangeTime[0] = rangetime[0].NumberToDateTime();
search.RangeTime[1] = rangetime[1].NumberToDateTime();
StateHasChanged();
}
}
}
async Task LoadListAsync()
{
try
{
pageLoading = true;
var url = "/api/currency/search";
var apiResult = await HttpService.GetPagingList<CurrencyModel>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
if (apiResult.Success)
{
if (apiResult.Data != null)
{
PagingList = apiResult.Data;
}
}
else if (apiResult.Code == 403)
{
ModalService.Error(new ConfirmOptions() { Title = "权限不足", Content = apiResult.Message });
}
StateHasChanged();
}
finally
{
pageLoading = false;
}
}
void OnSearchReset()
{
search = new CurrencySearchModel();
searchForm?.Reset();
}
private void OnSearch(int page)
{
var queryString = search.BuildQueryString();
if (string.IsNullOrEmpty(queryString))
{
if (page > 1)
{
Navigation.NavigateTo($"/currency/list?page={page}");
}
else
{
Navigation.NavigateTo($"/currency/list");
}
}
else
{
if (page > 1)
{
Navigation.NavigateTo($"/currency/list?page={page}&{queryString}");
}
else
{
Navigation.NavigateTo($"/currency/list?{queryString}");
}
}
}
void OnSearchFinish()
{
Page = Page.GetValueOrDefault(1) - 1;
OnSearch(Page.Value);
}
private void OnPageChanged(PaginationEventArgs args)
{
OnSearch(args.Page);
}
void HandleAddNew()
{
Navigation.NavigateTo($"/currency/edit");
}
void HandleEdit(CurrencyModel model)
{
Navigation.NavigateTo($"/currency/edit/{model.Id}");
}
}

View File

@@ -0,0 +1,152 @@
@page "/system/app/version/create"
@page "/system/app/version/edit/{id:long}"
@page "/{locale}/system/app/version/create"
@page "/{locale}/system/app/version/edit/{id:long}"
@inject ILogger<AppVersionEdit> Logger
@attribute [Authorize]
<PageContainer Title="@(Id > 0 ? "编辑版本信息" : "新增版本信息")">
<Breadcrumb>
<Breadcrumb>
<BreadcrumbItem Href="/">管理后台</BreadcrumbItem>
<BreadcrumbItem Href="/admin/list">系统功能</BreadcrumbItem>
<BreadcrumbItem>版本管理</BreadcrumbItem>
</Breadcrumb>
</Breadcrumb>
<ChildContent>
<Spin Spinning="pageLoading">
<Card Title="版本信息">
<Form @ref="editform" Model="@model" LabelColSpan="5" WrapperColSpan="14" OnFinish="OnFormFinishAsync">
<FormItem Label="应用名称" Required>
<Input @bind-Value="@context.AppName" Placeholder="应用名称" />
</FormItem>
<FormItem Label="版本标题" Required>
<Input @bind-Value="@context.Title" Placeholder="版本标题" />
</FormItem>
<FormItem Label="运行平台">
<Select TItemValue="int" TItem="int" Style="width:250px;" @bind-Value="@context.Platform">
<SelectOption Value="0" Label="请选择运行平台"></SelectOption>
<SelectOption Value="1" Label="Windows桌面"></SelectOption>
<SelectOption Value="2" Label="安卓系统"></SelectOption>
<SelectOption Value="3" Label="iOS系统"></SelectOption>
</Select>
</FormItem>
<FormItem Label="版本状态">
<Select TItemValue="int" TItem="int" Style="width:250px;" @bind-Value="@context.VersionState">
<SelectOption Value="0" Label="请选版本状态"></SelectOption>
<SelectOption Value="1" Label="开发版"></SelectOption>
<SelectOption Value="2" Label="Alphal内测版"></SelectOption>
<SelectOption Value="3" Label="Beta公测版"></SelectOption>
<SelectOption Value="4" Label="Rc版"></SelectOption>
<SelectOption Value="5" Label="正式版"></SelectOption>
</Select>
</FormItem>
<FormItem Label="版本信息" Required>
<InputGroup Compact>
<Input @bind-Value="@context.VersionX" Placeholder="主版本号" Style="width: 20%;" />
<Input @bind-Value="@context.VersionY" Placeholder="次版本号" Style="width: 20%;" />
<Input @bind-Value="@context.VersionZ" Placeholder="修订版本" Style="width: 20%;" />
</InputGroup>
</FormItem>
<FormItem Label="更新内容" Required>
<TextArea Rows="10" @bind-Value="@context.Content" Placeholder="更新内容" />
</FormItem>
<FormItem Label="状态">
<RadioGroup @bind-Value="@context.Status">
<Radio RadioButton Value=1>草稿</Radio>
<Radio RadioButton Value=2>发布</Radio>
</RadioGroup>
</FormItem>
<FormItem WrapperCol="new ColLayoutParam { Span = 24, Offset = 5 }">
<Button Type="@ButtonType.Primary" HtmlType="submit">
提交保存
</Button>
</FormItem>
</Form>
</Card>
</Spin>
</ChildContent>
</PageContainer>
@code {
[Parameter]
public string Locale { get; set; } = string.Empty;
[Parameter]
public long Id { get; set; }
[SupplyParameterFromForm]
AppVersionModel model { get; set; } = new();
Form<AppVersionModel> editform = null!;
bool pageLoading = false;
protected override void OnInitialized()
{
base.OnInitialized();
}
protected override void OnParametersSet()
{
if (Id > 0)
{
LoadData();
}
base.OnParametersSet();
}
async void LoadData()
{
pageLoading = true;
var url = $"/api/appversion/{Id}";
var apiResult = await HttpService.Get<ApiResult<AppVersion>>(url);
if (apiResult.Success)
{
if (apiResult.Data == null)
{
Navigation.NavigateTo($"/system/app/version/create");
}
else
{
model = apiResult.Data.Adapt<AppVersionModel>();
}
}
else
{
Navigation.NavigateTo($"/system/app/version/create");
}
pageLoading = false;
StateHasChanged();
}
async void OnFormFinishAsync()
{
if (editform.Validate())
{
var result = new ApiResult<string>();
if (model.Id > 0)
{
var url = $"api/appversion/edit";
result = await HttpService.Post<ApiResult<string>>(url, model);
}
else
{
var url = $"api/appversion/add";
result = await HttpService.Post<ApiResult<string>>(url, model);
}
if (result.Code == (int)ResultCode.Success)
{
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
Navigation.NavigateTo($"/system/app/version/list");
}
else
{
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });
}
}
}
}

View File

@@ -17,19 +17,19 @@
<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 Label="名称">
<Input @bind-Value="search.Name" Placeholder="名称" AllowClear />
</FormItem>
</Col>
<Col>
<FormItem Label="状态">
@* <SimpleSelect DefaultValue="" @bind-Value="search.Status">
<SimpleSelect DefaultValue="" Style="width:120px;" @bind-Value="@context.Status">
<SelectOptions>
<SimpleSelectOption Value="">全部</SimpleSelectOption>
<SimpleSelectOption Value="1">启用</SimpleSelectOption>
<SimpleSelectOption Value="0">禁用</SimpleSelectOption>
<SimpleSelectOption Value="" Label="全部"></SimpleSelectOption>
<SimpleSelectOption Value="1" Label="草稿"></SimpleSelectOption>
<SimpleSelectOption Value="2" Label="已发布"></SimpleSelectOption>
</SelectOptions>
</SimpleSelect> *@
</SimpleSelect>
</FormItem>
</Col>
<Col>
@@ -46,7 +46,7 @@
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true" Resizable>
<TitleTemplate>
<Flex Justify="FlexJustify.SpaceBetween">
帐号列表
版本记录
<div>
<AuthorizeCheck Permission="@Permissions.Admin.Create">
<Button Class="me-3" OnClick="OnCreateClick" Type="ButtonType.Primary">新增</Button>
@@ -110,11 +110,11 @@
<PropertyColumn Property="c => c.Status" Title="状态" Width="80px" Align="ColumnAlign.Center">
@if (context.Status == 1)
{
<Tag T="string" Size="Size.Small" Variant="Variant.Text">草稿</Tag>
<Tag>草稿</Tag>
}
else if (context.Status == 2)
{
<Tag T="string" Size="Size.Small" Variant="Variant.Text">发布</Tag>
<Tag>发布</Tag>
}
else
{