├── .editorconfig ├── .gitignore ├── CodeWF.Toolbox.sln ├── Directory.Build.props ├── LICENSE ├── README-zh_CN.md ├── README.md ├── UpdateLog.md ├── src ├── CodeWF.Controls │ └── CodeWF.Controls.csproj ├── CodeWF.Core │ ├── CodeWF.Core.csproj │ ├── ConfigDB │ │ └── DBConst.cs │ ├── DialogNames.cs │ ├── HostIds.cs │ ├── IServices │ │ ├── IApplicationService.cs │ │ ├── IFileChooserService.cs │ │ └── INotificationService.cs │ ├── IToolMenuService.cs │ ├── Models │ │ ├── ToolMenuItem.cs │ │ └── ToolStatus.cs │ ├── RegionAdapters │ │ └── TabControlRegionAdapter.cs │ ├── RegionNames.cs │ ├── Services │ │ ├── FileChooserService.cs │ │ └── NotificationService.cs │ └── ToolMenuService.cs ├── CodeWF.Modules.AI │ ├── AIModule.cs │ ├── CodeWF - Backup.Modules.AI.csproj │ ├── CodeWF.Modules.AI.csproj │ ├── Entities │ │ └── TranslateLanguageEntity.cs │ ├── Helpers │ │ ├── ApiClient.cs │ │ └── ConfigHelper.cs │ ├── I18n │ │ ├── AIModule.en-US.xml │ │ ├── AIModule.ja-JP.xml │ │ ├── AIModule.zh-CN.xml │ │ ├── AIModule.zh-Hant.xml │ │ ├── Language.cs │ │ └── Language.tt │ ├── Icons.cs │ ├── Imports.cs │ ├── Models │ │ ├── AskBotRequest.cs │ │ ├── ChatGptOptions.cs │ │ ├── PolyTranslateRequest.cs │ │ └── Title2SlugRequest.cs │ ├── ViewModels │ │ ├── AskBotViewModel.cs │ │ ├── ChoiceLanguagesViewModel.cs │ │ ├── PolyTranslateViewModel.cs │ │ └── Title2SlugViewModel.cs │ └── Views │ │ ├── AskBotView.axaml │ │ ├── AskBotView.axaml.cs │ │ ├── ChoiceLanguagesView.axaml │ │ ├── ChoiceLanguagesView.axaml.cs │ │ ├── PolyTranslateView.axaml │ │ ├── PolyTranslateView.axaml.cs │ │ ├── Title2SlugView.axaml │ │ └── Title2SlugView.axaml.cs ├── CodeWF.Modules.Converter │ ├── CodeWF.Modules.Converter.csproj │ ├── ConverterModule.cs │ ├── I18n │ │ ├── ConverterModule.en-US.xml │ │ ├── ConverterModule.ja-JP.xml │ │ ├── ConverterModule.zh-CN.xml │ │ ├── ConverterModule.zh-Hant.xml │ │ ├── Language.cs │ │ └── Language.tt │ ├── Icons.cs │ ├── Models │ │ └── IconSize.cs │ ├── ViewModels │ │ ├── DateTimeConverterViewModel.cs │ │ ├── ImageToIconViewModel.cs │ │ ├── JsonToYamlViewModel.cs │ │ └── YamlToJsonViewModel.cs │ └── Views │ │ ├── DateTimeConverterView.axaml │ │ ├── DateTimeConverterView.axaml.cs │ │ ├── ImageToIconView.axaml │ │ ├── ImageToIconView.axaml.cs │ │ ├── JsonToYamlView.axaml │ │ ├── JsonToYamlView.axaml.cs │ │ ├── YamlToJsonView.axaml │ │ └── YamlToJsonView.axaml.cs ├── CodeWF.Modules.Development │ ├── Assets │ │ ├── OvertimeAlarm.png │ │ ├── OvertimeAll.png │ │ └── OvertimeNormal.png │ ├── CodeWF.Modules.Development.csproj │ ├── Converters │ │ ├── WarningKindDescriptionConverter.cs │ │ └── WarningKindImageConverter.cs │ ├── DevelopmentModule.cs │ ├── Entities │ │ └── JsonPrettifyEntity.cs │ ├── Helpers │ │ └── ConfigHelper.cs │ ├── I18n │ │ ├── DevelopmentModule.en-US.xml │ │ ├── DevelopmentModule.ja-JP.xml │ │ ├── DevelopmentModule.zh-CN.xml │ │ ├── DevelopmentModule.zh-Hant.xml │ │ ├── Language.cs │ │ └── Language.tt │ ├── Icons.cs │ ├── Jobs │ │ ├── DailyTimeJob.cs │ │ └── UpdateTimeJob.cs │ ├── Models │ │ └── WarningKind.cs │ ├── ViewModels │ │ ├── JsonPrettifyViewModel.cs │ │ ├── TestViewModel.cs │ │ └── YamlPrettifyViewModel.cs │ └── Views │ │ ├── JsonPrettifyView.axaml │ │ ├── JsonPrettifyView.axaml.cs │ │ ├── TestView.axaml │ │ ├── TestView.axaml.cs │ │ ├── YamlPrettifyView.axaml │ │ └── YamlPrettifyView.axaml.cs ├── CodeWF.Modules.XmlTranslatorManager │ ├── CodeWF.Modules.XmlTranslatorManager.csproj │ ├── I18n │ │ ├── Language.cs │ │ ├── Language.tt │ │ ├── XmlTranslatorManagerModule.en-US.xml │ │ ├── XmlTranslatorManagerModule.ja-JP.xml │ │ ├── XmlTranslatorManagerModule.zh-CN.xml │ │ └── XmlTranslatorManagerModule.zh-Hant.xml │ ├── Icons.cs │ ├── Models │ │ ├── Consts.cs │ │ ├── LanguageClassModel.cs │ │ ├── LanguageProperty.cs │ │ ├── LanguageXmlFileInfo.cs │ │ └── LanguageXmlModel.cs │ ├── README.zh-CN.md │ ├── ViewModels │ │ ├── ManageXMLFilesViewModel.cs │ │ └── MergeXMLFilesViewModel.cs │ ├── Views │ │ ├── ManageXMLFilesView.axaml │ │ ├── ManageXMLFilesView.axaml.cs │ │ ├── MergeXMLFilesView.axaml │ │ └── MergeXMLFilesView.axaml.cs │ └── XmlTranslatorManagerModule.cs ├── CodeWF.Toolbox.Desktop │ ├── App.config │ ├── CodeWF.Toolbox.Desktop.csproj │ ├── Program.cs │ ├── Roots.xml │ ├── app.manifest │ └── logo.ico └── CodeWF.Toolbox │ ├── App.axaml │ ├── App.axaml.cs │ ├── Assets │ ├── datetime-converter.png │ ├── logo.ico │ ├── logo.png │ ├── slug-converter.png │ ├── wechatowner.jpg │ └── wechatpublic.jpg │ ├── CodeWF.Toolbox.csproj │ ├── Commands │ ├── ChangeApplicationStatusCommand.cs │ └── ChangeToolMenuCommand.cs │ ├── Converters │ └── IconConverter.cs │ ├── I18n │ ├── Language.cs │ ├── Language.tt │ ├── MainModule.en-US.xml │ ├── MainModule.ja-JP.xml │ ├── MainModule.zh-CN.xml │ └── MainModule.zh-Hant.xml │ ├── Icons.cs │ ├── MainModule.cs │ ├── Models │ ├── ConstDatas.cs │ └── ThemeItem.cs │ ├── Services │ └── ApplicationService.cs │ ├── Styles │ └── Index.axaml │ ├── ViewModels │ ├── AboutViewModel.cs │ ├── CommonSettingViewModel.cs │ ├── DashboardViewModel.cs │ ├── ExitOptionViewModel.cs │ ├── MainContentViewModel.cs │ ├── MainMenuViewModel.cs │ ├── MainViewModel.cs │ ├── SettingViewModel.cs │ ├── UpdateLogViewModel.cs │ └── ViewModelBase.cs │ └── Views │ ├── AboutView.axaml │ ├── AboutView.axaml.cs │ ├── CommonSettingView.axaml │ ├── CommonSettingView.axaml.cs │ ├── DashboardView.axaml │ ├── DashboardView.axaml.cs │ ├── ExitOptionView.axaml │ ├── ExitOptionView.axaml.cs │ ├── MainContentView.axaml │ ├── MainContentView.axaml.cs │ ├── MainMenuView.axaml │ ├── MainMenuView.axaml.cs │ ├── MainView.axaml │ ├── MainView.axaml.cs │ ├── MainWindow.axaml │ ├── MainWindow.axaml.cs │ ├── SettingView.axaml │ ├── SettingView.axaml.cs │ ├── UpdateLogView.axaml │ └── UpdateLogView.axaml.cs └── tests ├── AvaloniaAotDemo ├── App.axaml ├── App.axaml.cs ├── Assets │ └── avalonia-logo.ico ├── AvaloniaAotDemo.csproj ├── Commands │ └── ChangeTimeCommand.cs ├── Program.cs ├── ViewLocator.cs ├── ViewModels │ ├── MainWindowViewModel.cs │ └── ViewModelBase.cs ├── Views │ ├── MainWindow.axaml │ └── MainWindow.axaml.cs └── app.manifest ├── ConsoleAotDemo ├── ConsoleAotDemo.csproj ├── DBHeper.cs ├── Dtos │ └── Person.cs └── Program.cs └── WinFormsAotDemo ├── Form1.Designer.cs ├── Form1.cs ├── Form1.resx ├── Program.cs └── WinFormsAotDemo.csproj /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | CodeWF Toolbox 4 | codewf.com 5 | Copyright © 2024 codewf.com. All rights reserved. 6 | 使用.NET 9 + Avalonia UI + Prism开发的工具客户端,支持AOT发布,目前测试可在Windows 7\Windows Server 2019\Windows 10\Windows 11\macOS 11+等平台运行 7 | 0.0.1.1 8 | 0.0.1.1 9 | 0.0.1.1 10 | 0.0.1.1 11 | 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Dotnet9(dotnet9.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README-zh_CN.md: -------------------------------------------------------------------------------- 1 | # CodeWF Toolbox 2 | 3 | 简体中文 | [English](README.md) 4 | 5 | 使用.NET 9 + Avalonia UI + Prism开发的工具客户端,支持AOT发布,目前测试可在Windows 7\Windows Server 2019\Windows 10\Windows 11\macOS 11+平台运行 6 | 7 | **解决方案截图** 8 | 9 | ![](https://img1.dotnet9.com/site/doc/tool/imgs/0101.png) 10 | 11 | **AOT发布后目录** 12 | 13 | ![](https://img1.dotnet9.com/site/doc/tool/imgs/0102.png) 14 | 15 | **黑白主题切换** 16 | 17 | ![](https://img1.dotnet9.com/site/doc/tool/imgs/0103.gif) 18 | 19 | **国际化** 20 | 21 | ![](https://img1.dotnet9.com/site/doc/tool/imgs/0104.gif) 22 | 同时,包含实用的 Json 美化工具和 YAML 转 Json 工具,分别如下图所示: 23 | 24 | **Json 美化工具** 25 | 26 | ![](https://img1.dotnet9.com/2024/09/0108.png) 27 | 28 | **YAML转Json工具** 29 | 30 | ![](https://img1.dotnet9.com/2024/09/0109.png) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 码界工坊工具箱 2 | 3 | English | [简体中文](README-zh_CN.md) 4 | 5 | Use. NET 9+Avalonia UI+Prism developed tool client, supports AOT publishing, currently tested to run on Windows 7 \ Windows Server 2019 \ Windows 10 \ Windows 11 \ macOS 11+platforms 6 | 7 | **Solution screenshot** 8 | 9 | ![]( https://img1.dotnet9.com/site/doc/tool/imgs/0101.png ) 10 | 11 | **Directory after AOT release** 12 | 13 | ![]( https://img1.dotnet9.com/site/doc/tool/imgs/0102.png ) 14 | 15 | **Black and White Theme Switching** 16 | 17 | ![]( https://img1.dotnet9.com/site/doc/tool/imgs/0103.gif ) 18 | 19 | **Internationalization** 20 | 21 | ![]( https://img1.dotnet9.com/site/doc/tool/imgs/0104.gif ) 22 | At the same time, it includes practical Json beautification tools and YAML to Json tools, as shown in the following figures: 23 | 24 | **Json Beautification Tool** 25 | 26 | ![]( https://img1.dotnet9.com/2024/09/0108.png ) 27 | 28 | **YAML to JSON conversion tool** 29 | 30 | ![]( https://img1.dotnet9.com/2024/09/0109.png ) -------------------------------------------------------------------------------- /UpdateLog.md: -------------------------------------------------------------------------------- 1 | ## 更新日志 2 | 3 | ### V0.0.1.1(2024-12-28) 4 | - 🔨使用MarkdownAIRender渲染Markdown 5 | 6 | ### V0.0.1.0(2024-12-25) 7 | - 😄添加更新日志 8 | - 🔨导出Excel默认覆盖已有文件 9 | - 🐛修复只能导出渲染表格数据的问题 -------------------------------------------------------------------------------- /src/CodeWF.Controls/CodeWF.Controls.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net9.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/CodeWF.Core/CodeWF.Core.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net9.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/CodeWF.Core/ConfigDB/DBConst.cs: -------------------------------------------------------------------------------- 1 | namespace CodeWF.Core.ConfigDB; 2 | 3 | public class DBConst 4 | { 5 | public const string DBConnectionString = "Data Source=CodeWF.Toolbox.db"; 6 | } -------------------------------------------------------------------------------- /src/CodeWF.Core/DialogNames.cs: -------------------------------------------------------------------------------- 1 | namespace CodeWF.Core; 2 | 3 | public static class DialogNames 4 | { 5 | public const string Setting = nameof(Setting); 6 | public const string ChoiceLanguages = nameof(ChoiceLanguages); 7 | } -------------------------------------------------------------------------------- /src/CodeWF.Core/HostIds.cs: -------------------------------------------------------------------------------- 1 | namespace CodeWF.Core; 2 | 3 | public static class HostIds 4 | { 5 | public const string Main = "Main"; 6 | } -------------------------------------------------------------------------------- /src/CodeWF.Core/IServices/IApplicationService.cs: -------------------------------------------------------------------------------- 1 | namespace CodeWF.Core.IServices; 2 | 3 | public interface IApplicationService 4 | { 5 | public bool HideTrayIconOnClose { get; set; } 6 | public bool NeedExitDialogOnClose { get; set; } 7 | void Load(); 8 | string GetTheme(); 9 | void SetTheme(string theme); 10 | string GetCulture(); 11 | void SetCulture(string culture); 12 | } -------------------------------------------------------------------------------- /src/CodeWF.Core/IServices/IFileChooserService.cs: -------------------------------------------------------------------------------- 1 | using Avalonia.Controls; 2 | using Avalonia.Platform.Storage; 3 | 4 | namespace CodeWF.Core.IServices; 5 | 6 | public interface IFileChooserService 7 | { 8 | void SetHostWindow(TopLevel level); 9 | 10 | Task?> OpenFileAsync(string title, bool allowMultiple, 11 | IReadOnlyList? fileTypeFilters); 12 | 13 | Task SaveFileAsync(string title, IReadOnlyList? fileTypeFilters); 14 | 15 | Task?> OpenFolderAsync(string title, bool allowMultiple = false); 16 | } -------------------------------------------------------------------------------- /src/CodeWF.Core/IServices/INotificationService.cs: -------------------------------------------------------------------------------- 1 | using Avalonia.Controls; 2 | using Avalonia.Controls.Notifications; 3 | 4 | namespace CodeWF.Core.IServices; 5 | 6 | public interface INotificationService 7 | { 8 | void SetHostWindow(TopLevel level); 9 | void Show(string title, string message, NotificationType type = NotificationType.Information); 10 | } -------------------------------------------------------------------------------- /src/CodeWF.Core/IToolMenuService.cs: -------------------------------------------------------------------------------- 1 | using CodeWF.Core.Models; 2 | using System.Collections.ObjectModel; 3 | 4 | namespace CodeWF.Core; 5 | 6 | public interface IToolMenuService 7 | { 8 | ObservableCollection MenuItems { get; } 9 | event Action? ToolMenuChanged; 10 | 11 | void AddGroup(string name, string? icon = null); 12 | 13 | void AddItem(string name, string? parentName = null, string? description = null, string? viewName = null, 14 | string? icon = null, ToolStatus? status = null); 15 | 16 | void AddSeparator(); 17 | } -------------------------------------------------------------------------------- /src/CodeWF.Core/Models/ToolMenuItem.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | 3 | namespace CodeWF.Core.Models; 4 | 5 | public class ToolMenuItem 6 | { 7 | public int Level { get; set; } 8 | public string? Name { get; set; } 9 | public string? Description { get; set; } 10 | public string? ViewName { get; set; } 11 | public ToolStatus? Status { get; set; } 12 | public string? Icon { get; set; } 13 | public bool IsSeparator { get; set; } 14 | public ObservableCollection Children { get; set; } = new(); 15 | 16 | public override string ToString() 17 | { 18 | return $"{Name}"; 19 | } 20 | } -------------------------------------------------------------------------------- /src/CodeWF.Core/Models/ToolStatus.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace CodeWF.Core.Models; 4 | 5 | public enum ToolStatus 6 | { 7 | [Description("计划中")] Planned, 8 | [Description("开发中")] Developing, 9 | [Description("开发完成")] Complete 10 | } -------------------------------------------------------------------------------- /src/CodeWF.Core/RegionAdapters/TabControlRegionAdapter.cs: -------------------------------------------------------------------------------- 1 | using Avalonia.Controls; 2 | using AvaloniaXmlTranslator.Markup; 3 | using System.Collections.Specialized; 4 | 5 | namespace CodeWF.Core.RegionAdapters; 6 | 7 | public interface ITabItemBase 8 | { 9 | public string? TitleKey { get; set; } 10 | public string MessageKey { get; set; } 11 | } 12 | 13 | public class TabControlRegionAdapter : RegionAdapterBase 14 | { 15 | public TabControlRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory) : base(regionBehaviorFactory) 16 | { 17 | } 18 | 19 | protected override void Adapt(IRegion region, TabControl regionTarget) 20 | { 21 | if (region == null) 22 | throw new ArgumentNullException(nameof(region)); 23 | 24 | if (regionTarget == null) 25 | throw new ArgumentNullException(nameof(regionTarget)); 26 | 27 | regionTarget.SelectionChanged += (s, e) => 28 | { 29 | if (regionTarget.SelectedItem is TabItem { Content: UserControl { DataContext: ITabItemBase vm } }) 30 | { 31 | regionTarget.Tag = vm.MessageKey; 32 | } 33 | }; 34 | 35 | region.Views.CollectionChanged += (s, e) => 36 | { 37 | switch (e.Action) 38 | { 39 | case NotifyCollectionChangedAction.Add: 40 | { 41 | if (e.NewItems != null) 42 | { 43 | foreach (var item in e.NewItems) 44 | { 45 | var header = item is UserControl { DataContext: ITabItemBase tabItem } 46 | ? tabItem.TitleKey 47 | : item?.GetType().ToString(); 48 | var newTabItem = new TabItem { Content = item }; 49 | newTabItem.Bind(TabItem.HeaderProperty, new I18nBinding(header)); 50 | regionTarget.Items.Add(newTabItem); 51 | } 52 | } 53 | 54 | break; 55 | } 56 | case NotifyCollectionChangedAction.Remove: 57 | { 58 | if (e.OldItems != null) 59 | { 60 | foreach (var item in e.OldItems) 61 | { 62 | var tabToDelete = regionTarget.Items.OfType() 63 | .FirstOrDefault(n => n.Content == item); 64 | regionTarget.Items.Remove(tabToDelete); 65 | } 66 | } 67 | 68 | break; 69 | } 70 | } 71 | }; 72 | } 73 | 74 | protected override IRegion CreateRegion() => new SingleActiveRegion(); 75 | } -------------------------------------------------------------------------------- /src/CodeWF.Core/RegionNames.cs: -------------------------------------------------------------------------------- 1 | namespace CodeWF.Core; 2 | 3 | public static class RegionNames 4 | { 5 | /// Main Window's Footer Status Bar. 6 | public const string FooterRegion = nameof(FooterRegion); 7 | 8 | /// Left Side Bar. 9 | public const string LeftRegion = nameof(LeftRegion); 10 | 11 | /// Main Window's content region 12 | public const string ContentRegion = nameof(ContentRegion); 13 | 14 | /// Right Side Bar. 15 | public const string RightRegion = nameof(RightRegion); 16 | 17 | /// Right Side Bar. 18 | public const string SettingRegion = nameof(SettingRegion); 19 | } -------------------------------------------------------------------------------- /src/CodeWF.Core/Services/FileChooserService.cs: -------------------------------------------------------------------------------- 1 | using Avalonia.Controls; 2 | using Avalonia.Platform.Storage; 3 | using CodeWF.Core.IServices; 4 | 5 | namespace CodeWF.Core.Services; 6 | 7 | public class FileChooserService : IFileChooserService 8 | { 9 | private IStorageProvider? _storageProvider; 10 | 11 | public void SetHostWindow(TopLevel level) 12 | { 13 | _storageProvider = level?.StorageProvider; 14 | } 15 | 16 | public async Task?> OpenFileAsync(string title, bool allowMultiple, 17 | IReadOnlyList? fileTypeFilters) 18 | { 19 | var result = await _storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions() 20 | { 21 | Title = title, FileTypeFilter = fileTypeFilters, AllowMultiple = allowMultiple, 22 | }); 23 | 24 | return result.Any() ? result.Select(file => file.TryGetLocalPath()).ToList() : default; 25 | } 26 | 27 | public async Task SaveFileAsync(string title, IReadOnlyList? fileTypeFilters) 28 | { 29 | var result = await _storageProvider.SaveFilePickerAsync(new FilePickerSaveOptions() 30 | { 31 | Title = title, FileTypeChoices = fileTypeFilters 32 | }); 33 | 34 | return result == null ? default : result.TryGetLocalPath(); 35 | } 36 | 37 | public async Task?> OpenFolderAsync(string title, bool allowMultiple = false) 38 | { 39 | var result = await _storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions() 40 | { 41 | Title = title, AllowMultiple = allowMultiple, 42 | }); 43 | 44 | return result.Any() ? result.Select(file => file.TryGetLocalPath()).ToList() : default; 45 | } 46 | } -------------------------------------------------------------------------------- /src/CodeWF.Core/Services/NotificationService.cs: -------------------------------------------------------------------------------- 1 | using Avalonia.Controls; 2 | using Avalonia.Controls.Notifications; 3 | using CodeWF.Core.IServices; 4 | 5 | namespace CodeWF.Core.Services; 6 | 7 | public class NotificationService : INotificationService 8 | { 9 | private WindowNotificationManager? _notificationManager; 10 | 11 | public void SetHostWindow(TopLevel level) 12 | { 13 | _notificationManager = new WindowNotificationManager(level) 14 | { 15 | Position = NotificationPosition.BottomRight, MaxItems = 4, Margin = new Avalonia.Thickness(0, 0, 15, 40) 16 | }; 17 | } 18 | 19 | public void Show(string title, string message, NotificationType type = NotificationType.Information) 20 | { 21 | _notificationManager?.Show(new Notification(title, message, type, TimeSpan.FromSeconds(10))); 22 | } 23 | } -------------------------------------------------------------------------------- /src/CodeWF.Core/ToolMenuService.cs: -------------------------------------------------------------------------------- 1 | using CodeWF.Core.Models; 2 | using System.Collections.ObjectModel; 3 | 4 | namespace CodeWF.Core; 5 | 6 | public class ToolMenuService : IToolMenuService 7 | { 8 | public ObservableCollection MenuItems { get; } = []; 9 | public event Action? ToolMenuChanged; 10 | 11 | public void AddItem(string name, string? parentName = null, string? description = null, string? viewName = null, 12 | string? icon = null, ToolStatus? status = null) 13 | { 14 | ToolMenuItem? parent = null; 15 | if (parentName != null) 16 | { 17 | parent = MenuItems.FirstOrDefault(item => item.Name == parentName) ?? 18 | new ToolMenuItem { Name = parentName, Children = [] }; 19 | } 20 | 21 | var toolMenuItem = new ToolMenuItem() 22 | { 23 | Name = name, 24 | Description = description, 25 | ViewName = viewName, 26 | Status = status, 27 | Icon = icon 28 | }; 29 | if (parent == null) 30 | { 31 | MenuItems.Add(toolMenuItem); 32 | } 33 | else 34 | { 35 | parent.Children.Add(toolMenuItem); 36 | } 37 | 38 | ToolMenuChanged?.Invoke(); 39 | } 40 | 41 | public void AddSeparator() 42 | { 43 | MenuItems.Add(new ToolMenuItem() { IsSeparator = true }); 44 | } 45 | 46 | public void AddGroup(string name, string? icon = null) 47 | { 48 | MenuItems.Add(new ToolMenuItem() { Name = name, Icon = icon }); 49 | } 50 | } -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/AIModule.cs: -------------------------------------------------------------------------------- 1 | using CodeWF.Core; 2 | using CodeWF.Core.Models; 3 | using CodeWF.Modules.AI.Helpers; 4 | using CodeWF.Modules.AI.Views; 5 | using Ursa.PrismExtension; 6 | 7 | namespace CodeWF.Modules.AI; 8 | 9 | public class AIModule : IModule 10 | { 11 | public AIModule(IToolMenuService toolMenuService) 12 | { 13 | var groupName = Localization.AIModule.Title; 14 | toolMenuService.AddSeparator(); 15 | toolMenuService.AddGroup(groupName, Icons.AI); 16 | toolMenuService.AddItem(Localization.AskBotView.Title, groupName, Localization.AskBotView.Description, nameof(AskBotView), 17 | Icons.AskBot, 18 | ToolStatus.Developing); 19 | toolMenuService.AddItem(Localization.PolyTranslateView.Title, groupName, Localization.PolyTranslateView.Description, 20 | nameof(PolyTranslateView), 21 | Icons.PolyTranslate, 22 | ToolStatus.Complete); 23 | toolMenuService.AddItem(Localization.Title2SlugView.Title, groupName, Localization.Title2SlugView.Description, nameof(Title2SlugView), 24 | Icons.Title2Slug, 25 | ToolStatus.Complete); 26 | } 27 | 28 | public void OnInitialized(IContainerProvider containerProvider) 29 | { 30 | IRegionManager? regionManager = containerProvider.Resolve(); 31 | regionManager.RegisterViewWithRegion(RegionNames.ContentRegion); 32 | regionManager.RegisterViewWithRegion(RegionNames.ContentRegion); 33 | regionManager.RegisterViewWithRegion(RegionNames.ContentRegion); 34 | } 35 | 36 | public void RegisterTypes(IContainerRegistry containerRegistry) 37 | { 38 | containerRegistry.Register(); 39 | containerRegistry.RegisterScoped(); 40 | containerRegistry.RegisterUrsaDialogView(DialogNames.ChoiceLanguages); 41 | } 42 | } -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/CodeWF - Backup.Modules.AI.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net9.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | True 22 | True 23 | Language.tt 24 | 25 | 26 | 27 | 28 | 29 | TextTemplatingFileGenerator 30 | Language.cs 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | True 41 | True 42 | Language.tt 43 | 44 | 45 | True 46 | True 47 | Resources.resx 48 | 49 | 50 | 51 | 52 | 53 | ResXFileCodeGenerator 54 | Resources.Designer.cs 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/CodeWF.Modules.AI.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net9.0 5 | enable 6 | enable 7 | $(InterceptorsPreviewNamespaces);Dapper.AOT 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | True 26 | True 27 | Language.tt 28 | 29 | 30 | 31 | 32 | 33 | PreserveNewest 34 | 35 | 36 | PreserveNewest 37 | 38 | 39 | PreserveNewest 40 | 41 | 42 | TextTemplatingFileGenerator 43 | Language.cs 44 | 45 | 46 | PreserveNewest 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | True 57 | True 58 | Language.tt 59 | 60 | 61 | -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/Entities/TranslateLanguageEntity.cs: -------------------------------------------------------------------------------- 1 | namespace CodeWF.Modules.AI.Entities; 2 | 3 | public class TranslateLanguageEntity 4 | { 5 | public string? Languages { get; set; } 6 | } -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/Helpers/ConfigHelper.cs: -------------------------------------------------------------------------------- 1 | using CodeWF.Core.ConfigDB; 2 | using CodeWF.Modules.AI.Entities; 3 | using Dapper; 4 | using Microsoft.Data.Sqlite; 5 | 6 | namespace CodeWF.Modules.AI.Helpers; 7 | 8 | public static class ConfigHelper 9 | { 10 | [DapperAot] 11 | public static bool EnsureTableIsCreated() 12 | { 13 | try 14 | { 15 | using var connection = new SqliteConnection(DBConst.DBConnectionString); 16 | connection.Open(); 17 | 18 | const string sql = $@" 19 | CREATE TABLE IF NOT EXISTS {nameof(TranslateLanguageEntity)}( 20 | {nameof(TranslateLanguageEntity.Languages)} VARCHAR(3072) 21 | )"; 22 | 23 | using var command = new SqliteCommand(sql, connection); 24 | return command.ExecuteNonQuery() > 0; 25 | } 26 | catch (Exception ex) 27 | { 28 | return false; 29 | } 30 | } 31 | 32 | [DapperAot] 33 | public static List? GetTranslateLanguages() 34 | { 35 | try 36 | { 37 | EnsureTableIsCreated(); 38 | 39 | using var connection = new SqliteConnection(DBConst.DBConnectionString); 40 | connection.Open(); 41 | 42 | const string sql = 43 | $@"SELECT {nameof(TranslateLanguageEntity.Languages)} FROM {nameof(TranslateLanguageEntity)}"; 44 | var config = connection.QueryFirstOrDefault(sql); 45 | 46 | return config?.Languages?.Split(',').ToList(); 47 | } 48 | catch (Exception ex) 49 | { 50 | return default; 51 | } 52 | } 53 | 54 | [DapperAot] 55 | public static bool UpdateTranslateLanguages(List? languages) 56 | { 57 | try 58 | { 59 | EnsureTableIsCreated(); 60 | 61 | using var connection = new SqliteConnection(DBConst.DBConnectionString); 62 | connection.Open(); 63 | connection.Execute($"DELETE FROM {nameof(TranslateLanguageEntity)}"); 64 | if (languages?.Any() != true) 65 | { 66 | return false; 67 | } 68 | 69 | var languageStr = string.Join(",", languages)!; 70 | var result = connection.Execute( 71 | @$"INSERT INTO {nameof(TranslateLanguageEntity)}({nameof(TranslateLanguageEntity.Languages)}) 72 | VALUES(@{nameof(TranslateLanguageEntity.Languages)})", 73 | new { Languages = languageStr }); 74 | return result > 0; 75 | } 76 | catch (Exception ex) 77 | { 78 | return false; 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/I18n/AIModule.en-US.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | AI 6 | 7 | 8 | Intelligent Question and Answer Assistant 9 | Ask questions with one click and get answers immediately. The intelligent question and answer assistant will help you solve your doubts. 10 | 11 | 12 | AI One-Click Multi-language Translation Tool 13 | Easily achieve one-click translation, support mutual translation among multiple languages, and make communication without boundaries! 14 | 15 | 16 | AI One-Click Conversion to URL Slug 17 | Effortlessly convert article titles in Chinese, English and other languages into English URL Slugs with just one click. 18 | 19 | 20 | Language 21 | Selectable 22 | Selected 23 | 24 | -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/I18n/AIModule.ja-JP.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | AI(人工知能) 6 | 7 | 8 | 知能質問応答アシスタント 9 | ワンクリックで質問を投げると、すぐに回答を得ることができます。知能質問応答アシスタントがあなたの疑問を解決します。 10 | 11 | 12 | AIワンクリック多言語翻訳ツール 13 | 簡単にワンクリック翻訳が可能で、多言語間の相互翻訳をサポートし、コミュニケーションに境界を設けません! 14 | 15 | 16 | AIワンクリックでURLスラグに変換 17 | 簡単に中国語、英語などの記事タイトルをワンクリックで英語のURLスラグに変換できます。 18 | 19 | 20 | 言語 21 | 選択可能な 22 | 選択された 23 | 24 | -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/I18n/AIModule.zh-CN.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | AI 6 | 7 | 8 | 智能问答助手 9 | 一键提问,即刻获取答案,智能问答助手为您解惑。 10 | 11 | 12 | AI一键多语种翻译神器 13 | 轻松实现一键翻译,支持多种语言互译,让沟通无界限! 14 | 15 | 16 | AI一键转URL Slug 17 | 轻松将中文、英文等文章标题一键转换成英文URL Slug。 18 | 19 | 20 | 语言 21 | 可选择的 22 | 已选择 23 | 24 | -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/I18n/AIModule.zh-Hant.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 人工智能 6 | 7 | 8 | 智能問答助手 9 | 一鍵提問,即刻獲取答案,智能問答助手為您解惑。 10 | 11 | 12 | 人工智能一鍵多語種翻譯神器 13 | 輕鬆實現一鍵翻譯,支持多種語言互譯,讓溝通無界限! 14 | 15 | 16 | 人工智能一鍵轉URL Slug 17 | 輕鬆將中文、英文等文章標題一鍵轉換成英文URL Slug。 18 | 19 | 20 | 語言 21 | 可選擇的 22 | 已選擇 23 | 24 | -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/I18n/Language.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Changes to this file may cause incorrect behavior and will be lost if 5 | // the code is regenerated. 6 | // 7 | //------------------------------------------------------------------------------ 8 | namespace Localization 9 | { 10 | public static class AIModule 11 | { 12 | public static readonly string Title = "Localization.AIModule.Title"; 13 | } 14 | } 15 | namespace Localization 16 | { 17 | public static class AskBotView 18 | { 19 | public static readonly string Title = "Localization.AskBotView.Title"; 20 | public static readonly string Description = "Localization.AskBotView.Description"; 21 | } 22 | } 23 | namespace Localization 24 | { 25 | public static class PolyTranslateView 26 | { 27 | public static readonly string Title = "Localization.PolyTranslateView.Title"; 28 | public static readonly string Description = "Localization.PolyTranslateView.Description"; 29 | } 30 | } 31 | namespace Localization 32 | { 33 | public static class Title2SlugView 34 | { 35 | public static readonly string Title = "Localization.Title2SlugView.Title"; 36 | public static readonly string Description = "Localization.Title2SlugView.Description"; 37 | } 38 | } 39 | namespace Localization 40 | { 41 | public static class ChoiceLanguagesView 42 | { 43 | public static readonly string LanguageKey = "Localization.ChoiceLanguagesView.LanguageKey"; 44 | public static readonly string Selectable = "Localization.ChoiceLanguagesView.Selectable"; 45 | public static readonly string Selected = "Localization.ChoiceLanguagesView.Selected"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/I18n/Language.tt: -------------------------------------------------------------------------------- 1 | <#@ template debug="false" hostspecific="true" language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ assembly name="System.Xml" #> 4 | <#@ assembly name="System.Xml.Linq" #> 5 | <#@ import namespace="System.Linq" #> 6 | <#@ import namespace="System.Text" #> 7 | <#@ import namespace="System.Collections.Generic" #> 8 | <#@ import namespace="System.Xml.Linq" #> 9 | <#@ import namespace="System.IO" #> 10 | <#@ output extension=".cs" #> 11 | //------------------------------------------------------------------------------ 12 | // 13 | // This code was generated by a tool. 14 | // Changes to this file may cause incorrect behavior and will be lost if 15 | // the code is regenerated. 16 | // 17 | //------------------------------------------------------------------------------ 18 | <# 19 | string templateDirectory = Path.GetDirectoryName(Host.TemplateFile); 20 | string xmlFilePath = Directory.GetFiles(templateDirectory, "*.xml").FirstOrDefault(); 21 | if (xmlFilePath!= null) 22 | { 23 | XDocument xdoc = XDocument.Load(xmlFilePath); 24 | var classNodes = xdoc.Nodes().OfType().DescendantsAndSelf().Where(e => e.Descendants().Count() == 0).Select(e => e.Parent).Distinct().ToList(); 25 | foreach (var classNode in classNodes) 26 | { 27 | var namespaceSegments = classNode.Ancestors().Reverse().Select(node => node.Name.LocalName); 28 | string namespaceName = string.Join(".", namespaceSegments); 29 | GenerateClasses(classNode, namespaceName); 30 | } 31 | } 32 | else 33 | { 34 | Write("XML file not found, please ensure that there is an XML file in the current directory"); 35 | } 36 | 37 | void GenerateClasses(XElement element, string namespaceName) 38 | { 39 | string className = element.Name.LocalName; 40 | StringBuilder classBuilder = new StringBuilder(); 41 | classBuilder.AppendLine($"namespace {namespaceName}"); 42 | classBuilder.AppendLine("{"); 43 | classBuilder.AppendLine($" public static class {className}"); 44 | classBuilder.AppendLine(" {"); 45 | var fieldNodes = element.Elements(); 46 | foreach (var fieldNode in fieldNodes) 47 | { 48 | var propertyName = fieldNode.Name.LocalName; 49 | var languageKey = $"{namespaceName}.{className}.{propertyName}"; 50 | classBuilder.AppendLine($" public static readonly string {propertyName} = \"{languageKey}\";"); 51 | } 52 | classBuilder.AppendLine(" }"); 53 | classBuilder.AppendLine("}"); 54 | Write(classBuilder.ToString()); 55 | } 56 | #> 57 | -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/Icons.cs: -------------------------------------------------------------------------------- 1 | namespace CodeWF.Modules.AI; 2 | 3 | internal class Icons 4 | { 5 | public const string AI = 6 | "M512 85.333333c235.648 0 426.666667 191.018667 426.666667 426.666667s-191.018667 426.666667-426.666667 426.666667S85.333333 747.648 85.333333 512 276.352 85.333333 512 85.333333z m0 85.333334a341.333333 341.333333 0 1 0 0 682.666666 341.333333 341.333333 0 0 0 0-682.666666z m-40.405333 156.586666l121.856 369.706667h-83.968l-27.050667-89.685333H361.898667l-27.648 89.685333H256L378.453333 327.253333h93.141334z m256.213333 0v369.706667h-78.549333V327.253333h78.506666z m-303.36 75.562667H420.693333l-43.306666 144.64h89.898666L424.448 402.773333z"; 7 | 8 | public const string AskBot = 9 | "M682.592 341.408l0-255.904-597.088 0 0 460.608 255.904 0 0 255.904 354.016 0 136.48 136.448 21.28 0 0-136.448 85.312 0 0-460.608-255.904 0zM119.616 512l0-392.384 528.864 0 0 221.792-307.072 0 0 170.592-221.792 0zM904.384 767.904l-85.312 0 0 109.504-109.536-109.504-334.048 0 0-392.384 528.864 0 0 392.384z"; 10 | 11 | public const string PolyTranslate = 12 | "M744.448 478.122667l149.333333 384a32 32 0 0 1-59.648 23.210666l-37.674666-96.810666H632.746667l-37.546667 96.810666a32 32 0 0 1-37.290667 19.498667l-4.181333-1.28a32 32 0 0 1-18.218667-41.386667l149.333334-384c10.581333-27.221333 49.066667-27.221333 59.648 0zM160.042667 650.666667a32 32 0 0 1 32 32v96.085333c0 27.605333 20.992 50.346667 47.914666 53.077333l5.418667 0.256a32 32 0 1 1 0 64 117.333333 117.333333 0 0 1-117.333333-117.333333V682.666667a32 32 0 0 1 32-32z m554.581333-72.618667l-57.045333 146.474667h114.005333l-56.96-146.474667zM341.333333 127.829333a32 32 0 0 1 32 32v21.461334l74.666667 0.042666a96 96 0 0 1 96 96v85.333334a96 96 0 0 1-96 96H373.333333v102.528a32 32 0 1 1-64 0V458.666667l-74.666666 0.042666A96 96 0 0 1 138.666667 362.666667v-85.333334A96 96 0 0 1 234.666667 181.333333h74.666666v-21.504a32 32 0 0 1 32-32zM309.333333 245.333333L234.666667 245.333333a32 32 0 0 0-32 32v85.333334c0 17.664 14.336 32 32 32h74.666666v-149.333334z m138.666667 0.042667H373.333333v149.333333h74.666667a32 32 0 0 0 32-32v-85.333333a32 32 0 0 0-32-32z m330.666667-117.504A117.333333 117.333333 0 0 1 896 245.162667V341.333333a32 32 0 0 1-64 0V245.162667a53.333333 53.333333 0 0 0-47.914667-53.034667l-5.461333-0.298667a32 32 0 1 1 0-64z"; 13 | 14 | public const string Title2Slug = "M682.666667 256h-128v81.066667h128a174.933333 174.933333 0 0 1 174.933333 174.933333 174.933333 174.933333 0 0 1-174.933333 174.933333h-128V768h128a256 256 0 0 0 256-256c0-141.653333-114.773333-256-256-256M166.4 512A174.933333 174.933333 0 0 1 341.333333 337.066667h128V256H341.333333a256 256 0 0 0-256 256 256 256 0 0 0 256 256h128v-81.066667H341.333333c-96.426667 0-174.933333-78.506667-174.933333-174.933333M341.333333 554.666667h341.333334v-85.333334H341.333333v85.333334z"; 15 | } -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/Imports.cs: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/Models/AskBotRequest.cs: -------------------------------------------------------------------------------- 1 | namespace CodeWF.Modules.AI.Models; 2 | 3 | public record AskBotRequest(string Content); -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/Models/ChatGptOptions.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace CodeWF.Modules.AI.Models; 4 | 5 | internal class ChatGptOptions 6 | { 7 | private const string BaseUrl = "https://dotnet9.com/"; 8 | 9 | public string AskBotHttpUrl { get; set; } = $"{BaseUrl}ai/askbot"; 10 | public string PolyTranslateHttpUrl { get; set; } = $"{BaseUrl}ai/polytranslate"; 11 | public string Title2SlugHttpUrl { get; set; } = $"{BaseUrl}ai/title2slug"; 12 | } -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/Models/PolyTranslateRequest.cs: -------------------------------------------------------------------------------- 1 | namespace CodeWF.Modules.AI.Models; 2 | 3 | public record PolyTranslateRequest(string Content, List Languages); -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/Models/Title2SlugRequest.cs: -------------------------------------------------------------------------------- 1 | namespace CodeWF.Modules.AI.Models; 2 | 3 | public record Title2SlugRequest(string Content); -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/ViewModels/AskBotViewModel.cs: -------------------------------------------------------------------------------- 1 | using CodeWF.Modules.AI.Helpers; 2 | using CodeWF.Modules.AI.Models; 3 | using ReactiveUI; 4 | using System.Reactive; 5 | 6 | namespace CodeWF.Modules.AI.ViewModels; 7 | 8 | public class AskBotViewModel : ReactiveObject 9 | { 10 | private readonly ApiClient _apiClient; 11 | private readonly ChatGptOptions _chatGptOptions = new(); 12 | 13 | public AskBotViewModel(ApiClient apiClient) 14 | { 15 | _apiClient = apiClient; 16 | RaiseAskAICommand = ReactiveCommand.CreateFromTask(RaiseAskAICommandHandlerAsync); 17 | } 18 | 19 | private string? _askContent; 20 | 21 | public string? AskContent 22 | { 23 | get => _askContent; 24 | set => this.RaiseAndSetIfChanged(ref _askContent, value); 25 | } 26 | 27 | private string? _responseContent; 28 | 29 | public string? ResponseContent 30 | { 31 | get => _responseContent; 32 | set => this.RaiseAndSetIfChanged(ref _responseContent, value); 33 | } 34 | 35 | public ReactiveCommand RaiseAskAICommand { get; } 36 | 37 | private async Task RaiseAskAICommandHandlerAsync() 38 | { 39 | if (string.IsNullOrWhiteSpace(AskContent)) 40 | { 41 | return; 42 | } 43 | 44 | if (!string.IsNullOrWhiteSpace(ResponseContent)) 45 | { 46 | ResponseContent = ""; 47 | } 48 | 49 | try 50 | { 51 | await _apiClient.CreateChatGptClient(_chatGptOptions.AskBotHttpUrl, new AskBotRequest(AskContent), result => 52 | { 53 | ResponseContent += result; 54 | }, status => 55 | { 56 | //AskContent = string.Empty; 57 | }); 58 | } 59 | catch (Exception ex) 60 | { 61 | ResponseContent = ex.Message; 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/ViewModels/ChoiceLanguagesViewModel.cs: -------------------------------------------------------------------------------- 1 | using CodeWF.AvaloniaControls.Extensions; 2 | 3 | namespace CodeWF.Modules.AI.ViewModels; 4 | 5 | public class ChoiceLanguagesViewModel 6 | { 7 | public RangeObservableCollection SelectedLanguages { get; set; } 8 | 9 | public RangeObservableCollection AllLanguages { get; set; } 10 | } -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/ViewModels/Title2SlugViewModel.cs: -------------------------------------------------------------------------------- 1 | using CodeWF.Modules.AI.Helpers; 2 | using CodeWF.Modules.AI.Models; 3 | using ReactiveUI; 4 | using System.Reactive; 5 | 6 | namespace CodeWF.Modules.AI.ViewModels; 7 | 8 | public class Title2SlugViewModel : ReactiveObject 9 | { 10 | private readonly ApiClient _apiClient; 11 | private readonly ChatGptOptions _chatGptOptions = new(); 12 | 13 | public Title2SlugViewModel(ApiClient apiClient) 14 | { 15 | _apiClient = apiClient; 16 | RaiseConvertCommand = ReactiveCommand.CreateFromTask(RaiseConvertCommandHandlerAsync); 17 | } 18 | 19 | private string? _askContent; 20 | 21 | public string? AskContent 22 | { 23 | get => _askContent; 24 | set => this.RaiseAndSetIfChanged(ref _askContent, value); 25 | } 26 | 27 | private string? _responseContent; 28 | 29 | public string? ResponseContent 30 | { 31 | get => _responseContent; 32 | set => this.RaiseAndSetIfChanged(ref _responseContent, value); 33 | } 34 | 35 | public ReactiveCommand RaiseConvertCommand { get; } 36 | 37 | private async Task RaiseConvertCommandHandlerAsync() 38 | { 39 | if (string.IsNullOrWhiteSpace(AskContent)) 40 | { 41 | return; 42 | } 43 | 44 | if (!string.IsNullOrWhiteSpace(ResponseContent)) 45 | { 46 | ResponseContent = ""; 47 | } 48 | 49 | try 50 | { 51 | await _apiClient.CreateChatGptClient(_chatGptOptions.Title2SlugHttpUrl, new Title2SlugRequest(AskContent), 52 | result => 53 | { 54 | ResponseContent += result; 55 | }, status => 56 | { 57 | //AskContent = string.Empty; 58 | }); 59 | } 60 | catch (Exception ex) 61 | { 62 | ResponseContent = ex.Message; 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /src/CodeWF.Modules.AI/Views/AskBotView.axaml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 15 | 16 |