From 70ecd183636039cb1cb16d1311c7fa6d6d539256 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 28 May 2020 23:10:25 +0800 Subject: [PATCH] Improve --- .../Pages/Abp/MultiTenancy/tenant-switch.js | 5 +---- .../Themes/Basic/Layouts/Account.cshtml | 6 +++++- .../Themes/Basic/Layouts/Application.cshtml | 6 +++++- .../Themes/Basic/Layouts/Empty.cshtml | 6 +++++- .../Themes/Basic/_ViewImports.cshtml | 3 ++- .../bootstrap/modal-manager.js | 12 ++++-------- .../Mvc/UI/RazorPages/AbpRazorPage.cs | 17 +++++++++++++++++ ...pApplicationConfigurationScriptController.cs | 2 -- .../Pages/VirtualFileExplorer/Index.cshtml.cs | 14 +++----------- 9 files changed, 42 insertions(+), 29 deletions(-) create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpRazorPage.cs diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/tenant-switch.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/tenant-switch.js index 106eea205a..0644ad0934 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/tenant-switch.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/tenant-switch.js @@ -1,13 +1,10 @@ (function($) { - var tenantSwitchModal = new abp.ModalManager(); + var tenantSwitchModal = new abp.ModalManager(abp.appPath + 'Abp/MultiTenancy/TenantSwitchModal'); $(function() { $('#AbpTenantSwitchLink').click(function(e) { e.preventDefault(); - tenantSwitchModal.setOptions({ - viewUrl : abp.appPath + 'Abp/MultiTenancy/TenantSwitchModal' - }) tenantSwitchModal.open(); }); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml index d3d4dbfb10..3df66f85fa 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml @@ -46,6 +46,10 @@ @await Component.InvokeAsync(typeof(WidgetStylesViewComponent)) + + @await Component.InvokeLayoutHookAsync(LayoutHooks.Head.Last, StandardLayouts.Account) @@ -101,4 +105,4 @@ @await Component.InvokeLayoutHookAsync(LayoutHooks.Body.Last, StandardLayouts.Account) - \ No newline at end of file + diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Application.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Application.cshtml index 2f3b2869f3..75d3453e1c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Application.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Application.cshtml @@ -48,6 +48,10 @@ @await RenderSectionAsync("styles", false) + + @await Component.InvokeLayoutHookAsync(LayoutHooks.Head.Last, StandardLayouts.Application) @@ -76,4 +80,4 @@ @await Component.InvokeLayoutHookAsync(LayoutHooks.Body.Last, StandardLayouts.Application) - \ No newline at end of file + diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Empty.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Empty.cshtml index 6e47a10c33..06708bb95c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Empty.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Empty.cshtml @@ -50,6 +50,10 @@ @await RenderSectionAsync("styles", false) + + @await Component.InvokeLayoutHookAsync(LayoutHooks.Head.Last, StandardLayouts.Empty) @@ -71,4 +75,4 @@ @await Component.InvokeLayoutHookAsync(LayoutHooks.Body.Last, StandardLayouts.Empty) - \ No newline at end of file + diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/_ViewImports.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/_ViewImports.cshtml index 229004aa93..41c2b4ae4e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/_ViewImports.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/_ViewImports.cshtml @@ -1,4 +1,5 @@ @using System.Globalization +@inherits Volo.Abp.AspNetCore.Mvc.UI.RazorPages.AbpRazorPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap -@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bundling \ No newline at end of file +@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bundling diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js index 4e1c89afdb..cc4122a373 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js @@ -112,7 +112,7 @@ $.validator.defaults.ignore = ''; //TODO: Would be better if we can apply only f $firstVisibleInput.focus(); }); - var modalClass = abp.modals[_options.modalClass]; + var modalClass = abp.modals[options.modalClass]; if (modalClass) { _modalObject = new modalClass(); _modalObject.init && _modalObject.init(_publicApi, _args); //TODO: Remove later @@ -127,14 +127,14 @@ $.validator.defaults.ignore = ''; //TODO: Would be better if we can apply only f _args = args || {}; _createContainer(_modalId) - .load(_options.viewUrl, $.param(_args), function (response, status, xhr) { + .load(options.viewUrl, $.param(_args), function (response, status, xhr) { if (status === "error") { //TODO: Handle! return; }; - if (_options.scriptUrl) { - abp.ResourceLoader.loadScript(_options.scriptUrl, function () { + if (options.scriptUrl) { + abp.ResourceLoader.loadScript(options.scriptUrl, function () { _initAndShowModal(); }); } else { @@ -192,10 +192,6 @@ $.validator.defaults.ignore = ''; //TODO: Would be better if we can apply only f return _options; }, - setOptions: function(options){ - _options = options; - }, - setResult: function () { _onResultCallbacks.triggerAll(_publicApi, arguments); }, diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpRazorPage.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpRazorPage.cs new file mode 100644 index 0000000000..81178ef926 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpRazorPage.cs @@ -0,0 +1,17 @@ +using System; +using Microsoft.AspNetCore.Mvc.Razor; + +namespace Volo.Abp.AspNetCore.Mvc.UI.RazorPages +{ + public abstract class AbpRazorPage : RazorPage + { + public string ApplicationPath + { + get + { + string str = ViewContext.HttpContext.Request.PathBase.Value; + return str == null ? "/" : str.EnsureEndsWith('/'); + } + } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationScriptController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationScriptController.cs index 7234fb4f4d..d4ce99dc12 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationScriptController.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationScriptController.cs @@ -55,8 +55,6 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations script.AppendLine(); script.AppendLine($"$.extend(true, abp, {_jsonSerializer.Serialize(config, indented: true)})"); script.AppendLine(); - script.AppendLine($"abp.appPath = abp.toAbsAppPath('{Request.PathBase}/')"); - script.AppendLine(); script.AppendLine("abp.event.trigger('abp.configurationInitialized');"); script.AppendLine(); script.Append("})();"); diff --git a/modules/virtual-file-explorer/src/Volo.Abp.VirtualFileExplorer.Web/Pages/VirtualFileExplorer/Index.cshtml.cs b/modules/virtual-file-explorer/src/Volo.Abp.VirtualFileExplorer.Web/Pages/VirtualFileExplorer/Index.cshtml.cs index bb48951825..b450531cc8 100644 --- a/modules/virtual-file-explorer/src/Volo.Abp.VirtualFileExplorer.Web/Pages/VirtualFileExplorer/Index.cshtml.cs +++ b/modules/virtual-file-explorer/src/Volo.Abp.VirtualFileExplorer.Web/Pages/VirtualFileExplorer/Index.cshtml.cs @@ -43,7 +43,7 @@ namespace Volo.Abp.VirtualFileExplorer.Web.Pages.VirtualFileExplorer .Where(d => VirtualFileExplorerConsts.AllowFileInfoTypes.Contains(d.GetType().Name)) .OrderByDescending(f => f.IsDirectory).ToList(); - PagerModel = new PagerModel(query.Count, PageSize, CurrentPage, PageSize, $"{ResolveUrl()}VirtualFileExplorer?Path={Path}&PageSize={PageSize}"); + PagerModel = new PagerModel(query.Count, PageSize, CurrentPage, PageSize, $"{Url.Content("~/")}VirtualFileExplorer?Path={Path}&PageSize={PageSize}"); SetViewModel(query.Skip((CurrentPage - 1) * PageSize).Take(PageSize)); SetPathNavigation(); @@ -72,7 +72,7 @@ namespace Volo.Abp.VirtualFileExplorer.Web.Pages.VirtualFileExplorer fileInfoViewModel.Icon = "fas fa-folder"; fileInfoViewModel.FileType = "folder"; fileInfoViewModel.Length = "/"; - fileInfoViewModel.FileName =$"{fileInfo.Name}"; + fileInfoViewModel.FileName =$"{fileInfo.Name}"; } else { @@ -87,7 +87,7 @@ namespace Volo.Abp.VirtualFileExplorer.Web.Pages.VirtualFileExplorer { var navigationBuild = new StringBuilder(); var pathArray = Path.Split('/').Where(p => !p.IsNullOrWhiteSpace()); - var href = $"{ResolveUrl()}VirtualFileExplorer?path="; + var href = $"{Url.Content("~/")}VirtualFileExplorer?path="; navigationBuild.Append($"