From f77d2a47d16b40a476fad2e530bd775d2f048340 Mon Sep 17 00:00:00 2001 From: jackfiled Date: Sun, 8 Sep 2024 22:34:20 +0800 Subject: [PATCH] fix: Svg image can't load currently. --- YaeBlog/Controllers/FilesController.cs | 8 ++++++++ YaeBlog/appsettings.json | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/YaeBlog/Controllers/FilesController.cs b/YaeBlog/Controllers/FilesController.cs index ace5d47..646d11c 100644 --- a/YaeBlog/Controllers/FilesController.cs +++ b/YaeBlog/Controllers/FilesController.cs @@ -9,12 +9,20 @@ public class FilesController : ControllerBase [HttpGet("{*filename}")] public IActionResult Images(string filename) { + // 这里疑似有点太愚蠢了 string contentType = "image/png"; + if (filename.EndsWith("jpg") || filename.EndsWith("jpeg")) { contentType = "image/jpeg"; } + if (filename.EndsWith("svg")) + { + contentType = "image/svg+xml"; + } + + FileInfo imageFile = new(filename); if (!imageFile.Exists) diff --git a/YaeBlog/appsettings.json b/YaeBlog/appsettings.json index 454c218..4efd31b 100644 --- a/YaeBlog/appsettings.json +++ b/YaeBlog/appsettings.json @@ -24,10 +24,16 @@ "AvatarImage": "https://zzachary.top/img/ztqy_hub928259802d192ff5718c06370f0f2c4_48203_300x0_resize_q75_box.jpg" }, { - "Name": "Chenxu", + "Name": "不会写程序的晨旭", "Description": "一个普通大学生", "Link": "https://chenxutalk.top", "AvatarImage": "https://www.chenxutalk.top/img/photo.png" + }, + { + "Name": "万木长风", + "Description": "世界渲染中...", + "Link": "https://ryohai.fun", + "AvatarImage": "https://ryohai.fun/icon.jpg" } ] }