Finishddd
This commit is contained in:
@@ -1,127 +1,62 @@
|
||||
@using TechHelper.Client.Exam
|
||||
@using Entities.Contracts // Assuming SubjectAreaEnum is defined here, adjust if not
|
||||
|
||||
<MudPaper Outlined="true" Class="mt-2">
|
||||
|
||||
<MudRadioGroup @bind-Value="_examParser">
|
||||
@foreach (ExamParserEnum item in Enum.GetValues(typeof(ExamParserEnum)))
|
||||
{
|
||||
<MudRadio T="ExamParserEnum" Value="@item">@item</MudRadio>
|
||||
}
|
||||
</MudRadioGroup>
|
||||
<MudText Typo="Typo.h6" Class="mb-4">Current Parsing Rules</MudText>
|
||||
|
||||
<MudTextField @bind-Value="_ParserConfig" Label="正则表达式模式" Variant="Variant.Outlined" FullWidth="true" Class="mb-2" />
|
||||
<MudNumericField Label="优先级" @bind-Value="_Priority" Variant="Variant.Outlined" Min="1" Max="100" />
|
||||
<MudButton OnClick="AddPattern" Variant="Variant.Filled" Color="Color.Primary" Class="mt-2">添加模式</MudButton>
|
||||
@* Display Question Patterns *@
|
||||
@if (ExamParserConfig.QuestionPatterns.Any())
|
||||
{
|
||||
<MudExpansionPanel Text="Question Patterns" Class="mb-2" IsInitiallyExpanded="true">
|
||||
<MudStack Spacing="1">
|
||||
@foreach (var config in ExamParserConfig.QuestionPatterns)
|
||||
{
|
||||
<MudChip T="string" Color="Color.Info" Variant="Variant.Outlined" Class="d-flex justify-content-between align-items-center">
|
||||
<div class="d-flex flex-column align-items-start">
|
||||
<MudText Typo="Typo.body2">**Type:** @config.Type</MudText>
|
||||
<MudText Typo="Typo.body2">**Pattern:** <code>@config.Pattern</code></MudText>
|
||||
</div>
|
||||
<MudText Typo="Typo.body2">**Priority:** @config.Priority</MudText>
|
||||
</MudChip>
|
||||
}
|
||||
</MudStack>
|
||||
</MudExpansionPanel>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body2" Class="mb-2">No question patterns configured.</MudText>
|
||||
}
|
||||
|
||||
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2">所有已配置模式:</MudText>
|
||||
|
||||
|
||||
@if (ExamParserConfig.MajorQuestionGroupPatterns.Any())
|
||||
{
|
||||
<MudExpansionPanel Text="大题组模式详情" Class="mb-2">
|
||||
<MudStack>
|
||||
@foreach (var config in ExamParserConfig.MajorQuestionGroupPatterns)
|
||||
{
|
||||
<MudChip T="string">
|
||||
**模式:** <code>@config.Pattern</code>, **优先级:** @config.Priority
|
||||
</MudChip>
|
||||
}
|
||||
</MudStack>
|
||||
</MudExpansionPanel>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body2" Class="mb-2">暂无大题组模式。</MudText>
|
||||
}
|
||||
|
||||
@* 题目模式详情 *@
|
||||
@if (ExamParserConfig.QuestionPatterns.Any())
|
||||
{
|
||||
<MudExpansionPanel Text="题目模式详情" Class="mb-2">
|
||||
<MudStack>
|
||||
@foreach (var config in ExamParserConfig.QuestionPatterns)
|
||||
{
|
||||
<MudChip T="string">
|
||||
**模式:** <code>@config.Pattern</code>, **优先级:** @config.Priority
|
||||
</MudChip>
|
||||
}
|
||||
</MudStack>
|
||||
</MudExpansionPanel>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body2" Class="mb-2">暂无题目模式。</MudText>
|
||||
}
|
||||
|
||||
@if (ExamParserConfig.OptionPatterns.Any())
|
||||
{
|
||||
<MudExpansionPanel Text="选项模式详情" Class="mb-2">
|
||||
<MudStack>
|
||||
@foreach (var config in ExamParserConfig.OptionPatterns)
|
||||
{
|
||||
<MudChip T="string">
|
||||
**模式:** <code>@config.Pattern</code>, **优先级:** @config.Priority
|
||||
</MudChip>
|
||||
}
|
||||
</MudStack>
|
||||
</MudExpansionPanel>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body2" Class="mb-2">暂无选项模式。</MudText>
|
||||
}
|
||||
|
||||
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Secondary" OnClick="ResetPatterns">重置默认规则</MudButton>
|
||||
@* Display Option Patterns *@
|
||||
@if (ExamParserConfig.OptionPatterns.Any())
|
||||
{
|
||||
<MudExpansionPanel Text="Option Patterns" Class="mb-2" IsInitiallyExpanded="true">
|
||||
<MudStack Spacing="1">
|
||||
@foreach (var config in ExamParserConfig.OptionPatterns)
|
||||
{
|
||||
<MudChip T="string" Color="Color.Warning" Variant="Variant.Outlined" Class="d-flex justify-content-between align-items-center">
|
||||
<div class="d-flex flex-column align-items-start">
|
||||
<MudText Typo="Typo.body2">**Type:** @config.Type</MudText>
|
||||
<MudText Typo="Typo.body2">**Pattern:** <code>@config.Pattern</code></MudText>
|
||||
</div>
|
||||
<MudText Typo="Typo.body2">**Priority:** @config.Priority</MudText>
|
||||
</MudChip>
|
||||
}
|
||||
</MudStack>
|
||||
</MudExpansionPanel>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body2" Class="mb-2">No option patterns configured.</MudText>
|
||||
}
|
||||
|
||||
</MudPaper>
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public ExamParserConfig ExamParserConfig { get; set; } = new ExamParserConfig();
|
||||
|
||||
public ExamParserEnum _examParser { get; set; } = ExamParserEnum.MajorQuestionGroupPatterns;
|
||||
private string _ParserConfig;
|
||||
private int _Priority = 1;
|
||||
|
||||
[Parameter]
|
||||
public ExamParserConfig ExamParserConfig { get; set; } = new ExamParserConfig();
|
||||
|
||||
[Inject]
|
||||
public ISnackbar Snackbar { get; set; }
|
||||
|
||||
private void AddPattern()
|
||||
{
|
||||
|
||||
switch ((ExamParserEnum)_examParser)
|
||||
{
|
||||
case ExamParserEnum.MajorQuestionGroupPatterns:
|
||||
ExamParserConfig.MajorQuestionGroupPatterns.Add(new RegexPatternConfig(_ParserConfig, _Priority));
|
||||
Snackbar.Add($"已添加大题组模式: {_ParserConfig}, 优先级: {_Priority}", Severity.Success);
|
||||
break;
|
||||
case ExamParserEnum.QuestionPatterns:
|
||||
ExamParserConfig.QuestionPatterns.Add(new RegexPatternConfig(_ParserConfig, _Priority));
|
||||
Snackbar.Add($"已添加题目模式: {_ParserConfig}, 优先级: {_Priority}", Severity.Success);
|
||||
break;
|
||||
case ExamParserEnum.OptionPatterns:
|
||||
ExamParserConfig.OptionPatterns.Add(new RegexPatternConfig(_ParserConfig, _Priority));
|
||||
Snackbar.Add($"已添加选项模式: {_ParserConfig}, 优先级: {_Priority}", Severity.Success);
|
||||
break;
|
||||
default:
|
||||
Snackbar.Add("请选择要添加的模式类型。");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void ResetPatterns()
|
||||
{
|
||||
ExamParserConfig = new ExamParserConfig();
|
||||
StateHasChanged();
|
||||
}
|
||||
// No other properties or methods are needed as the component is now purely for display.
|
||||
}
|
Reference in New Issue
Block a user