Browse Source

Support virtual path deployment

pull/4101/head
liangshiwei 6 years ago
parent
commit
27aa66558f
  1. 7
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/tenant-switch.js
  2. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Menu/Default.cshtml
  3. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Menu/_MenuItem.cshtml
  4. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/LanguageSwitch/Default.cshtml
  5. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/UserMenu/Default.cshtml
  6. 12
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js
  7. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationScriptController.cs
  8. 4
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Authentication/ChallengeAccountController.cs
  9. 6
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpLanguagesController.cs
  10. 5
      framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs
  11. 2
      modules/account/src/Volo.Abp.Account.Web/Modules/Account/Components/Toolbar/UserLoginLink/Default.cshtml
  12. 3
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/AccountPageModel.cs
  13. 2
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs
  14. 15
      modules/virtual-file-explorer/src/Volo.Abp.VirtualFileExplorer.Web/Pages/VirtualFileExplorer/Index.cshtml.cs
  15. 2
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Controllers/HomeController.cs
  16. 2
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Controllers/HomeController.cs
  17. 2
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/Index.cshtml
  18. 2
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Pages/Index.cshtml

7
framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/tenant-switch.js

@ -1,10 +1,13 @@
(function($) { (function($) {
var tenantSwitchModal = new abp.ModalManager(abp.appPath + 'Abp/MultiTenancy/TenantSwitchModal'); var tenantSwitchModal = new abp.ModalManager();
$(function() { $(function() {
$('#AbpTenantSwitchLink').click(function(e) { $('#AbpTenantSwitchLink').click(function(e) {
e.preventDefault(); e.preventDefault();
tenantSwitchModal.setOptions({
viewUrl : abp.appPath + 'Abp/MultiTenancy/TenantSwitchModal'
})
tenantSwitchModal.open(); tenantSwitchModal.open();
}); });
@ -13,4 +16,4 @@
}); });
}); });
})(jQuery); })(jQuery);

4
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Menu/Default.cshtml

@ -10,7 +10,7 @@
if (menuItem.Url != null) if (menuItem.Url != null)
{ {
<li class="nav-item @cssClass @disabled" @elementId> <li class="nav-item @cssClass @disabled" @elementId>
<a class="nav-link" href="@(menuItem.Url ?? "#")"> <a class="nav-link" href="@Url.Content(menuItem.Url ?? "#")">
@if (menuItem.Icon != null) @if (menuItem.Icon != null)
{ {
if (menuItem.Icon.StartsWith("fa")) if (menuItem.Icon.StartsWith("fa"))
@ -46,4 +46,4 @@
</div> </div>
</li> </li>
} }
} }

