1
This commit is contained in:
25
Components/App.razor
Normal file
25
Components/App.razor
Normal file
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<base href="/" />
|
||||
<link rel="stylesheet" href="bootstrap/bootstrap.min.css" />
|
||||
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
|
||||
<link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" />
|
||||
|
||||
<link rel="stylesheet" href="app.css" />
|
||||
|
||||
<link rel="icon" type="image/png" href="favicon.ico" />
|
||||
<HeadOutlet />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<Routes @rendermode=RenderMode.InteractiveServer />
|
||||
<script src="_framework/blazor.web.js"></script>
|
||||
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
42
Components/Layout/MainLayout.razor
Normal file
42
Components/Layout/MainLayout.razor
Normal file
@@ -0,0 +1,42 @@
|
||||
@inherits LayoutComponentBase
|
||||
|
||||
<MudThemeProvider @bind-IsDarkMode="@_isDarkMode"/>
|
||||
<MudLayout>
|
||||
<MudAppBar Color="Color.Transparent" Fixed="true" Elevation="0">
|
||||
@* <MudToggleIconButton @bind-Toggled="_drawerOpen" *@
|
||||
@* Icon="@Icons.Material.Filled.Menu" *@
|
||||
@* ToggledIcon="@Icons.Material.Filled.Menu" *@
|
||||
@* Color="Color.Inherit" Edge="Edge.Start" /> *@
|
||||
<MudImage Src="images/header-logo.png" Width="256"></MudImage>
|
||||
<MudSpacer />
|
||||
<MudToggleIconButton @bind-Toggled="@_isDarkMode"
|
||||
Icon="@Icons.Material.Filled.DarkMode"
|
||||
ToggledIcon="@Icons.Material.Filled.LightMode"
|
||||
Color="Color.Default"
|
||||
ToggledColor="Color.Default"
|
||||
/>
|
||||
<MudIconButton Icon="@Icons.Custom.Brands.GitHub" Color="Color.Inherit" />
|
||||
</MudAppBar>
|
||||
<MudDrawer Color="Color.Transparent" @bind-Open="_drawerOpen" ClipMode="DrawerClipMode.Always" Elevation="0">
|
||||
@* <MudDrawerHeader> *@
|
||||
@* <MudText Typo="Typo.h6">导航</MudText> *@
|
||||
@* </MudDrawerHeader> *@
|
||||
<NavMenu/>
|
||||
</MudDrawer>
|
||||
<MudMainContent Class="mt-16 pa-4">
|
||||
@Body
|
||||
</MudMainContent>
|
||||
</MudLayout>
|
||||
|
||||
<MudDialogProvider/>
|
||||
<MudSnackbarProvider/>
|
||||
|
||||
@code {
|
||||
private bool _drawerOpen = true;
|
||||
private bool _isDarkMode = false;
|
||||
|
||||
private void DrawerToggle()
|
||||
{
|
||||
_drawerOpen = !_drawerOpen;
|
||||
}
|
||||
}
|
6
Components/Layout/NavMenu.razor
Normal file
6
Components/Layout/NavMenu.razor
Normal file
@@ -0,0 +1,6 @@
|
||||
<MudNavMenu Dense="true" Class="pa-4" Rounded="true" Color="Color.Info">
|
||||
<MudNavLink Href="" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.PlayCircleOutline">主页</MudNavLink>
|
||||
<MudNavLink Href="/query" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Outlined.DataObject">解析标识</MudNavLink>
|
||||
<MudNavLink Href="template/register" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Outlined.AppRegistration">注册标识模板</MudNavLink>
|
||||
<MudNavLink Href="/register" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Outlined.Assignment">注册标识</MudNavLink>
|
||||
</MudNavMenu>
|
13
Components/Pages/Auth.razor
Normal file
13
Components/Pages/Auth.razor
Normal file
@@ -0,0 +1,13 @@
|
||||
@page "/auth"
|
||||
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
|
||||
@attribute [Authorize]
|
||||
|
||||
<PageTitle>Auth</PageTitle>
|
||||
|
||||
<h1>You are authenticated</h1>
|
||||
|
||||
<AuthorizeView>
|
||||
Hello @context.User.Identity?.Name!
|
||||
</AuthorizeView>
|
20
Components/Pages/Counter.razor
Normal file
20
Components/Pages/Counter.razor
Normal file
@@ -0,0 +1,20 @@
|
||||
@page "/counter"
|
||||
|
||||
<MudPopoverProvider />
|
||||
<MudDialogProvider />
|
||||
<MudSnackbarProvider />
|
||||
|
||||
<PageTitle>Counter</PageTitle>
|
||||
|
||||
<MudText Typo="Typo.h3" GutterBottom="true">Counter</MudText>
|
||||
<MudText Class="mb-4">Current count: @currentCount</MudText>
|
||||
<MudButton Color="Color.Primary" Variant="Variant.Filled" @onclick="IncrementCount">Click me</MudButton>
|
||||
|
||||
@code {
|
||||
private int currentCount = 0;
|
||||
|
||||
private void IncrementCount()
|
||||
{
|
||||
currentCount++;
|
||||
}
|
||||
}
|
36
Components/Pages/Error.razor
Normal file
36
Components/Pages/Error.razor
Normal file
@@ -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;
|
||||
}
|
75
Components/Pages/Home.razor
Normal file
75
Components/Pages/Home.razor
Normal file
@@ -0,0 +1,75 @@
|
||||
@page "/"
|
||||
|
||||
<PageTitle>主页</PageTitle>
|
||||
|
||||
|
||||
<MudText Typo="Typo.h3" GutterBottom="true" Color="Color.Default">你好,<MudLink Href="https://www.idfactory.cn/" Typo="Typo.h3">工业互联网标识</MudLink></MudText>
|
||||
<MudText Class="mb-8">欢迎来到工业互联网标识解析Web端,有什么你想了解的么?</MudText>
|
||||
|
||||
<MudAlert Severity="Severity.Normal">
|
||||
你可以找到一些文档和案例,从
|
||||
<MudLink Href="http://server.bitfall.icu:3000/root/iFactory.Godot/src/branch/main/ReadMe/%E5%B7%A5%E4%B8%9A%E4%BA%92%E8%81%94%E7%BD%91%E6%A0%87%E8%AF%86%E8%A7%A3%E6%9E%90%E4%B8%8E%E6%B3%A8%E5%86%8C/%E6%A0%87%E8%AF%86%E8%A7%A3%E6%9E%90%E6%AD%A5%E9%AA%A4.md" Target="_blank" Typo="Typo.body2" Color="Color.Primary">
|
||||
<b>iFactory 文档中心</b>
|
||||
</MudLink>
|
||||
</MudAlert>
|
||||
|
||||
<br />
|
||||
<MudText Typo="Typo.h5" GutterBottom="true">这里有些什么呢?</MudText>
|
||||
<br />
|
||||
<MudText Typo="Typo.body2">
|
||||
基于IDIS_Runtime的一些实现 <br />
|
||||
可以在Web端完成一些手动注册与解析的操作<br />
|
||||
通常这些操作会由相关的生产系统自动化解析<br />
|
||||
<br />
|
||||
你可以在<AppBar>的右上角切换夜间模式<br />
|
||||
如果你觉得暗色主题更好的话<br />
|
||||
<br />
|
||||
</MudText>
|
||||
|
||||
|
||||
@* <br /> *@
|
||||
@* <MudText Typo="Typo.h5" GutterBottom="true">此模板中的交互性</MudText> *@
|
||||
@* <br /> *@
|
||||
@* <MudText Typo="Typo.body2"> *@
|
||||
@* When you opt for the "Global" Interactivity Location, <br /> *@
|
||||
@* the render modes are defined in App.razor and consequently apply to all child components.<br /> *@
|
||||
@* In this case, providers are globally set in the MainLayout.<br /> *@
|
||||
@* <br /> *@
|
||||
@* On the other hand, if you choose the "Per page/component" Interactivity Location,<br /> *@
|
||||
@* it is necessary to include the <br /> *@
|
||||
@* <br /> *@
|
||||
@* <MudPopoverProvider /> <br /> *@
|
||||
@* <MudDialogProvider /> <br /> *@
|
||||
@* <MudSnackbarProvider /> <br /> *@
|
||||
@* <br /> *@
|
||||
@* components on every interactive page.<br /> *@
|
||||
@* <br /> *@
|
||||
@* If a render mode is not specified for a page, it defaults to Server-Side Rendering (SSR),<br /> *@
|
||||
@* similar to this page. While MudBlazor allows pages to be rendered in SSR,<br /> *@
|
||||
@* please note that interactive features, such as buttons and dropdown menus, will not be functional. *@
|
||||
@* </MudText> *@
|
||||
@* *@
|
||||
@* <br /> *@
|
||||
@* <MudText Typo="Typo.h5" GutterBottom="true">What's New in Blazor with the Release of .NET 8</MudText> *@
|
||||
@* <br /> *@
|
||||
@* <MudText Typo="Typo.h6" GutterBottom="true">Prerendering</MudText> *@
|
||||
@* <MudText Typo="Typo.body2" GutterBottom="true"> *@
|
||||
@* If you're exploring the features of .NET 8 Blazor,<br /> you might be pleasantly surprised to learn that each page is prerendered on the server,<br /> regardless of the selected render mode.<br /><br /> *@
|
||||
@* This means that you'll need to inject all necessary services on the server,<br /> even when opting for the wasm (WebAssembly) render mode.<br /><br /> *@
|
||||
@* This prerendering functionality is crucial to ensuring that WebAssembly mode feels fast and responsive,<br /> especially when it comes to initial page load times.<br /><br /> *@
|
||||
@* For more information on how to detect prerendering and leverage the RenderContext, you can refer to the following link: *@
|
||||
@* <MudLink Href="https://github.com/dotnet/aspnetcore/issues/51468#issuecomment-1783568121" Target="_blank" Typo="Typo.body2" Color="Color.Primary"> *@
|
||||
@* More details *@
|
||||
@* </MudLink> *@
|
||||
@* </MudText> *@
|
||||
@* *@
|
||||
@* <br /> *@
|
||||
@* <MudText Typo="Typo.h6" GutterBottom="true">InteractiveAuto</MudText> *@
|
||||
@* <MudText Typo="Typo.body2"> *@
|
||||
@* A discussion on how to achieve this can be found here: *@
|
||||
@* <MudLink Href="https://github.com/dotnet/aspnetcore/issues/51468#issue-1950424116" Target="_blank" Typo="Typo.body2" Color="Color.Primary"> *@
|
||||
@* More details *@
|
||||
@* </MudLink> *@
|
||||
@* </MudText> *@
|
||||
|
||||
|
70
Components/Pages/Query.razor
Normal file
70
Components/Pages/Query.razor
Normal file
@@ -0,0 +1,70 @@
|
||||
@page "/Query"
|
||||
@inject IDIS_Service service
|
||||
@inject IDIS_TemplateService templateService
|
||||
@inject ISnackbar snackbar
|
||||
@using IDIS.Models
|
||||
@using IDIS.Services
|
||||
<MudText Typo="Typo.h3" GutterBottom="true">解析标识</MudText>
|
||||
<MudStack>
|
||||
<MudTextField
|
||||
@bind-Value="@handle"
|
||||
HelperText="例如:88.123.99/202402051710"
|
||||
Label="Normal"
|
||||
Variant="Variant.Outlined"
|
||||
Adornment="Adornment.End"
|
||||
AdornmentIcon="@Icons.Material.Filled.Search"
|
||||
OnAdornmentClick="QueryInternal"
|
||||
/>
|
||||
<MudAlert Severity="@severity">@currentMessage</MudAlert>
|
||||
@if (queryData.Value.Length is not 0)
|
||||
{
|
||||
<MudPaper Class="pa-2">
|
||||
<MudStack Spacing="2">
|
||||
|
||||
@for (var index = 0; index < queryData.Value.Length; index++)
|
||||
{
|
||||
var x = queryData.Value[index];
|
||||
var templateItem = template.Items[index];
|
||||
<MudGrid Class="align-center">
|
||||
<MudItem>
|
||||
<MudIcon Icon="@Icons.Material.Outlined.Info"/>
|
||||
</MudItem>
|
||||
<MudItem Style="min-width: 100px">
|
||||
<MudText >@templateItem.Name</MudText>
|
||||
</MudItem>
|
||||
<MudItem>
|
||||
<MudText>@x.Data.Value</MudText>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
}
|
||||
</MudStack >
|
||||
</MudPaper>
|
||||
}
|
||||
</MudStack>
|
||||
@code {
|
||||
private string handle { get; set; }
|
||||
private IDIS_Query_Data queryData { get; set; }= new IDIS_Query_Data();
|
||||
private IDIS_Template template { get; set; } = new IDIS_Template();
|
||||
private string currentMessage { get; set; } = "从解析一个标识开始";
|
||||
private Severity severity { get; set; } = Severity.Normal;
|
||||
private async void QueryInternal()
|
||||
{
|
||||
try
|
||||
{
|
||||
currentMessage = "正在查询";
|
||||
severity = Severity.Info;
|
||||
queryData = await service.QueryAsync(handle);
|
||||
template = await templateService.QueryAsync(queryData.Prefix,queryData.TemplateVersion);
|
||||
|
||||
currentMessage = "查询成功";
|
||||
severity = Severity.Success;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
currentMessage = e.Message;
|
||||
severity = Severity.Error;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
150
Components/Pages/Register.razor
Normal file
150
Components/Pages/Register.razor
Normal file
@@ -0,0 +1,150 @@
|
||||
@page "/register"
|
||||
@using IDIS.Services
|
||||
@using IDIS.Models
|
||||
@using Cysharp.Threading.Tasks
|
||||
@using BITKit
|
||||
@using System.Text.RegularExpressions
|
||||
@using System.ComponentModel
|
||||
@inject ILogger<TemlateRegister> logger
|
||||
@inject ISnackbar Snackbar
|
||||
@inject IDIS_TemplateService templateService
|
||||
@inject IDIS_Service service
|
||||
@inherits OwningComponentBase
|
||||
<MudText Typo="Typo.h3" GutterBottom="true">注册标识</MudText>
|
||||
<MudText>当我们创建标识模板后<br/>我们就可以通过标识模板快速注册标识</MudText>
|
||||
<MudGrid>
|
||||
<MudItem xs="3">
|
||||
<div class="d-flex flex-grow-1 gap-4 py-2">
|
||||
<MudText Class="flex-1 d-flex" Typo="Typo.h6">选择标识模板</MudText>
|
||||
<MudButton Class="d-flex" Variant="Variant.Outlined" OnClick="() => Refresh().Forget()">刷新</MudButton>
|
||||
</div>
|
||||
@if (templates.Length is 0)
|
||||
{
|
||||
<MudAlert Severity="Severity.Normal">模板为空</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudStack>
|
||||
@foreach (var item in templates)
|
||||
{
|
||||
<MudButton
|
||||
Class="pa-2"
|
||||
Variant="Variant.Outlined"
|
||||
OnClick="() => SelectTemplate(item)">
|
||||
@(item.Prefix)/@(item.Version)
|
||||
</MudButton>
|
||||
}
|
||||
</MudStack>
|
||||
}
|
||||
</MudItem>
|
||||
<MudItem xs="1">
|
||||
</MudItem>
|
||||
<MudItem xs="8">
|
||||
<MudStack>
|
||||
<MudText Typo="Typo.h6">模板信息</MudText>
|
||||
<MudStack Row="true">
|
||||
<MudAutocomplete Disabled="true" T="string" Label="国家" @bind-Value="prefix_c" SearchFunc="@Search1"
|
||||
CoerceText="true" CoerceValue="true" />
|
||||
<MudAutocomplete Disabled="true" T="string" Label="区域" @bind-Value="prefix_p" SearchFunc="@Search1"
|
||||
CoerceText="true" CoerceValue="true"/>
|
||||
<MudAutocomplete Disabled="true" T="string" Label="企业" @bind-Value="prefix_e" SearchFunc="@Search1"
|
||||
CoerceText="true" CoerceValue="true"/>
|
||||
<MudTextField
|
||||
@bind-Value="@handle_code"
|
||||
HelperText="点击右侧图标生成标识"
|
||||
Label="标识值"
|
||||
Variant="Variant.Text"
|
||||
Adornment="Adornment.End"
|
||||
AdornmentIcon="@Icons.Material.Filled.Refresh"
|
||||
OnAdornmentClick="GenerateHandle"/>
|
||||
</MudStack>
|
||||
|
||||
<MudText Typo="Typo.h6">注册值</MudText>
|
||||
<MudStack Spacing="0">
|
||||
@for(var index=0;index<_valueInfo.Length;index++)
|
||||
{
|
||||
var registerInfo = _valueInfo[index];
|
||||
var templateInfo = this.template.Items[index];
|
||||
<MudTextField bind-Value="@registerInfo.Data.Value" HelperText="@templateInfo.IdType" T="string" Counter="25" Immediate="true" Label="@templateInfo.Name" Variant="Variant.Text" />
|
||||
}
|
||||
@foreach (var x in _valueInfo)
|
||||
{
|
||||
}
|
||||
</MudStack>
|
||||
<div class="d-flex">
|
||||
<MudButton Class="d-flex flex-grow-1" Variant="Variant.Outlined" OnClick="Reg">注册标识:@handle</MudButton>
|
||||
</div>
|
||||
</MudStack>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
@code {
|
||||
private IDIS_Template[] templates = Array.Empty<IDIS_Template>();
|
||||
private IDIS_Template template = new IDIS_Template();
|
||||
|
||||
private IDIS_Register_Data.ValueInfo[] _valueInfo { get; set; } = Array.Empty<IDIS_Register_Data.ValueInfo>();
|
||||
private string prefix_c { get; set; } = "88";
|
||||
private string prefix_p { get; set; } = "123";
|
||||
private string prefix_e { get; set; } = "99";
|
||||
private string handle_code { get; set; } = DateTime.Now.Ticks.ToString();
|
||||
private string handle=> $"{prefix_c}.{prefix_p}.{prefix_e}/{handle_code}";
|
||||
|
||||
async UniTask Refresh()
|
||||
{
|
||||
Snackbar.Add("正在刷新模板");
|
||||
templates = await templateService.ToArrayAsync();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
Snackbar.Add("模板刷新完成");
|
||||
}
|
||||
private void GenerateHandle()
|
||||
{
|
||||
handle_code = DateTime.Now.Ticks.ToString();
|
||||
}
|
||||
private void SelectTemplate(IDIS_Template newValue)
|
||||
{
|
||||
template = newValue;
|
||||
_valueInfo = new IDIS_Register_Data.ValueInfo[template.Items.Length];
|
||||
for (var index = 0; index < template.Items.Length; index++)
|
||||
{
|
||||
var x = template.Items[index];
|
||||
var info = new IDIS_Register_Data.ValueInfo
|
||||
{
|
||||
Type = x.Name,
|
||||
Index = index,
|
||||
Data = new IDIS_Register_Data.ValueData()
|
||||
{
|
||||
Format = x.MetaData.Type,
|
||||
Value = string.Empty
|
||||
}
|
||||
};
|
||||
_valueInfo[index] = info;
|
||||
}
|
||||
}
|
||||
|
||||
private async void Reg()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Regex.IsMatch(handle, IDIS_Code.AddressRegex) is false)
|
||||
{
|
||||
throw new Exception($"标识格式错误,正则表达式为{IDIS_Code.AddressRegex}");
|
||||
}
|
||||
await service.RegisterAsync(handle, template.Version, _valueInfo);
|
||||
Snackbar.Add("注册成功");
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Snackbar.Add(e.Message, Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<string>> Search1(string arg)
|
||||
{
|
||||
await UniTask.Yield();
|
||||
return new List<string>()
|
||||
{
|
||||
"88","123","99"
|
||||
};
|
||||
}
|
||||
|
||||
}
|
140
Components/Pages/TemlateRegister.razor
Normal file
140
Components/Pages/TemlateRegister.razor
Normal file
@@ -0,0 +1,140 @@
|
||||
@page "/template/register"
|
||||
@using IDIS.Services
|
||||
@using IDIS.Models
|
||||
@using Cysharp.Threading.Tasks
|
||||
@using BITKit
|
||||
@inject ILogger<TemlateRegister> logger
|
||||
@inject ISnackbar Snackbar
|
||||
@inject IDIS_TemplateService templateService
|
||||
@inject IDIS_Service service
|
||||
@inherits OwningComponentBase
|
||||
<MudText Typo="Typo.h3" GutterBottom="true">注册标识模板</MudText>
|
||||
<MudText>在注册与更新标识之前,我们需要一个创建标识模板,然后我们可以通过创建的模板注册标识<br />
|
||||
基于已选的标识模板,创建新的标识模板</MudText>
|
||||
<MudGrid>
|
||||
<MudItem xs="3">
|
||||
<div class="d-flex flex-grow-1 gap-4 py-2">
|
||||
<MudText Class="flex-1 d-flex" Typo="Typo.h6">选择标识模板</MudText>
|
||||
<MudButton Class="d-flex" Variant="Variant.Outlined" OnClick="() => Refresh().Forget()">刷新</MudButton>
|
||||
</div>
|
||||
@if (templates.Length is 0)
|
||||
{
|
||||
<MudAlert Severity="Severity.Normal">模板为空</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudStack>
|
||||
@foreach (var item in templates)
|
||||
{
|
||||
<MudButton
|
||||
Class="pa-2"
|
||||
Variant="Variant.Outlined"
|
||||
OnClick="() => SelectTemplate(item)">
|
||||
@(item.Prefix)/@(item.Version)
|
||||
</MudButton>
|
||||
}
|
||||
</MudStack>
|
||||
}
|
||||
</MudItem>
|
||||
<MudItem xs="1">
|
||||
</MudItem>
|
||||
<MudItem xs="8">
|
||||
<MudStack>
|
||||
<MudText Typo="Typo.h6">模板信息</MudText>
|
||||
<MudStack Row="true" Spacing="2">
|
||||
<MudTextField @bind-Value="prefix" Label="前缀" Variant="Variant.Outlined"></MudTextField>
|
||||
<MudTextField @bind-Value="version" Label="版本" Variant="Variant.Outlined"></MudTextField>
|
||||
</MudStack>
|
||||
|
||||
<MudTextField @bind-Value="description" Label="描述" Variant="Variant.Outlined"></MudTextField>
|
||||
<MudText Typo="Typo.h6">模板条目</MudText>
|
||||
<MudTable Items="@items"
|
||||
Hover="true"
|
||||
Class="py-2"
|
||||
>
|
||||
<HeaderContent>
|
||||
<MudTh>Name</MudTh>
|
||||
<MudTh>IdType</MudTh>
|
||||
<MudTh>Type</MudTh>
|
||||
<MudTh>MinLength</MudTh>
|
||||
<MudTh>MaxLength</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Name">@context.Name</MudTd>
|
||||
<MudTd DataLabel="IdType">@context.IdType</MudTd>
|
||||
<MudTd DataLabel="Type">@context.MetaData.Type</MudTd>
|
||||
<MudTd DataLabel="MinLength">@context.MetaData.MinLength</MudTd>
|
||||
<MudTd DataLabel="MaxLength">@context.MetaData.MaxLength</MudTd>
|
||||
</RowTemplate>
|
||||
<RowEditingTemplate>
|
||||
<MudTd DataLabel="Name">
|
||||
<MudTextField @bind-Value="@context.Name" Required />
|
||||
</MudTd>
|
||||
<MudTd DataLabel="IdType">
|
||||
<MudTextField @bind-Value="@context.IdType" Required />
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Type">
|
||||
<MudTextField @bind-Value="@context.MetaData.Type" Required />
|
||||
</MudTd>
|
||||
<MudTd DataLabel="MinLength">
|
||||
<MudTextField @bind-Value="@context.MetaData.MinLength" Required />
|
||||
</MudTd>
|
||||
<MudTd DataLabel="MaxLength">
|
||||
<MudTextField @bind-Value="@context.MetaData.MaxLength" Required />
|
||||
</MudTd>
|
||||
</RowEditingTemplate>
|
||||
</MudTable>
|
||||
<div class="d-flex">
|
||||
<MudButton Class="d-flex flex-grow-1" Variant="Variant.Outlined" OnClick="SaveTemplate">保存标识模板</MudButton>
|
||||
<MudDivider Style="width: 1em" Vertical="true" FlexItem="true" />
|
||||
<MudButton Class="d-flex" Variant="Variant.Outlined">删除标识模板</MudButton>
|
||||
</div>
|
||||
</MudStack>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
@code {
|
||||
public IDIS_Template[] templates { get; set; } = Array.Empty<IDIS_Template>();
|
||||
private IDIS_Template template = new IDIS_Template();
|
||||
private IDIS_Template_Item[] items = new []{new IDIS_Template_Item()};
|
||||
|
||||
private string prefix { get; set; } = new IDIS_Template().Prefix;
|
||||
private string version { get; set; }= new IDIS_Template().Version;
|
||||
private string description { get; set; }= new IDIS_Template().Description;
|
||||
|
||||
async UniTask Refresh()
|
||||
{
|
||||
Snackbar.Add("正在刷新模板");
|
||||
templates = await templateService.ToArrayAsync();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
Snackbar.Add("模板刷新完成");
|
||||
}
|
||||
private void SelectTemplate(IDIS_Template newValue)
|
||||
{
|
||||
template = newValue;
|
||||
prefix = template.Prefix;
|
||||
version = template.Version;
|
||||
description = template.Description;
|
||||
items = template.Items;
|
||||
}
|
||||
private async void SaveTemplate()
|
||||
{
|
||||
var newTemplate = new IDIS_Template
|
||||
{
|
||||
Prefix = prefix,
|
||||
Version = version,
|
||||
Description = description,
|
||||
Items = items
|
||||
};
|
||||
Snackbar.Add("正在保存模板");
|
||||
try
|
||||
{
|
||||
await templateService.SaveAsync(newTemplate);
|
||||
Snackbar.Add("模板已保存");
|
||||
await Refresh();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Snackbar.Add(e.Message, Severity.Error);
|
||||
}
|
||||
}
|
||||
}
|
62
Components/Pages/Weather.razor
Normal file
62
Components/Pages/Weather.razor
Normal file
@@ -0,0 +1,62 @@
|
||||
@page "/weather"
|
||||
|
||||
<MudPopoverProvider />
|
||||
<MudDialogProvider />
|
||||
<MudSnackbarProvider />
|
||||
|
||||
<PageTitle>Weather</PageTitle>
|
||||
|
||||
<MudText Typo="Typo.h3" GutterBottom="true">Weather forecast</MudText>
|
||||
<MudText Class="mb-8">This component demonstrates fetching data from the server.</MudText>
|
||||
|
||||
@if (forecasts == null)
|
||||
{
|
||||
<MudProgressCircular Color="Color.Default" Indeterminate="true" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudTable Items="forecasts" Hover="true" SortLabel="Sort By" Elevation="0">
|
||||
<HeaderContent>
|
||||
<MudTh><MudTableSortLabel InitialDirection="SortDirection.Ascending" SortBy="new Func<WeatherForecast, object>(x=>x.Date)">Date</MudTableSortLabel></MudTh>
|
||||
<MudTh><MudTableSortLabel SortBy="new Func<WeatherForecast, object>(x=>x.TemperatureC)">Temp. (C)</MudTableSortLabel></MudTh>
|
||||
<MudTh><MudTableSortLabel SortBy="new Func<WeatherForecast, object>(x=>x.TemperatureF)">Temp. (F)</MudTableSortLabel></MudTh>
|
||||
<MudTh><MudTableSortLabel SortBy="new Func<WeatherForecast, object>(x=>x.Summary!)">Summary</MudTableSortLabel></MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Date">@context.Date</MudTd>
|
||||
<MudTd DataLabel="Temp. (C)">@context.TemperatureC</MudTd>
|
||||
<MudTd DataLabel="Temp. (F)">@context.TemperatureF</MudTd>
|
||||
<MudTd DataLabel="Summary">@context.Summary</MudTd>
|
||||
</RowTemplate>
|
||||
<PagerContent>
|
||||
<MudTablePager PageSizeOptions="new int[]{50, 100}" />
|
||||
</PagerContent>
|
||||
</MudTable>
|
||||
}
|
||||
|
||||
@code {
|
||||
private WeatherForecast[]? forecasts;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
// Simulate asynchronous loading to demonstrate streaming rendering
|
||||
await Task.Delay(500);
|
||||
|
||||
var startDate = DateOnly.FromDateTime(DateTime.Now);
|
||||
var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" };
|
||||
forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = startDate.AddDays(index),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = summaries[Random.Shared.Next(summaries.Length)]
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
private class WeatherForecast
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
public int TemperatureC { get; set; }
|
||||
public string? Summary { get; set; }
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
}
|
||||
}
|
10
Components/Routes.razor
Normal file
10
Components/Routes.razor
Normal file
@@ -0,0 +1,10 @@
|
||||
<Router AppAssembly="@typeof(Program).Assembly">
|
||||
<Found Context="routeData">
|
||||
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)">
|
||||
<NotAuthorized>
|
||||
<RedirectToLogin />
|
||||
</NotAuthorized>
|
||||
</AuthorizeRouteView>
|
||||
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
|
||||
</Found>
|
||||
</Router>
|
13
Components/_Imports.razor
Normal file
13
Components/_Imports.razor
Normal file
@@ -0,0 +1,13 @@
|
||||
@using System.Net.Http
|
||||
@using System.Net.Http.Json
|
||||
@using Microsoft.AspNetCore.Components.Authorization
|
||||
@using Microsoft.AspNetCore.Components.Forms
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using static Microsoft.AspNetCore.Components.Web.RenderMode
|
||||
@using Microsoft.AspNetCore.Components.Web.Virtualization
|
||||
@using Microsoft.JSInterop
|
||||
@using IDIS.Client.Web
|
||||
@using IDIS.Client.Web.Components
|
||||
@using MudBlazor
|
||||
@using MudBlazor.Services
|
Reference in New Issue
Block a user