Yess
Some checks failed
Mirror to Gitea / git-sync (push) Has been cancelled

This commit is contained in:
2026-03-28 00:26:55 +02:00
parent ea2d84f5cc
commit ae0994409a
15 changed files with 660 additions and 94 deletions

View File

@@ -1,20 +1,30 @@
using System;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using VisionAsist.Models;
using VisionAsist.Views;
using Avalonia.Threading;
namespace VisionAsist.ViewModels;
public partial class MainWindowViewModel : ViewModelBase
{
public MainWindowViewModel()
{
Selector.OnLogUpdate += text =>
{
Dispatcher.UIThread.Post(() =>
{
CommandLog += text;
});
};
}
[RelayCommand]
private void Settingse()
{
new Settings
{
DataContext = new SettingsViewModel()
}.Show();
new Settings { DataContext = new SettingsViewModel() }.Show();
}
[ObservableProperty]
@@ -23,19 +33,23 @@ public partial class MainWindowViewModel : ViewModelBase
[ObservableProperty]
private string commandText = string.Empty;
[ObservableProperty]
private bool isGenerating = false;
[RelayCommand]
private void Send()
private async Task Send()
{
if (!string.IsNullOrWhiteSpace(CommandText))
if (!string.IsNullOrWhiteSpace(CommandText) && !IsGenerating)
{
// Отображаем введенную команду в логе
CommandLog = CommandText;
// Отправляем в селектор
Selector.selector(CommandText);
// Очищаем поле ввода
string input = CommandText;
CommandText = string.Empty;
IsGenerating = true;
// Запускаем логику в фоновом потоке, чтобы UI не зависал
await Task.Run(async () => {
await Selector.selector(input);
IsGenerating = false;
});
}
}
}