|
|
|
@ -1,5 +1,6 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using Volo.Abp.Ui.LayoutHooks; |
|
|
|
@ -17,11 +18,17 @@ public class LayoutHookViewComponent : AbpViewComponent |
|
|
|
|
|
|
|
public virtual IViewComponentResult Invoke(string name, string layout) |
|
|
|
{ |
|
|
|
var hooks = Options.Hooks.GetOrDefault(name)?.ToArray() ?? Array.Empty<LayoutHookInfo>(); |
|
|
|
|
|
|
|
var hooks = Options.Hooks.GetOrDefault(name)?.Where(IsViewComponent).ToArray() |
|
|
|
?? Array.Empty<LayoutHookInfo>(); |
|
|
|
|
|
|
|
return View( |
|
|
|
"~/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/Default.cshtml", |
|
|
|
new LayoutHookViewModel(hooks, layout) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual bool IsViewComponent(LayoutHookInfo layoutHook) |
|
|
|
{ |
|
|
|
return typeof(ViewComponent).IsAssignableFrom(layoutHook.ComponentType); |
|
|
|
} |
|
|
|
} |
|
|
|
|