-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:add masa blazor web for imaotai
- Loading branch information
1 parent
7155367
commit eba509d
Showing
48 changed files
with
2,541 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<appSettings> | ||
<!--是否启用本地文件存储 如果LocalFile:0/禁用,1/启用 则不使用数据库--> | ||
<add key="LoadFromFile" value="1"/> | ||
<add key="DbType" value="MySql"/> | ||
<add key="DefaultConnStr" value="server=localhost;database=imaotai;user=root;password=root;port=3306;"/> | ||
</appSettings> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<base href="/" /> | ||
<link href="_content/Masa.Blazor/css/masa-blazor.min.css" rel="stylesheet" /> | ||
<link rel="stylesheet" href="css/app.css" /> | ||
<link rel="stylesheet" href="IMaoTai.MasaBlazor.styles.css" /> | ||
<link href="css/materialdesign/v7.1.96/css/materialdesignicons.min.css" rel="stylesheet"> | ||
<link rel="icon" type="image/png" href="favicon.png" /> | ||
<HeadOutlet @rendermode="@InteractiveServer" /> | ||
</head> | ||
|
||
<body> | ||
<Routes @rendermode="@InteractiveServer" /> | ||
<script src="_framework/blazor.web.js"></script> | ||
<script src="_content/Masa.Blazor/js/masa-blazor.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@inherits LayoutComponentBase | ||
|
||
<MApp> | ||
<NavMenu /> | ||
<MMain> | ||
<MContainer Fluid> | ||
@Body | ||
</MContainer> | ||
</MMain> | ||
</MApp> | ||
|
||
<div id="blazor-error-ui" data-nosnippet> | ||
An unhandled error has occurred. | ||
<a href="." class="reload">Reload</a> | ||
<span class="dismiss">🗙</span> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#blazor-error-ui { | ||
background: lightyellow; | ||
bottom: 0; | ||
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); | ||
box-sizing: border-box; | ||
display: none; | ||
left: 0; | ||
padding: 0.6rem 1.25rem 0.7rem 1.25rem; | ||
position: fixed; | ||
width: 100%; | ||
z-index: 1000; | ||
} | ||
|
||
#blazor-error-ui .dismiss { | ||
cursor: pointer; | ||
position: absolute; | ||
right: 0.75rem; | ||
top: 0.5rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<MAppBar App> | ||
<MAppBarNavIcon @onclick="() => _drawer = !_drawer"></MAppBarNavIcon> | ||
<MToolbarTitle>i茅台预约助手</MToolbarTitle> | ||
<MSpacer></MSpacer> | ||
</MAppBar> | ||
|
||
<MNavigationDrawer App @bind-Value="_drawer"> | ||
<MList Nav Routable> | ||
<MListItem Href="/" ActiveClass="primary--text"> | ||
<MListItemIcon> | ||
<MIcon>mdi-home</MIcon> | ||
</MListItemIcon> | ||
<MListItemContent> | ||
<MListItemTitle>Home</MListItemTitle> | ||
</MListItemContent> | ||
</MListItem> | ||
<MListItem Href="/userData" ActiveClass="primary--text"> | ||
<MListItemIcon> | ||
<MIcon>mdi-plus</MIcon> | ||
</MListItemIcon> | ||
<MListItemContent> | ||
<MListItemTitle>用户管理</MListItemTitle> | ||
</MListItemContent> | ||
</MListItem> | ||
<MListItem Href="/productdata" ActiveClass="primary--text"> | ||
<MListItemIcon> | ||
<MIcon>mdi-list-box</MIcon> | ||
</MListItemIcon> | ||
<MListItemContent> | ||
<MListItemTitle>预约商品管理</MListItemTitle> | ||
</MListItemContent> | ||
</MListItem> | ||
<MListItem Href="/shopdata" ActiveClass="primary--text"> | ||
<MListItemIcon> | ||
<MIcon>mdi-list-box</MIcon> | ||
</MListItemIcon> | ||
<MListItemContent> | ||
<MListItemTitle>店铺管理</MListItemTitle> | ||
</MListItemContent> | ||
</MListItem> | ||
<MListItem Href="/logdata" ActiveClass="primary--text"> | ||
<MListItemIcon> | ||
<MIcon>mdi-list-box</MIcon> | ||
</MListItemIcon> | ||
<MListItemContent> | ||
<MListItemTitle>日志管理</MListItemTitle> | ||
</MListItemContent> | ||
</MListItem> | ||
</MList> | ||
</MNavigationDrawer> | ||
|
||
@code { | ||
|
||
private bool? _drawer; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
@page "/Error" | ||
@using System.Diagnostics | ||
|
||
<PageTitle>Error</PageTitle> | ||
|
||
<h1 class="text-danger">Error.</h1> | ||
<h2 class="text-danger">An error occurred while processing your request.</h2> | ||
|
||
@if (ShowRequestId) | ||
{ | ||
<p> | ||
<strong>Request ID:</strong> <code>@RequestId</code> | ||
</p> | ||
} | ||
|
||
<h3>Development Mode</h3> | ||
<p> | ||
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred. | ||
</p> | ||
<p> | ||
<strong>The Development environment shouldn't be enabled for deployed applications.</strong> | ||
It can result in displaying sensitive information from exceptions to end users. | ||
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong> | ||
and restarting the app. | ||
</p> | ||
|
||
@code{ | ||
[CascadingParameter] | ||
private HttpContext? HttpContext { get; set; } | ||
|
||
private string? RequestId { get; set; } | ||
private bool ShowRequestId => !string.IsNullOrEmpty(RequestId); | ||
|
||
protected override void OnInitialized() => | ||
RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@page "/" | ||
@using Masa.Blazor | ||
|
||
<MImage AspectRatio="16/9d" Width="931" Height="311" | ||
Src="/imgs/home.png"></MImage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
@page "/logData" | ||
@using IMaoTai.Core.Entity | ||
@using IMaoTai.Core.Domain | ||
@inject IMaoTai.Core.Service.ILogService LogService | ||
|
||
<PageTitle>日志管理</PageTitle> | ||
|
||
<h1>日志管理</h1> | ||
|
||
@if (_logList == null) | ||
{ | ||
<p><em>Loading...</em></p> | ||
} | ||
else | ||
{ | ||
<MCard> | ||
<MCardTitle> | ||
查询条件 | ||
<MSpacer></MSpacer> | ||
<MTextField @bind-Value="_search.Mobile" | ||
Label="手机号" | ||
SingleLine | ||
HideDetails="true"></MTextField> | ||
<MTextField @bind-Value="_search.Status" | ||
Label="状态" | ||
SingleLine | ||
HideDetails="true"></MTextField> | ||
<MTextField @bind-Value="_search.SearchContent" | ||
Label="模糊匹配日志的内容" | ||
SingleLine | ||
HideDetails="true"></MTextField> | ||
|
||
</MCardTitle> | ||
<MRow Align="@AlignTypes.Center" | ||
Justify="@JustifyTypes.Center"> | ||
<MToolbar> | ||
<MButton Depressed Color="primary" | ||
Dark | ||
OnClick="GetListDataFromApi"> | ||
搜索 | ||
</MButton> | ||
<MButton Depressed Color="primary" | ||
Dark | ||
OnClick="ClearSearch"> | ||
重置 | ||
</MButton> | ||
<MButton Depressed Color="primary" | ||
Dark | ||
OnClick="DeleteAll"> | ||
清空日志 | ||
</MButton> | ||
</MToolbar> | ||
</MRow> | ||
<MDataTable Headers="_headers" DisableFiltering | ||
Items="_logList" | ||
Id="Id" ItemKey="(a)=>{ return a.Id.ToString(); }" | ||
ShowSelect="true" | ||
Page="@_page" | ||
ItemsPerPage="@_itemsPerPage" | ||
OnOptionsUpdate="@HandleOnOptionsUpdate" | ||
ServerItemsLength="@_total" | ||
Loading="_loading" | ||
Class="elevation-1"> | ||
<ItemColContent> | ||
@context.Value | ||
</ItemColContent> | ||
<NoDataContent> | ||
暂无数据....... | ||
</NoDataContent> | ||
</MDataTable> | ||
</MCard> | ||
|
||
} | ||
|
||
@code { | ||
private List<LogEntity> _logList = new List<LogEntity>(); | ||
private LogListViewModel _search = new LogListViewModel(); | ||
private int _total; | ||
private bool _loading = true; | ||
private int _itemsPerPage = 10; | ||
private int _page = 1; | ||
private DataOptions _options = new(1, 10); | ||
|
||
private List<DataTableHeader<LogEntity>> _headers = new() | ||
{ | ||
new() { Text = "日志ID", Value = nameof(LogEntity.Id) }, | ||
new() { Text = "手机号", Value = nameof(LogEntity.MobilePhone) }, | ||
new() { Text = "状态", Value = nameof(LogEntity.Status) }, | ||
new() { Text = "日志内容", Value = nameof(LogEntity.Content),Ellipsis = new DataTableEllipsis() }, | ||
new() { Text = "响应信息", Value = nameof(LogEntity.Response),Ellipsis = new DataTableEllipsis() }, | ||
new() { Text = "操作日期", Value = nameof(LogEntity.CreateTime) }, | ||
}; | ||
|
||
public void ClearSearch() | ||
{ | ||
_search = new(); | ||
_options.Page = 1; | ||
} | ||
|
||
public async Task DeleteAll() | ||
{ | ||
_options.Page = 1; | ||
await LogService.DeleteAll(); | ||
StateHasChanged(); | ||
} | ||
|
||
|
||
private async Task HandleOnOptionsUpdate(DataOptions options) | ||
{ | ||
_options = options; | ||
await GetListDataFromApi(); | ||
} | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
await GetListDataFromApi(); | ||
} | ||
|
||
protected override async Task OnAfterRenderAsync(bool firstRender) | ||
{ | ||
if (firstRender) | ||
{ | ||
await GetListDataFromApi(); | ||
StateHasChanged(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// 获取列表信息 | ||
/// </summary> | ||
/// <returns></returns> | ||
private async Task GetListDataFromApi() | ||
{ | ||
_loading = true; | ||
_search.Current = _options.Page; | ||
_search.PageSize = _options.ItemsPerPage; | ||
var result = await LogService.GetList(_search); | ||
_logList = result.LogList; | ||
_total = Convert.ToInt32(result.Total); | ||
_loading = false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
@page "/productdata" | ||
@using IMaoTai.Core.Entity | ||
@using IMaoTai.Core.Domain | ||
@inject IMaoTai.Core.Service.IAppointProjectService AppointProjectService | ||
|
||
<PageTitle>预约商品管理</PageTitle> | ||
<h1>预约商品管理</h1> | ||
@if (_productList == null) | ||
{ | ||
<p><em>Loading...</em></p> | ||
} | ||
else | ||
{ | ||
<MCard> | ||
<MRow Align="@AlignTypes.Center" | ||
Justify="@JustifyTypes.Center"> | ||
<MToolbar> | ||
<MButton Depressed Color="primary" | ||
Dark | ||
OnClick="GetProductListDataFromApi"> | ||
刷新商品 | ||
</MButton> | ||
</MToolbar> | ||
</MRow> | ||
<MDataTable Headers="_headers" Items="_productList" ItemsPerPage="5"> | ||
<ItemColContent> | ||
@if (context.Header.Value == nameof(ProductEntity.Img)) | ||
{ | ||
<img src="@context.Item.Img" width="80" height="80" /> | ||
} | ||
else if (context.Header.Value == nameof(ProductEntity.PictureV2)) | ||
{ | ||
<img src="@context.Item.PictureV2" width="80" height="80" /> | ||
} | ||
else | ||
{ | ||
@context.Value | ||
} | ||
</ItemColContent> | ||
</MDataTable> | ||
</MCard> | ||
} | ||
|
||
@code { | ||
private List<ProductEntity> _productList = new List<ProductEntity>(); | ||
|
||
private List<DataTableHeader<ProductEntity>> _headers = new() | ||
{ | ||
new() { Text = "商品Code", Value = nameof(ProductEntity.Code) }, | ||
new() { Text = "标题", Value = nameof(ProductEntity.Title) }, | ||
new() { Text = "内容", Value = nameof(ProductEntity.Description),Ellipsis = new DataTableEllipsis() }, | ||
new() { Text = "主图片", Value = nameof(ProductEntity.Img) }, | ||
new() { Text = "副图片", Value = nameof(ProductEntity.PictureV2) }, | ||
new() { Text = "创建时间", Value = nameof(ProductEntity.Created)} | ||
}; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
_productList = AppointProjectViewModel.ProductList; | ||
await Task.CompletedTask; | ||
} | ||
|
||
private async Task GetProductListDataFromApi() | ||
{ | ||
await AppointProjectService.RefreshProduct(); | ||
_productList = AppointProjectViewModel.ProductList; | ||
StateHasChanged(); | ||
} | ||
} |
Oops, something went wrong.