2
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.Url != null)
{ {
<a class="dropdown-item @cssClass @disabled" href="@(Model.Url ?? "#")" @Html.Raw(elementId)> <a class="dropdown-item @cssClass @disabled" href="@Url.Content(Model.Url ?? "#")" @Html.Raw(elementId)>
@if (Model.Icon != null) @if (Model.Icon != null)
{ {
if (Model.Icon.StartsWith("fa")) if (Model.Icon.StartsWith("fa"))

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/LanguageSwitch/Default.cshtml

@ -12,7 +12,7 @@
<div class="dropdown-menu dropdown-menu-right border-0 shadow-sm" aria-labelledby="dropdownMenuLink"> <div class="dropdown-menu dropdown-menu-right border-0 shadow-sm" aria-labelledby="dropdownMenuLink">
@foreach (var language in Model.OtherLanguages) @foreach (var language in Model.OtherLanguages)
{ {
<a class="dropdown-item" href="/Abp/Languages/Switch?culture=@(language.CultureName)&uiCulture=@(language.UiCultureName)&returnUrl=@(System.Net.WebUtility.UrlEncode(Context.Request.GetEncodedPathAndQuery()))">@language.DisplayName</a> <a class="dropdown-item" href="~/Abp/Languages/Switch?culture=@(language.CultureName)&uiCulture=@(language.UiCultureName)&returnUrl=@(System.Net.WebUtility.UrlEncode(Context.Request.GetEncodedPathAndQuery()))">@language.DisplayName</a>
} }
</div> </div>
</div> </div>

2
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 cssClass = string.IsNullOrEmpty(menuItem.CssClass) ? string.Empty : menuItem.CssClass;
var disabled = menuItem.IsDisabled ? "disabled" : string.Empty; var disabled = menuItem.IsDisabled ? "disabled" : string.Empty;
<a class="dropdown-item @cssClass @disabled" href="@(menuItem.Url ?? "#")" target="@menuItem.Target" @Html.Raw(elementId)> <a class="dropdown-item @cssClass @disabled" href="@Url.Content(menuItem.Url ?? "#")" target="@menuItem.Target" @Html.Raw(elementId)>
@if (menuItem.Icon != null) @if (menuItem.Icon != null)
{ {
if (menuItem.Icon.StartsWith("fa")) if (menuItem.Icon.StartsWith("fa"))

12
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(); $firstVisibleInput.focus();
}); });
var modalClass = abp.modals[options.modalClass]; var modalClass = abp.modals[_options.modalClass];
if (modalClass) { if (modalClass) {
_modalObject = new modalClass(); _modalObject = new modalClass();
_modalObject.init && _modalObject.init(_publicApi, _args); //TODO: Remove later _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 || {}; _args = args || {};
_createContainer(_modalId) _createContainer(_modalId)
.load(options.viewUrl, $.param(_args), function (response, status, xhr) { .load(_options.viewUrl, $.param(_args), function (response, status, xhr) {
if (status === "error") { if (status === "error") {
//TODO: Handle! //TODO: Handle!
return; return;
}; };
if (options.scriptUrl) { if (_options.scriptUrl) {
abp.ResourceLoader.loadScript(options.scriptUrl, function () { abp.ResourceLoader.loadScript(_options.scriptUrl, function () {
_initAndShowModal(); _initAndShowModal();
}); });
} else { } else {
@ -192,6 +192,10 @@ $.validator.defaults.ignore = ''; //TODO: Would be better if we can apply only f
return _options; return _options;
}, },
setOptions: function(options){
_options = options;
},
setResult: function () { setResult: function () {
_onResultCallbacks.triggerAll(_publicApi, arguments); _onResultCallbacks.triggerAll(_publicApi, arguments);
}, },

2
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();
script.AppendLine($"$.extend(true, abp, {_jsonSerializer.Serialize(config, indented: true)})"); script.AppendLine($"$.extend(true, abp, {_jsonSerializer.Serialize(config, indented: true)})");
script.AppendLine(); script.AppendLine();
script.AppendLine($"abp.appPath = abp.toAbsAppPath('{Request.PathBase}/')");
script.AppendLine();
script.AppendLine("abp.event.trigger('abp.configurationInitialized');"); script.AppendLine("abp.event.trigger('abp.configurationInitialized');");
script.AppendLine(); script.AppendLine();
script.Append("})();"); script.Append("})();");

4
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() protected virtual string GetAppHomeUrl()
{ {
return "/"; return "~/";
} }
} }
} }

6
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(GetRedirectUrl(returnUrl));
} }
return Redirect("/"); return Redirect("~/");
} }
private string GetRedirectUrl(string returnUrl) private string GetRedirectUrl(string returnUrl)
{ {
if (returnUrl.IsNullOrEmpty()) if (returnUrl.IsNullOrEmpty())
{ {
return "/"; return "~/";
} }
if (Url.IsLocalUrl(returnUrl)) if (Url.IsLocalUrl(returnUrl))
@ -47,7 +47,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Localization
return returnUrl; return returnUrl;
} }
return "/"; return "~/";
} }
} }
} }

5
framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using JetBrains.Annotations; using JetBrains.Annotations;
@ -101,7 +102,7 @@ namespace Volo.Abp.UI.Navigation
Name = name; Name = name;
DisplayName = displayName; DisplayName = displayName;
Url = url; Url = url?.EnsureStartsWith('~');
Icon = icon; Icon = icon;
Order = order; Order = order;
CustomData = customData; CustomData = customData;
@ -133,4 +134,4 @@ namespace Volo.Abp.UI.Navigation
return $"[ApplicationMenuItem] Name = {Name}"; return $"[ApplicationMenuItem] Name = {Name}";
} }
} }
} }

2
modules/account/src/Volo.Abp.Account.Web/Modules/Account/Components/Toolbar/UserLoginLink/Default.cshtml

@ -1,4 +1,4 @@
@using Localization.Resources.AbpUi @using Localization.Resources.AbpUi
@using Microsoft.AspNetCore.Mvc.Localization @using Microsoft.AspNetCore.Mvc.Localization
@inject IHtmlLocalizer<AbpUiResource> L @inject IHtmlLocalizer<AbpUiResource> L
<a href="/Account/Login">@L["Login"]</a> <a href="~/Account/Login">@L["Login"]</a>

3
modules/account/src/Volo.Abp.Account.Web/Pages/Account/AccountPageModel.cs

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Account.Localization; using Volo.Abp.Account.Localization;
@ -73,7 +74,7 @@ namespace Volo.Abp.Account.Web.Pages.Account
protected virtual string GetAppHomeUrl() protected virtual string GetAppHomeUrl()
{ {
return "/"; //TODO: ??? return "~/"; //TODO: ???
} }
} }
} }

