fix #3793 - render issues on .NET MAUI

This commit is contained in:
sbwalker
2024-02-15 10:22:14 -05:00
parent 0fb45d4584
commit 7d1b4d916e
6 changed files with 30 additions and 6 deletions

View File

@ -1,7 +1,7 @@
@namespace Oqtane.UI
@inject SiteState SiteState
@if (PageState.Site.RenderMode == RenderModes.Interactive || ModuleState.RenderMode == RenderModes.Static)
@if (PageState.RenderMode == RenderModes.Interactive || ModuleState.RenderMode == RenderModes.Static)
{
<RenderModeBoundary ModuleState="@ModuleState" PageState="@PageState" SiteState="@SiteState" />
}

View File

@ -53,6 +53,30 @@
{
headcontent = AddHeadContent(headcontent, PageState.Page.HeadContent);
}
if (PageState.RenderMode == RenderModes.Static)
{
string batch = DateTime.UtcNow.ToString("yyyyMMddHHmmssfff");
int count = 0;
foreach (Resource resource in PageState.Page.Resources.Where(item => item.ResourceType == ResourceType.Stylesheet && item.Level == ResourceLevel.Module))
{
// if (resource.Url.StartsWith("~"))
// {
// resource.Url = resource.Url.Replace("~", "/Themes/" + Utilities.GetTypeName(name) + "/").Replace("//", "/");
// }
if (!resource.Url.Contains("://") && PageState.Alias.BaseUrl != "" && !resource.Url.StartsWith(PageState.Alias.BaseUrl))
{
resource.Url = PageState.Alias.BaseUrl + resource.Url;
}
if (!headcontent.Contains(resource.Url, StringComparison.OrdinalIgnoreCase))
{
count++;
string id = "id=\"app-stylesheet-" + resource.Level.ToString().ToLower() + "-" + batch + "-" + count.ToString("00") + "\" ";
headcontent += "<link " + id + "rel=\"stylesheet\" href=\"" + resource.Url + "\"" + (!string.IsNullOrEmpty(resource.Integrity) ? " integrity=\"" + resource.Integrity + "\"" : "") + (!string.IsNullOrEmpty(resource.CrossOrigin) ? " crossorigin=\"" + resource.CrossOrigin + "\"" : "") + " type=\"text/css\"/>" + Environment.NewLine;
}
}
}
SiteState.Properties.HeadContent = headcontent;
DynamicComponent = builder =>