add: 迁移到WASM

This commit is contained in:
jackfiled 2023-10-17 20:10:28 +08:00
parent d3833fdfda
commit bb6ed6acfc
6 changed files with 47 additions and 54 deletions

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
@ -9,6 +9,8 @@
<ItemGroup>
<PackageReference Include="AntDesign" Version="0.15.5" />
<PackageReference Include="BlazorMonaco" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.11" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>

View File

@ -1,37 +0,0 @@
@page "/"
@using Microsoft.AspNetCore.Components.Web
@namespace Frontend.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<base href="~/"/>
<link href="css/site.css" rel="stylesheet"/>
<link href="_content/AntDesign/css/ant-design-blazor.css" rel="stylesheet" />
<link href="Frontend.styles.css" rel="stylesheet">
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered"/>
</head>
<body>
<component type="typeof(App)" render-mode="ServerPrerendered"/>
<div id="blazor-error-ui">
<environment include="Staging,Production">
An error has occurred. This application may no longer respond until reloaded.
</environment>
<environment include="Development">
An unhandled exception has occurred. See browser dev tools for details.
</environment>
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>
<script src="_content/AntDesign/js/ant-design-blazor.js"></script>
<script src="_content/BlazorMonaco/jsInterop.js"></script>
<script src="_content/BlazorMonaco/lib/monaco-editor/min/vs/loader.js"></script>
<script src="_content/BlazorMonaco/lib/monaco-editor/min/vs/editor/editor.main.js"></script>
<script src="_framework/blazor.server.js"></script>
<script src="js/helper.js"></script>
</body>
</html>

View File

@ -1,19 +1,15 @@
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Katheryne;
using Frontend;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddAntDesign();
builder.Services.AddKatheryne();
WebApplication app = builder.Build();
WebAssemblyHost app = builder.Build();
app.UseStaticFiles();
app.UseRouting();
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
app.Run();
await app.RunAsync();

View File

@ -1,5 +1,8 @@
@using Microsoft.AspNetCore.Components.Routing
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.WebAssembly.Http
@using Microsoft.JSInterop
@using AntDesign
@using BlazorMonaco

View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>BlazorWasmSample</title>
<base href="/" />
<link href="css/site.css" rel="stylesheet" />
<link href="Frontend.styles.css" rel="stylesheet" />
<link href="_content/AntDesign/css/ant-design-blazor.css" rel="stylesheet" />
</head>
<body>
<div id="app">Loading...</div>
<div id="blazor-error-ui">
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>
<script src="_content/AntDesign/js/ant-design-blazor.js"></script>
<script src="_content/BlazorMonaco/jsInterop.js"></script>
<script src="_content/BlazorMonaco/lib/monaco-editor/min/vs/loader.js"></script>
<script src="_content/BlazorMonaco/lib/monaco-editor/min/vs/editor/editor.main.js"></script>
<script src="_framework/blazor.webassembly.js"></script>
<script src="js/helper.js"></script>
</body>
</html>

View File

@ -29,10 +29,10 @@ public class KatheryneChatRobotFactory
}
/// <summary>
/// 设置当前机器人使用的文法
/// 设置当前机器人使用的文法
/// </summary>
/// <param name="grammarText">文法字符串</param>
/// <exception cref="GrammarException">编译文法失败抛出的异常</exception>
/// <param name="grammarText">文法字符串</param>
/// <exception cref="GrammarException">编译文法失败抛出的异常</exception>
public void SetGrammar(string grammarText)
{
_factoryLogger.LogInformation("Receive new grammar: {}.", grammarText);