2
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); 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() protected virtual async Task CheckSelfRegistrationAsync()

15
modules/virtual-file-explorer/src/Volo.Abp.VirtualFileExplorer.Web/Pages/VirtualFileExplorer/Index.cshtml.cs

@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.FileProviders;
using NUglify.Helpers; using NUglify.Helpers;
@ -42,7 +43,7 @@ namespace Volo.Abp.VirtualFileExplorer.Web.Pages.VirtualFileExplorer
.Where(d => VirtualFileExplorerConsts.AllowFileInfoTypes.Contains(d.GetType().Name)) .Where(d => VirtualFileExplorerConsts.AllowFileInfoTypes.Contains(d.GetType().Name))
.OrderByDescending(f => f.IsDirectory).ToList(); .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)); SetViewModel(query.Skip((CurrentPage - 1) * PageSize).Take(PageSize));
SetPathNavigation(); SetPathNavigation();
@ -71,7 +72,7 @@ namespace Volo.Abp.VirtualFileExplorer.Web.Pages.VirtualFileExplorer
fileInfoViewModel.Icon = "fas fa-folder"; fileInfoViewModel.Icon = "fas fa-folder";
fileInfoViewModel.FileType = "folder"; fileInfoViewModel.FileType = "folder";
fileInfoViewModel.Length = "/"; fileInfoViewModel.Length = "/";
fileInfoViewModel.FileName =$"<a href='/VirtualFileExplorer?path={fileInfo.PhysicalPath}'>{fileInfo.Name}</a>"; fileInfoViewModel.FileName =$"<a href='{ResolveUrl()}VirtualFileExplorer?path={fileInfo.PhysicalPath}'>{fileInfo.Name}</a>";
} }
else else
{ {
@ -86,7 +87,7 @@ namespace Volo.Abp.VirtualFileExplorer.Web.Pages.VirtualFileExplorer
{ {
var navigationBuild = new StringBuilder(); var navigationBuild = new StringBuilder();
var pathArray = Path.Split('/').Where(p => !p.IsNullOrWhiteSpace()); var pathArray = Path.Split('/').Where(p => !p.IsNullOrWhiteSpace());
var href = "/VirtualFileExplorer?path="; var href = $"{ResolveUrl()}VirtualFileExplorer?path=";
navigationBuild.Append($"<nav aria-label='breadcrumb'>" + navigationBuild.Append($"<nav aria-label='breadcrumb'>" +
$" <ol class='breadcrumb'>" + $" <ol class='breadcrumb'>" +
@ -102,5 +103,13 @@ namespace Volo.Abp.VirtualFileExplorer.Web.Pages.VirtualFileExplorer
PathNavigation = navigationBuild.ToString(); PathNavigation = navigationBuild.ToString();
} }
private string ResolveUrl()
{
var segment = new PathString("/");
var applicationPath = Request.PathBase;
return applicationPath.Add(segment).Value;
}
} }
} }

2
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Controllers/HomeController.cs

@ -7,7 +7,7 @@ namespace MyCompanyName.MyProjectName.Controllers
{ {
public ActionResult Index() public ActionResult Index()
{ {
return Redirect("/swagger"); return Redirect("~/swagger");
} }
} }
} }

2
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Controllers/HomeController.cs

@ -7,7 +7,7 @@ namespace MyCompanyName.MyProjectName.Controllers
{ {
public ActionResult Index() public ActionResult Index()
{ {
return Redirect("/swagger"); return Redirect("~/swagger");
} }
} }
} }

2
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/Index.cshtml

@ -26,6 +26,6 @@
<a href="https://abp.io?ref=tmpl" target="_blank" class="btn btn-primary px-4">abp.io</a> <a href="https://abp.io?ref=tmpl" target="_blank" class="btn btn-primary px-4">abp.io</a>
@if (!CurrentUser.IsAuthenticated) @if (!CurrentUser.IsAuthenticated)
{ {
<a abp-button="Primary" href="/Account/Login" class="px-4"><i class="fa fa-sign-in"></i> @L["Login"]</a> <a abp-button="Primary" href="~/Account/Login" class="px-4"><i class="fa fa-sign-in"></i> @L["Login"]</a>
} }
</div> </div>

2
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Pages/Index.cshtml

@ -4,4 +4,4 @@
@using MyCompanyName.MyProjectName.Pages @using MyCompanyName.MyProjectName.Pages
@model IndexModel @model IndexModel
@inject IStringLocalizer<AbpUiResource> Localizer @inject IStringLocalizer<AbpUiResource> Localizer
<a href="/Account/Login">@Localizer["Login"]</a> <a href="~/Account/Login">@Localizer["Login"]</a>
Loading…
Cancel
Save