diff --git a/AbpHelper.CLI b/AbpHelper.CLI index 2836a54..7d15a0e 160000 --- a/AbpHelper.CLI +++ b/AbpHelper.CLI @@ -1 +1 @@ -Subproject commit 2836a5432534aa0dac5fbc95c47a49f1183d4843 +Subproject commit 7d15a0e4d5db38465f7345eb5734ae05050696ee diff --git a/dotnet/src/EasyAbp.AbpHelper.Gui.Application.Contracts/Localization/Gui/zh-Hans.json b/dotnet/src/EasyAbp.AbpHelper.Gui.Application.Contracts/Localization/Gui/zh-Hans.json index 8a479b4..9597670 100644 --- a/dotnet/src/EasyAbp.AbpHelper.Gui.Application.Contracts/Localization/Gui/zh-Hans.json +++ b/dotnet/src/EasyAbp.AbpHelper.Gui.Application.Contracts/Localization/Gui/zh-Hans.json @@ -1,4 +1,4 @@ -{ +{ "culture": "zh-Hans", "texts": { "Welcome": "欢迎使用", @@ -17,6 +17,11 @@ "SolutionDirectoryPath": "解决方案路径", "SolutionType:Application": "应用", "SolutionType:Module": "模块", + "Template": "模板方案", + "OpenTemplate": "打开模板方案", + "ManageTemplates": "管理模板方案", + "TemplateDisplayName": "名称", + "TemplateDirectoryPath": "模板方案路径", "Use": "使用", "Open": "打开", "Current": "当前", diff --git a/dotnet/src/EasyAbp.AbpHelper.Gui.Application.Contracts/Localization/Gui/zh-Hant.json b/dotnet/src/EasyAbp.AbpHelper.Gui.Application.Contracts/Localization/Gui/zh-Hant.json index 324b2bc..0063c6c 100644 --- a/dotnet/src/EasyAbp.AbpHelper.Gui.Application.Contracts/Localization/Gui/zh-Hant.json +++ b/dotnet/src/EasyAbp.AbpHelper.Gui.Application.Contracts/Localization/Gui/zh-Hant.json @@ -1,4 +1,4 @@ -{ +{ "culture": "zh-Hant", "texts": { "Welcome": "歡迎使用", @@ -17,6 +17,11 @@ "SolutionDirectoryPath": "解決方案路徑", "SolutionType:Application": "應用", "SolutionType:Module": "模塊", + "Template": "範本方案", + "OpenTemplate": "打開範本方案", + "ManageTemplates": "管理範本方案", + "TemplateDisplayName": "名稱", + "TemplateDirectoryPath": "範本方案路徑", "Use": "使用", "Open": "打開", "NoDataAvailable": "無可用數據", diff --git a/dotnet/src/EasyAbp.AbpHelper.Gui.Application.Contracts/Shared/Dtos/InputDtoWithDirectory.cs b/dotnet/src/EasyAbp.AbpHelper.Gui.Application.Contracts/Shared/Dtos/InputDtoWithDirectory.cs index fd1d720..ebcd1c9 100644 --- a/dotnet/src/EasyAbp.AbpHelper.Gui.Application.Contracts/Shared/Dtos/InputDtoWithDirectory.cs +++ b/dotnet/src/EasyAbp.AbpHelper.Gui.Application.Contracts/Shared/Dtos/InputDtoWithDirectory.cs @@ -9,11 +9,14 @@ public class InputDtoWithDirectory [NotNull] public virtual string Directory { get; set; } + [CanBeNull] + public virtual string TemplatePath { get; set; } + protected InputDtoWithDirectory() { - + } - + public InputDtoWithDirectory([NotNull] string directory) { Directory = directory; diff --git a/dotnet/src/EasyAbp.AbpHelper.Gui.Application.Contracts/Templates/Dtos/TemplateDto.cs b/dotnet/src/EasyAbp.AbpHelper.Gui.Application.Contracts/Templates/Dtos/TemplateDto.cs new file mode 100644 index 0000000..b42fd1f --- /dev/null +++ b/dotnet/src/EasyAbp.AbpHelper.Gui.Application.Contracts/Templates/Dtos/TemplateDto.cs @@ -0,0 +1,23 @@ +using System.ComponentModel.DataAnnotations; +using JetBrains.Annotations; + +namespace EasyAbp.AbpHelper.Gui.Templates.Dtos +{ + public class TemplateDto + { + [Required] + public string DisplayName { get; set; } + + public string DirectoryPath { get; set; } + + public bool Equals([CanBeNull] TemplateDto other) + { + if (other == null) + { + return false; + } + + return DirectoryPath == other.DirectoryPath; + } + } +} \ No newline at end of file diff --git a/dotnet/src/EasyAbp.AbpHelper.Gui.Application.Contracts/Templates/ITemplateAppService.cs b/dotnet/src/EasyAbp.AbpHelper.Gui.Application.Contracts/Templates/ITemplateAppService.cs new file mode 100644 index 0000000..1c1d8a0 --- /dev/null +++ b/dotnet/src/EasyAbp.AbpHelper.Gui.Application.Contracts/Templates/ITemplateAppService.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using EasyAbp.AbpHelper.Gui.Templates.Dtos; +using JetBrains.Annotations; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace EasyAbp.AbpHelper.Gui.Templates +{ + public interface ITemplateAppService : IApplicationService + { + Task> GetListAsync(); + + Task UseAsync(TemplateDto input); + + Task DeleteAsync(TemplateDto input); + } +} \ No newline at end of file diff --git a/dotnet/src/EasyAbp.AbpHelper.Gui.Application/Templates/IRecentlyTemplatesManager.cs b/dotnet/src/EasyAbp.AbpHelper.Gui.Application/Templates/IRecentlyTemplatesManager.cs new file mode 100644 index 0000000..ef6bf2f --- /dev/null +++ b/dotnet/src/EasyAbp.AbpHelper.Gui.Application/Templates/IRecentlyTemplatesManager.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using EasyAbp.AbpHelper.Gui.Templates.Dtos; + +namespace EasyAbp.AbpHelper.Gui.Templates +{ + public interface IRecentlyTemplatesManager + { + Task> GetListAsync(); + + Task UpdateListAsync(List input); + } +} \ No newline at end of file diff --git a/dotnet/src/EasyAbp.AbpHelper.Gui.Application/Templates/RecentlyTemplatesManager.cs b/dotnet/src/EasyAbp.AbpHelper.Gui.Application/Templates/RecentlyTemplatesManager.cs new file mode 100644 index 0000000..b4e139f --- /dev/null +++ b/dotnet/src/EasyAbp.AbpHelper.Gui.Application/Templates/RecentlyTemplatesManager.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using EasyAbp.AbpHelper.Gui.Templates.Dtos; +using Newtonsoft.Json; +using Volo.Abp.DependencyInjection; + +namespace EasyAbp.AbpHelper.Gui.Templates +{ + public class RecentlyTemplatesManager : IRecentlyTemplatesManager, ITransientDependency + { + private static readonly string PersonalDirectoryPath = + Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); + + private static readonly string SettingsDirectoryPath = Path.Combine(PersonalDirectoryPath, ".abphelper-gui"); + + private static readonly string FilePath = Path.Combine(SettingsDirectoryPath, "RecentlyTemplates.json"); + + public async Task> GetListAsync() + { + if (!File.Exists(FilePath)) + { + Directory.CreateDirectory(SettingsDirectoryPath); + + await File.WriteAllTextAsync(FilePath, JsonConvert.SerializeObject(new List())); + } + + var result = JsonConvert.DeserializeObject>(await File.ReadAllTextAsync(FilePath)); + + if (!result.Any(x => x.DisplayName == "Default")) + { + result.Add(new TemplateDto + { + DisplayName = "Default", + DirectoryPath = string.Empty + }); + } + + return result; + } + + public async Task UpdateListAsync(List input) + { + input ??= new List(); + + await File.WriteAllTextAsync(FilePath, JsonConvert.SerializeObject(input)); + } + } +} \ No newline at end of file diff --git a/dotnet/src/EasyAbp.AbpHelper.Gui.Application/Templates/TemplateAppService.cs b/dotnet/src/EasyAbp.AbpHelper.Gui.Application/Templates/TemplateAppService.cs new file mode 100644 index 0000000..c0faa8b --- /dev/null +++ b/dotnet/src/EasyAbp.AbpHelper.Gui.Application/Templates/TemplateAppService.cs @@ -0,0 +1,93 @@ +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using EasyAbp.AbpHelper.Core.Services; +using EasyAbp.AbpHelper.Gui.Templates.Dtos; +using JetBrains.Annotations; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace EasyAbp.AbpHelper.Gui.Templates +{ + public class TemplateAppService : ApplicationService, ITemplateAppService + { + private const byte RecentlyTemplatesMaxCount = 10; + + private readonly IRecentlyTemplatesManager _manager; + + public TemplateAppService( + IRecentlyTemplatesManager manager) + { + _manager = manager; + } + + public virtual async Task> GetListAsync() + { + return new(await _manager.GetListAsync()); + } + + public virtual async Task UseAsync(TemplateDto input) + { + Check.NotNullOrWhiteSpace(input.DisplayName, nameof(input.DisplayName)); + + var list = await _manager.GetListAsync(); + + var template = FindTemplate(list, input); + + if (template == null) + { + template = input; + + list.AddFirst(template); + } + else + { + list.MoveItem((x) => x == template, 0); + } + + if (!await IsTemplateDirectoryValidAsync(template)) + { + list.RemoveAt(0); + + await UpdateRecentlyTemplateListAsync(list); + + throw new BusinessException("Gui:InvalidTemplateDirectoryPath"); + } + + await UpdateRecentlyTemplateListAsync(list); + + return input; + } + + protected virtual async Task UpdateRecentlyTemplateListAsync(List list) + { + if (list.Count > RecentlyTemplatesMaxCount) + { + list = list.GetRange(0, RecentlyTemplatesMaxCount); + } + + await _manager.UpdateListAsync(list); + } + + protected virtual Task IsTemplateDirectoryValidAsync(TemplateDto template) + { + return Task.FromResult(string.IsNullOrWhiteSpace(template.DirectoryPath) || Directory.Exists(template.DirectoryPath)); + } + + protected virtual TemplateDto FindTemplate(IEnumerable templates, TemplateDto target) + { + return templates.FirstOrDefault(x => x.DirectoryPath == target.DirectoryPath); + } + + public virtual async Task DeleteAsync(TemplateDto input) + { + var list = await _manager.GetListAsync(); + + list.Remove(FindTemplate(list, input)); + + await UpdateRecentlyTemplateListAsync(list); + } + } +} \ No newline at end of file diff --git a/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Shared/ExecutableComponentBaseWithCurrentSolution.cs b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Shared/ExecutableComponentBaseWithCurrentSolution.cs index 5bb063d..62e5de0 100644 --- a/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Shared/ExecutableComponentBaseWithCurrentSolution.cs +++ b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Shared/ExecutableComponentBaseWithCurrentSolution.cs @@ -9,15 +9,20 @@ public abstract class ExecutableComponentBaseWithCurrentSolution : ExecutableCom { [Inject] private ICurrentSolution CurrentSolution { get; set; } - + + [Inject] + private ICurrentTemplate CurrentTemplate { get; set; } + protected override void OnInitialized() { CurrentSolution.OnChangeAsync += CurrentSolutionChangedAsync; + CurrentTemplate.OnChangeAsync += CurrentTemplateChangedAsync; } public void Dispose() { CurrentSolution.OnChangeAsync -= CurrentSolutionChangedAsync; + CurrentTemplate.OnChangeAsync -= CurrentTemplateChangedAsync; } protected virtual async Task CurrentSolutionChangedAsync() @@ -28,5 +33,14 @@ protected virtual async Task CurrentSolutionChangedAsync() } protected abstract Task OnCurrentSolutionChangedAsync(); + + protected virtual async Task CurrentTemplateChangedAsync() + { + await OnCurrentTemplateChangedAsync(); + + StateHasChanged(); + } + + protected abstract Task OnCurrentTemplateChangedAsync(); } } diff --git a/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Shared/ExecutableComponentBaseWithDirectory.cs b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Shared/ExecutableComponentBaseWithDirectory.cs index 882ed7e..a908f72 100644 --- a/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Shared/ExecutableComponentBaseWithDirectory.cs +++ b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Shared/ExecutableComponentBaseWithDirectory.cs @@ -9,26 +9,42 @@ namespace EasyAbp.AbpHelper.Gui.Blazor.Pages.Shared { [Inject] protected ICurrentSolution CurrentSolution { get; set; } - + + [Inject] + protected ICurrentTemplate CurrentTemplate { get; set; } + protected TInput Input { get; set; } = new(); - + protected override Task OnInitializedAsync() { SetDirectoryToCurrentSolutionPath(); - + SetDirectoryToCurrentTemplatePath(); + return base.OnInitializedAsync(); } protected override Task OnCurrentSolutionChangedAsync() { SetDirectoryToCurrentSolutionPath(); - + return Task.CompletedTask; } - + protected virtual void SetDirectoryToCurrentSolutionPath() { Input.Directory = CurrentSolution.Value?.DirectoryPath ?? string.Empty; } + + protected override Task OnCurrentTemplateChangedAsync() + { + SetDirectoryToCurrentTemplatePath(); + + return Task.CompletedTask; + } + + protected virtual void SetDirectoryToCurrentTemplatePath() + { + Input.TemplatePath = CurrentTemplate.Value?.DirectoryPath ?? string.Empty; + } } } \ No newline at end of file diff --git a/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Templates/Components/TemplateSwitch.razor b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Templates/Components/TemplateSwitch.razor new file mode 100644 index 0000000..5c5dbc3 --- /dev/null +++ b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Templates/Components/TemplateSwitch.razor @@ -0,0 +1,67 @@ +@using EasyAbp.AbpHelper.Gui.Templates.Dtos +@inherits EasyAbp.AbpHelper.Gui.Blazor.Pages.Templates.Shared.TemplateManagementBase +@{ + var templateDefault = new TemplateDto() { DisplayName = "Default", DirectoryPath = "" }; + +} + + + + @L["Template"]|@(CurrentTemplate.Value?.DisplayName ?? L["Default"]) + + + @foreach (var template in Templates) + { + + @template.DisplayName @if (CurrentTemplate.Value.Equals(template)) + { + @($" ({L["Current"].Value})") + } + + } + + @L["OpenTemplate"] + + + @L["ManageTemplates"] + + + + + + + + + @L["OpenTemplate"] + + + + + + + @L["TemplateDisplayName"] + + + + + + + + + + @L["TemplateDirectoryPath"] + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Templates/Components/TemplateSwitch.razor.cs b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Templates/Components/TemplateSwitch.razor.cs new file mode 100644 index 0000000..3176b40 --- /dev/null +++ b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Templates/Components/TemplateSwitch.razor.cs @@ -0,0 +1,23 @@ +using System.Threading.Tasks; +using Blazorise; +using Microsoft.AspNetCore.Components; + +namespace EasyAbp.AbpHelper.Gui.Blazor.Pages.Templates.Components +{ + public partial class TemplateSwitch + { + private readonly NavigationManager _navigationManager; + + public TemplateSwitch(NavigationManager navigationManager) + { + _navigationManager = navigationManager; + } + + private Task RedirectToTemplatesPageAsync() + { + _navigationManager.NavigateTo("/Templates"); + + return Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Templates/Index.razor b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Templates/Index.razor new file mode 100644 index 0000000..f21d82a --- /dev/null +++ b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Templates/Index.razor @@ -0,0 +1,91 @@ +@page "/Templates" +@using Volo.Abp.AspNetCore.Components.Web +@using EasyAbp.AbpHelper.Gui.Localization +@using EasyAbp.AbpHelper.Gui.Templates.Dtos +@using EasyAbp.AbpHelper.Gui.Blazor.Pages.Templates.Components; +@inherits EasyAbp.AbpHelper.Gui.Blazor.Pages.Templates.Shared.TemplateManagementBase + + + + @* ************************* PAGE HEADER ************************* *@ + + +

@L["ManageTemplates"]

+
+ + +
+
+ + + + + + + + + + + + + + @(context.DisplayName) @if (CurrentTemplate.Value.Equals(context)) + { + @($" ({L["Current"].Value})") + } + + + + + @(context.DirectoryPath) + + + + + +
+ + + + + @L["OpenTemplate"] + + + + + + + @L["TemplateDisplayName"] + + + + + + + + + + @L["TemplateDirectoryPath"] + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Templates/Index.razor.cs b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Templates/Index.razor.cs new file mode 100644 index 0000000..934f478 --- /dev/null +++ b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Templates/Index.razor.cs @@ -0,0 +1,21 @@ +using EasyAbp.AbpHelper.Gui.Templates.Dtos; +using Localization.Resources.AbpUi; +using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Localization; +using Volo.Abp.BlazoriseUI.Components; + +namespace EasyAbp.AbpHelper.Gui.Blazor.Pages.Templates +{ + public partial class Index + { + [Inject] + private IStringLocalizer UiLocalizer { get; set; } + + private DataGridEntityActionsColumn EntityActionsColumn { get; set; } + + protected virtual string GetDeleteConfirmationMessage(TemplateDto template) + { + return UiLocalizer["ItemWillBeDeletedMessage"]; + } + } +} diff --git a/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Templates/Shared/TemplateManagementBase.cs b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Templates/Shared/TemplateManagementBase.cs new file mode 100644 index 0000000..2bea02f --- /dev/null +++ b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Pages/Templates/Shared/TemplateManagementBase.cs @@ -0,0 +1,130 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Blazorise; +using EasyAbp.AbpHelper.Gui.Blazor.Services; +using EasyAbp.AbpHelper.Gui.Localization; +using EasyAbp.AbpHelper.Gui.Templates; +using EasyAbp.AbpHelper.Gui.Templates.Dtos; +using Microsoft.AspNetCore.Components; +using Volo.Abp.AspNetCore.Components.Web; + +namespace EasyAbp.AbpHelper.Gui.Blazor.Pages.Templates.Shared +{ + public class TemplateManagementBase : GuiComponentBase, IDisposable + { + protected IReadOnlyList Templates = new List(); + + [Inject] + protected NavigationManager NavigationManager { get; set; } + + [Inject] + protected ICurrentTemplate CurrentTemplate { get; set; } + + [Inject] + protected AbpBlazorMessageLocalizerHelper Lh { get; set; } + + [Inject] + protected ITemplateAppService TemplateAppService { get; set; } + + protected Modal Modal; + + protected Validations ValidationsRef; + + protected virtual TemplateDto CreateTemplate { get; set; } = new(); + + protected override async Task OnInitializedAsync() + { + await RefreshTemplates(); + } + + protected virtual async Task RefreshTemplates() + { + var templates = await TemplateAppService.GetListAsync(); + + Templates = templates.Items; + + var targetTemplate = Templates.Count > 0 ? Templates[0] : null; + + if (targetTemplate == null && CurrentTemplate.Value != null || + targetTemplate != null && !targetTemplate.Equals(CurrentTemplate.Value)) + { + await CurrentTemplate.SetAsync(targetTemplate); + } + } + + protected virtual async Task ChangeTemplateAsync(TemplateDto templateDto) + { + try + { + await TemplateAppService.UseAsync(templateDto); + } + finally + { + await RefreshTemplates(); + } + } + + protected virtual Task OpenOpenTemplateModalAsync() + { + CreateTemplate = new TemplateDto(); + + Modal.Show(); + + return Task.CompletedTask; + } + + protected virtual void CloseOpenTemplateModal() + { + Modal.Hide(); + } + + protected virtual async Task OpenTemplateExecuteAsync() + { + try + { + var validate = true; + if (ValidationsRef != null) + { + validate = await ValidationsRef.ValidateAll(); + } + if (validate) + { + await TemplateAppService.UseAsync(CreateTemplate); + + await Modal.Hide(); + + await RefreshTemplates(); + } + } + catch (Exception ex) + { + await HandleErrorAsync(ex); + } + } + + protected virtual async Task DeleteTemplateAsync(TemplateDto template) + { + await TemplateAppService.DeleteAsync(template); + + await RefreshTemplates(); + } + + protected override void OnInitialized() + { + CurrentTemplate.OnChangeAsync += StateHasChangedAsync; + } + + public void Dispose() + { + CurrentTemplate.OnChangeAsync -= StateHasChangedAsync; + } + + protected virtual Task StateHasChangedAsync() + { + StateHasChanged(); + + return Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Services/CurrentTemplate.cs b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Services/CurrentTemplate.cs new file mode 100644 index 0000000..cd28ea3 --- /dev/null +++ b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Services/CurrentTemplate.cs @@ -0,0 +1,26 @@ +using System; +using System.Threading.Tasks; +using EasyAbp.AbpHelper.Gui.Templates.Dtos; +using Volo.Abp.DependencyInjection; + +namespace EasyAbp.AbpHelper.Gui.Blazor.Services +{ + public class CurrentTemplate : ICurrentTemplate, ISingletonDependency + { + public TemplateDto Value { get; private set; } + + public virtual async Task SetAsync(TemplateDto templateDto) + { + Value = templateDto; + + if (OnChangeAsync != null) + { + await NotifyStateChanged(); + } + } + + public event Func OnChangeAsync; + + private Task NotifyStateChanged() => OnChangeAsync?.Invoke(); + } +} \ No newline at end of file diff --git a/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Services/ICurrentTemplate.cs b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Services/ICurrentTemplate.cs new file mode 100644 index 0000000..cada8dc --- /dev/null +++ b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Services/ICurrentTemplate.cs @@ -0,0 +1,15 @@ +using System; +using System.Threading.Tasks; +using EasyAbp.AbpHelper.Gui.Templates.Dtos; + +namespace EasyAbp.AbpHelper.Gui.Blazor.Services +{ + public interface ICurrentTemplate + { + TemplateDto Value { get; } + + Task SetAsync(TemplateDto templateDto); + + event Func OnChangeAsync; + } +} \ No newline at end of file diff --git a/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Toolbars/GuiToolbarContributor.cs b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Toolbars/GuiToolbarContributor.cs index 30a5f05..3da3ee5 100644 --- a/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Toolbars/GuiToolbarContributor.cs +++ b/dotnet/src/EasyAbp.AbpHelper.Gui.Blazor/Toolbars/GuiToolbarContributor.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using EasyAbp.AbpHelper.Gui.Blazor.Pages.LogService.Components; using EasyAbp.AbpHelper.Gui.Blazor.Pages.Solutions.Components; +using EasyAbp.AbpHelper.Gui.Blazor.Pages.Templates.Components; using Volo.Abp.AspNetCore.Components.Server.LeptonXLiteTheme.Themes.LeptonXLite.Toolbar; using Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars; @@ -14,12 +15,14 @@ public Task ConfigureToolbarAsync(IToolbarConfigurationContext context) { return Task.CompletedTask; } - + // Remove the login item. context.Toolbar.Items.RemoveAll(x => x.ComponentType == typeof(UserMenuComponent)); - + context.Toolbar.Items.Insert(0, new ToolbarItem(typeof(Logs))); - + + context.Toolbar.Items.Add(new ToolbarItem(typeof(TemplateSwitch))); + context.Toolbar.Items.Add(new ToolbarItem(typeof(SolutionSwitch))); return Task.CompletedTask;