Add SVGA animation preview support

This commit is contained in:
ema
2025-07-05 06:46:52 +08:00
parent 3858e142e2
commit eecb56db14
6 changed files with 125 additions and 31 deletions

View File

@@ -99,7 +99,7 @@ public class SvgImagePanel : WebpagePanel
ObjectForScripting ??= new ScriptHandler(path);
_homePage = _resources["/svg2html.html"];
_homePage = _resources[path.EndsWith(".svga", StringComparison.OrdinalIgnoreCase) ? "/svga2html.html" : "/svg2html.html"];
NavigateToUri(new Uri("file://quicklook/"));
}
@@ -145,6 +145,21 @@ public class SvgImagePanel : WebpagePanel
}
}
}
else if (requestedUri.Scheme == "https")
{
var localPath = $"{requestedUri.Authority}:{requestedUri.AbsolutePath}".Replace('/', '\\');
if (localPath.StartsWith(_fallbackPath, StringComparison.OrdinalIgnoreCase))
{
if (File.Exists(localPath))
{
var fileStream = File.OpenRead(localPath);
var response = _webView.CoreWebView2.Environment.CreateWebResourceResponse(
fileStream, 200, "OK", MimeTypes.GetContentType() + "\r\nAccess-Control-Allow-Origin: *");
args.Response = response;
}
}
}
}
catch (Exception e)
{
@@ -197,6 +212,16 @@ public sealed class ScriptHandler(string path)
{
public string Path { get; } = path;
public async Task<string> GetPath()
{
return await Task.FromResult(new Uri(Path).AbsolutePath);
}
public async Task<string> GetUri()
{
return await Task.FromResult(new Uri(Path).AbsoluteUri);
}
public async Task<string> GetSvgContent()
{
if (File.Exists(Path))