fix: 🐛 tinymce editor css 加载路径错误 (#94)

This commit is contained in:
nsnail 2024-02-27 09:58:16 +08:00 committed by GitHub
parent 5fe73878a2
commit 802251e423
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -35,32 +35,41 @@ public static class IApplicationBuilderExtensions
return Assembly.GetExecutingAssembly().GetManifestResourceStream(_RES_PFX + path);
}
private static async Task UseVueAdminAsync(HttpContext context, Func<Task> next)
private static string GetResName(string path)
{
if (!context.Request.Path.StartsWithSegments(new PathString("/api"))) {
var path = context.Request.Path.Value?.Replace("-", "_");
if (path == "/" || path?.Length == 0) {
path = _INDEX_HTML_PATH;
}
return _allResNames.FirstOrDefault(x => path.EndsWith(x, StringComparison.OrdinalIgnoreCase));
}
path = path!.Replace('/', '.');
var output = GetManifestResourceStream(path);
if (output == null) {
var resName = _allResNames.FirstOrDefault(x => path.EndsWith(x, StringComparison.OrdinalIgnoreCase));
output = resName == null
? GetManifestResourceStream(_INDEX_HTML_PATH)
: GetManifestResourceStream(resName);
}
if (output != null) {
context.Response.ContentLength = output.Length;
context.Response.ContentType = MimeTypeHelper.GetMimeTypeByExtName(_regex.Match(path!).Groups[1].Value);
await output.CopyToAsync(context.Response.Body).ConfigureAwait(false);
return;
}
private static Task UseVueAdminAsync(HttpContext context, Func<Task> next)
{
if (context.Request.Path.StartsWithSegments(new PathString("/api"))) {
return next.Invoke();
}
await next.Invoke().ConfigureAwait(false);
var path = context.Request.Path.Value;
if (path == "/" || path?.Length == 0) {
path = _INDEX_HTML_PATH;
}
path = path!.Replace('/', '.');
var output = GetManifestResourceStream(path);
if (output == null) {
var resName = GetResName(path);
if (resName == null) {
path = path.Replace("-", "_");
resName = GetResName(path);
}
output = resName == null ? GetManifestResourceStream(_INDEX_HTML_PATH) : GetManifestResourceStream(resName);
}
if (output == null) {
return next.Invoke();
}
context.Response.ContentLength = output.Length;
context.Response.ContentType = MimeTypeHelper.GetMimeTypeByExtName(_regex.Match(path!).Groups[1].Value);
return output.CopyToAsync(context.Response.Body);
}
}