浏览代码

fix Net Core 3.0,Dashboard Can't Load Js And Css. (#407)

master
Yrin Leung 5 年前
committed by Savorboard
父节点
当前提交
843e99420d
共有 2 个文件被更改,包括 10 次插入10 次删除
  1. +4
    -3
      src/DotNetCore.CAP/Dashboard/CombinedResourceDispatcher.cs
  2. +6
    -7
      src/DotNetCore.CAP/Dashboard/EmbeddedResourceDispatcher.cs

+ 4
- 3
src/DotNetCore.CAP/Dashboard/CombinedResourceDispatcher.cs 查看文件

@@ -2,6 +2,7 @@
// Licensed under the MIT License. See License.txt in the project root for license information.

using System.Reflection;
using System.Threading.Tasks;

namespace DotNetCore.CAP.Dashboard
{
@@ -22,14 +23,14 @@ namespace DotNetCore.CAP.Dashboard
_resourceNames = resourceNames;
}

protected override void WriteResponse(DashboardResponse response)
protected override async Task WriteResponse(DashboardResponse response)
{
foreach (var resourceName in _resourceNames)
{
WriteResource(
await WriteResource(
response,
_assembly,
$"{_baseNamespace}.{resourceName}");
$"{_baseNamespace}.{resourceName}").ConfigureAwait(false);
}
}
}

+ 6
- 7
src/DotNetCore.CAP/Dashboard/EmbeddedResourceDispatcher.cs 查看文件

@@ -30,22 +30,21 @@ namespace DotNetCore.CAP.Dashboard
}
}

public Task Dispatch(DashboardContext context)
public async Task Dispatch(DashboardContext context)
{
context.Response.ContentType = _contentType;
context.Response.SetExpire(DateTimeOffset.Now.AddYears(1));

WriteResponse(context.Response);
await WriteResponse(context.Response).ConfigureAwait(false);

return Task.FromResult(true);
}

protected virtual void WriteResponse(DashboardResponse response)
protected virtual Task WriteResponse(DashboardResponse response)
{
WriteResource(response, _assembly, _resourceName);
return WriteResource(response, _assembly, _resourceName);
}

protected void WriteResource(DashboardResponse response, Assembly assembly, string resourceName)
protected async Task WriteResource(DashboardResponse response, Assembly assembly, string resourceName)
{
using (var inputStream = assembly.GetManifestResourceStream(resourceName))
{
@@ -55,7 +54,7 @@ namespace DotNetCore.CAP.Dashboard
$@"Resource with name {resourceName} not found in assembly {assembly}.");
}

inputStream.CopyTo(response.Body);
await inputStream.CopyToAsync(response.Body).ConfigureAwait(false);
}
}
}

正在加载...
取消
保存