Support virtual path deployment

pull/4101/head
liangshiwei 5 years ago
parent ddd16664cc
commit 27aa66558f

@ -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);
})(jQuery);

@ -10,7 +10,7 @@
if (menuItem.Url != null)
{
<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.StartsWith("fa"))
@ -46,4 +46,4 @@
</div>
</li>
}
}
}

@ -9,7 +9,7 @@
{
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.StartsWith("fa"))

@ -12,7 +12,7 @@
<div class="dropdown-menu dropdown-menu-right border-0 shadow-sm" aria-labelledby="dropdownMenuLink">
@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>

@ -28,7 +28,7 @@
var cssClass = string.IsNullOrEmpty(menuItem.CssClass) ? string.Empty : menuItem.CssClass;
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.StartsWith("fa"))

@ -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);
},

@ -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("})();");

@ -86,7 +86,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Authentication
protected virtual string GetAppHomeUrl()
{
return "/";
return "~/";
}
}
}
}

@ -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 "~/";
}
}
}

@ -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}";
}
}
}
}

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

@ -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: ???
}
}
}

@ -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()

@ -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 =$"<a href='/VirtualFileExplorer?path={fileInfo.PhysicalPath}'>{fileInfo.Name}</a>";
fileInfoViewModel.FileName =$"<a href='{ResolveUrl()}VirtualFileExplorer?path={fileInfo.PhysicalPath}'>{fileInfo.Name}</a>";
}
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($"<nav aria-label='breadcrumb'>" +
$" <ol class='breadcrumb'>" +
@ -102,5 +103,13 @@ namespace Volo.Abp.VirtualFileExplorer.Web.Pages.VirtualFileExplorer
PathNavigation = navigationBuild.ToString();
}
private string ResolveUrl()
{
var segment = new PathString("/");
var applicationPath = Request.PathBase;
return applicationPath.Add(segment).Value;
}
}
}

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

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

@ -26,6 +26,6 @@
<a href="https://abp.io?ref=tmpl" target="_blank" class="btn btn-primary px-4">abp.io</a>
@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>

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