From 27aa66558ffea0a78b96d2094da0adffe7005e78 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 26 May 2020 17:15:09 +0800 Subject: [PATCH] Support virtual path deployment --- .../Pages/Abp/MultiTenancy/tenant-switch.js | 7 +++++-- .../Themes/Basic/Components/Menu/Default.cshtml | 4 ++-- .../Themes/Basic/Components/Menu/_MenuItem.cshtml | 2 +- .../Toolbar/LanguageSwitch/Default.cshtml | 2 +- .../Components/Toolbar/UserMenu/Default.cshtml | 2 +- .../bootstrap/modal-manager.js | 12 ++++++++---- ...AbpApplicationConfigurationScriptController.cs | 2 ++ .../Authentication/ChallengeAccountController.cs | 4 ++-- .../Mvc/Localization/AbpLanguagesController.cs | 6 +++--- .../Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs | 5 +++-- .../Toolbar/UserLoginLink/Default.cshtml | 2 +- .../Pages/Account/AccountPageModel.cs | 3 ++- .../Pages/Account/Register.cshtml.cs | 2 +- .../Pages/VirtualFileExplorer/Index.cshtml.cs | 15 ++++++++++++--- .../Controllers/HomeController.cs | 2 +- .../Controllers/HomeController.cs | 2 +- .../Pages/Index.cshtml | 2 +- .../Pages/Index.cshtml | 2 +- 18 files changed, 48 insertions(+), 28 deletions(-) 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 6b9e348f1d..106eea205a 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,10 +1,13 @@ (function($) { - var tenantSwitchModal = new abp.ModalManager(abp.appPath + 'Abp/MultiTenancy/TenantSwitchModal'); + var tenantSwitchModal = new abp.ModalManager(); $(function() { $('#AbpTenantSwitchLink').click(function(e) { e.preventDefault(); + tenantSwitchModal.setOptions({ + viewUrl : abp.appPath + 'Abp/MultiTenancy/TenantSwitchModal' + }) tenantSwitchModal.open(); }); @@ -13,4 +16,4 @@ }); }); -})(jQuery); \ No newline at end of file +})(jQuery); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Menu/Default.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Menu/Default.cshtml index 0c6b5d8a3b..b6a7a559bb 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Menu/Default.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Menu/Default.cshtml @@ -10,7 +10,7 @@ if (menuItem.Url != null) { } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Menu/_MenuItem.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Menu/_MenuItem.cshtml index eaec9fc7c4..dd517b91ff 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Menu/_MenuItem.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Menu/_MenuItem.cshtml @@ -9,7 +9,7 @@ { if (Model.Url != null) { - + @if (Model.Icon != null) { if (Model.Icon.StartsWith("fa")) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/LanguageSwitch/Default.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/LanguageSwitch/Default.cshtml index 65ca8d940e..8b7ea1bf2c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/LanguageSwitch/Default.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/LanguageSwitch/Default.cshtml @@ -12,7 +12,7 @@ diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/UserMenu/Default.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/UserMenu/Default.cshtml index d1738165d3..3b06904d63 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/UserMenu/Default.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/UserMenu/Default.cshtml @@ -28,7 +28,7 @@ var cssClass = string.IsNullOrEmpty(menuItem.CssClass) ? string.Empty : menuItem.CssClass; var disabled = menuItem.IsDisabled ? "disabled" : string.Empty; - + @if (menuItem.Icon != null) { if (menuItem.Icon.StartsWith("fa")) 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 cc4122a373..4e1c89afdb 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,6 +192,10 @@ $.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/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationScriptController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationScriptController.cs index d4ce99dc12..7234fb4f4d 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,6 +55,8 @@ 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/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Authentication/ChallengeAccountController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Authentication/ChallengeAccountController.cs index 36e0bebfd6..15854e10a6 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Authentication/ChallengeAccountController.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Authentication/ChallengeAccountController.cs @@ -86,7 +86,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Authentication protected virtual string GetAppHomeUrl() { - return "/"; + return "~/"; } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpLanguagesController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpLanguagesController.cs index 3f25eb2f84..06b9c9a620 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpLanguagesController.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpLanguagesController.cs @@ -32,14 +32,14 @@ namespace Volo.Abp.AspNetCore.Mvc.Localization return Redirect(GetRedirectUrl(returnUrl)); } - return Redirect("/"); + return Redirect("~/"); } private string GetRedirectUrl(string returnUrl) { if (returnUrl.IsNullOrEmpty()) { - return "/"; + return "~/"; } if (Url.IsLocalUrl(returnUrl)) @@ -47,7 +47,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Localization return returnUrl; } - return "/"; + return "~/"; } } } diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs index d4960c883e..4400fe7b46 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using JetBrains.Annotations; @@ -101,7 +102,7 @@ namespace Volo.Abp.UI.Navigation Name = name; DisplayName = displayName; - Url = url; + Url = url?.EnsureStartsWith('~'); Icon = icon; Order = order; CustomData = customData; @@ -133,4 +134,4 @@ namespace Volo.Abp.UI.Navigation return $"[ApplicationMenuItem] Name = {Name}"; } } -} \ No newline at end of file +} diff --git a/modules/account/src/Volo.Abp.Account.Web/Modules/Account/Components/Toolbar/UserLoginLink/Default.cshtml b/modules/account/src/Volo.Abp.Account.Web/Modules/Account/Components/Toolbar/UserLoginLink/Default.cshtml index 451a65b2dc..2331409857 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Modules/Account/Components/Toolbar/UserLoginLink/Default.cshtml +++ b/modules/account/src/Volo.Abp.Account.Web/Modules/Account/Components/Toolbar/UserLoginLink/Default.cshtml @@ -1,4 +1,4 @@ @using Localization.Resources.AbpUi @using Microsoft.AspNetCore.Mvc.Localization @inject IHtmlLocalizer L -@L["Login"] +@L["Login"] diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/AccountPageModel.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/AccountPageModel.cs index f5dbba8b2f..41bdd93647 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/AccountPageModel.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/AccountPageModel.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Volo.Abp.Account.Localization; @@ -73,7 +74,7 @@ namespace Volo.Abp.Account.Web.Pages.Account protected virtual string GetAppHomeUrl() { - return "/"; //TODO: ??? + return "~/"; //TODO: ??? } } } diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs index 3b5a5b2cd1..87c7131305 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs @@ -59,7 +59,7 @@ namespace Volo.Abp.Account.Web.Pages.Account await SignInManager.SignInAsync(user, isPersistent: false); - return Redirect(ReturnUrl ?? "/"); //TODO: How to ensure safety? IdentityServer requires it however it should be checked somehow! + return Redirect(ReturnUrl ?? "~/"); //TODO: How to ensure safety? IdentityServer requires it however it should be checked somehow! } protected virtual async Task CheckSelfRegistrationAsync() 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 4c79e27240..bb48951825 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 @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.FileProviders; using NUglify.Helpers; @@ -42,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, $"/VirtualFileExplorer?Path={Path}&PageSize={PageSize}"); + PagerModel = new PagerModel(query.Count, PageSize, CurrentPage, PageSize, $"{ResolveUrl()}VirtualFileExplorer?Path={Path}&PageSize={PageSize}"); SetViewModel(query.Skip((CurrentPage - 1) * PageSize).Take(PageSize)); SetPathNavigation(); @@ -71,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 { @@ -86,7 +87,7 @@ namespace Volo.Abp.VirtualFileExplorer.Web.Pages.VirtualFileExplorer { var navigationBuild = new StringBuilder(); var pathArray = Path.Split('/').Where(p => !p.IsNullOrWhiteSpace()); - var href = "/VirtualFileExplorer?path="; + var href = $"{ResolveUrl()}VirtualFileExplorer?path="; navigationBuild.Append($"