|
|
|
|
@ -1,11 +1,13 @@
|
|
|
|
|
@using System.Dynamic
|
|
|
|
|
@using Microsoft.AspNetCore.Mvc.ViewComponents
|
|
|
|
|
@using Volo.Abp.Data
|
|
|
|
|
@using Volo.Abp.Reflection
|
|
|
|
|
@using Volo.CmsKit.Web.Renderers;
|
|
|
|
|
@using Volo.CmsKit.Web.Pages.CmsKit.Components.Contents;
|
|
|
|
|
|
|
|
|
|
@model ContentFragmentViewComponent
|
|
|
|
|
|
|
|
|
|
@inject IMarkdownToHtmlRenderer MarkdownRenderer
|
|
|
|
|
@inject IViewComponentSelector ViewComponentSelector
|
|
|
|
|
|
|
|
|
|
@foreach (var contentFragment in Model.ContentDto.ContentFragments)
|
|
|
|
|
{
|
|
|
|
|
@ -15,6 +17,23 @@
|
|
|
|
|
}
|
|
|
|
|
else if (contentFragment.Type == "Widget")
|
|
|
|
|
{
|
|
|
|
|
@await Component.InvokeAsync(contentFragment.GetProperty<string>("Type"), contentFragment.ExtraProperties.ConvertToDynamicObject())
|
|
|
|
|
var componentName = contentFragment.GetProperty<string>("Type");
|
|
|
|
|
var descriptor = ViewComponentSelector.SelectComponent(componentName);
|
|
|
|
|
var componentParameters = descriptor.Parameters;
|
|
|
|
|
var parameters = new Dictionary<string, object>(contentFragment.ExtraProperties);
|
|
|
|
|
|
|
|
|
|
foreach (var componentParameter in componentParameters)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(componentParameter.Name))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if(parameters.TryGetValue(componentParameter.Name, out var value))
|
|
|
|
|
{
|
|
|
|
|
parameters[componentParameter.Name] = TypeHelper.ConvertFrom(componentParameter.ParameterType, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@await Component.InvokeAsync(componentName, parameters)
|
|
|
|
|
}
|
|
|
|
|
}
|