mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-12 18:39:45 +00:00
Add SVGA animation preview support
This commit is contained in:
@@ -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))
|
||||
|
Reference in New Issue
Block a user