This commit is contained in:
CortexCore 2024-05-09 01:24:50 +08:00
commit 01f42d169d
24 changed files with 1386 additions and 0 deletions

575
.gitignore vendored Normal file
View File

@ -0,0 +1,575 @@
# ---> Unity
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Uu]ser[Ss]ettings/
# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data
/[Mm]emoryCaptures/
# Recordings can get excessive in size
/[Rr]ecordings/
# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*
# Autogenerated Jetbrains Rider plugin
/[Aa]ssets/Plugins/Editor/JetBrains*
# Visual Studio cache directory
.vs/
# Gradle cache directory
.gradle/
# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db
# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta
# Unity3D generated file on crash reports
sysinfo.txt
# Builds
*.apk
*.aab
*.unitypackage
*.app
# Crashlytics generated file
crashlytics-build.properties
# Packed Addressables
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*
# ---> JetBrains
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# SonarLint plugin
.idea/sonarlint/
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
# ---> VisualStudio
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp
# Visual Studio 6 technical files
*.ncb
*.aps
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# Visual Studio History (VSHistory) files
.vshistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
*.sln.iml
# ---> VisualStudioCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
*.vsix
# custom
.idea
.plastic
.vscode
/Assets/StreamingAssets/yoo
yoo/
Bundles/
Profiler/

25
Components/App.razor Normal file
View 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>

View 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;
}
}

View 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>

View 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>

View 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++;
}
}

View 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;
}

View 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 />
你可以在&lt;AppBar&gt;的右上角切换夜间模式<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 /> *@
@* &lt;MudPopoverProvider /&gt; <br /> *@
@* &lt;MudDialogProvider /&gt; <br /> *@
@* &lt;MudSnackbarProvider /&gt; <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> *@

View 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;
}
}
}

View 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"
};
}
}

View 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);
}
}
}

View 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
View 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
View 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

59
Program.cs Normal file
View File

@ -0,0 +1,59 @@
using BITKit;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using IDIS.Client.Web.Components;
using IDIS.Models;
using IDIS.Services;
using MudBlazor.Services;
await BITAppForNet.InitializeAsync("IDIS");
var config = Path.Combine(Environment.CurrentDirectory,"appsettings.json");
if (File.Exists(config))
{
var json = File.ReadAllText(config);
DataParser.Set(json);
}
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.Services.AddMudServices();
builder.Services.AddCascadingAuthenticationState();
builder.Services.AddTransient<IDIS_Service, IDIS_Service_MySQLBased>();
builder.Services.AddTransient<IDIS_TemplateService, IDIS_TemplateService_MySQLBased>();
builder.Services.AddAuthentication(options =>
{
options.DefaultScheme = IdentityConstants.ApplicationScheme;
options.DefaultSignInScheme = IdentityConstants.ExternalScheme;
})
.AddIdentityCookies();
var app = builder.Build();
app.UseExceptionHandler("/Error", createScopeForErrors: true);
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAntiforgery();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
// Add additional endpoints required by the Identity /Account Razor components.
app.Run();

View File

@ -0,0 +1,38 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:46622",
"sslPort": 44333
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5150",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:7086;http://localhost:5150",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

10
appsettings.json Normal file
View File

@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"DefaultConnection":"server=server.bitfall.icu;port=3306;database=ifactory;uid=ifactory;password=JdBfKR2dxhm76Ss2;",
"AllowedHosts": "*"
}

7
global.json Normal file
View File

@ -0,0 +1,7 @@
{
"sdk": {
"version": "8.0.0",
"rollForward": "latestMajor",
"allowPrerelease": true
}
}

20
wwwroot/app.css Normal file
View File

@ -0,0 +1,20 @@
/*
This CSS file matches the color scheme from MudBlazor to Bootstrap when utilized for authentication.
The file remains available at all times for demonstration purposes,
but it is exclusively employed in the 'App.razor' component when authentication is enabled.
*/
.btn-primary {
text-transform: uppercase;
--bs-btn-bg: var(--mud-palette-primary) !important;
--bs-btn-hover-bg: var(--mud-palette-primary-darken) !important;
}
.nav-pills {
--bs-nav-pills-link-active-bg: var(--mud-palette-primary) !important;
}
.nav {
--bs-nav-link-color: var(--mud-palette-primary) !important;
--bs-nav-link-hover-color: var(--mud-palette-primary-darken) !important;
}

6
wwwroot/bootstrap/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

BIN
wwwroot/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB