@page "/editor"
@page "/editor/{action}"
@page "/editor/{action}/{projectId:int}"
@inject IOllamaService OllamaService
@inject IProjectService ProjectService
@inject NavigationManager Navigation
Editor - Author Buddy
@if (!string.IsNullOrEmpty(analysisResult))
{
Ergebnis:
@analysisResult
}
@code {
[Parameter]
public string? Action { get; set; }
[Parameter]
public int? ProjectId { get; set; }
private string editorContent = string.Empty;
private string statusText = "Bereit";
private bool isChecking;
private double checkProgress;
private string analysisResult = string.Empty;
protected override async Task OnInitializedAsync()
{
if (Action == "newproject")
{
// The native folder dialog isn't available in Blazor.
// In a real app, you'd provide a form to enter project name and path.
statusText = "Bitte nutze die Einstellungen zum Erstellen eines neuen Projekts.";
}
}
private async Task CheckStyle()
{
if (string.IsNullOrWhiteSpace(editorContent)) return;
isChecking = true;
statusText = "Ollama analysiert Stil...";
checkProgress = 50;
try
{
analysisResult = await OllamaService.StreamStyleCheckAsync(editorContent);
}
catch (Exception ex)
{
analysisResult = $"Fehler: {ex.Message}";
}
finally
{
statusText = "Bereit";
isChecking = false;
checkProgress = 0;
}
}
private async Task SpellCheck()
{
if (string.IsNullOrWhiteSpace(editorContent)) return;
isChecking = true;
statusText = "Ollama prüft Rechtschreibung...";
checkProgress = 50;
try
{
analysisResult = await OllamaService.QuickSpellCheckAsync(editorContent);
}
catch (Exception ex)
{
analysisResult = $"Fehler: {ex.Message}";
}
finally
{
statusText = "Bereit";
isChecking = false;
checkProgress = 0;
}
}
private async Task RagSearch()
{
if (string.IsNullOrWhiteSpace(editorContent)) return;
isChecking = true;
statusText = "Suche verwandte Fakten...";
await Task.Delay(500);
analysisResult = "RAG-Suche: Stelle sicher, dass ein Projekt geladen und indexiert wurde.";
statusText = "Bereit";
isChecking = false;
}
}