refact: 重构回Server
This commit is contained in:
@@ -84,6 +84,25 @@
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
Log("编辑器加载完成");
|
||||
if (await GrammarStorage.RestoreGrammar())
|
||||
{
|
||||
await _editor.SetValue(RobotFactory.GrammarText);
|
||||
Log("从浏览器中恢复成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("尚未设置语法");
|
||||
}
|
||||
}
|
||||
|
||||
await base.OnAfterRenderAsync(firstRender);
|
||||
}
|
||||
|
||||
private StandaloneEditorConstructionOptions GetEditorConstructionOptions(StandaloneCodeEditor editor)
|
||||
{
|
||||
return new StandaloneEditorConstructionOptions
|
||||
|
@@ -53,13 +53,17 @@
|
||||
|
||||
private Guid _currentGuid;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
await GrammarStorage.RestoreGrammar();
|
||||
|
||||
Chat chat = GetInitChat();
|
||||
_chatDictionary.Add(chat.Guid, chat);
|
||||
_currentGuid = chat.Guid;
|
||||
if (firstRender)
|
||||
{
|
||||
await GrammarStorage.RestoreGrammar();
|
||||
|
||||
Chat chat = GetInitChat();
|
||||
_chatDictionary.Add(chat.Guid, chat);
|
||||
_currentGuid = chat.Guid;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
37
Frontend/Pages/_Host.cshtml
Normal file
37
Frontend/Pages/_Host.cshtml
Normal file
@@ -0,0 +1,37 @@
|
||||
@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>
|
Reference in New Issue
Block a user