From 4f81735af6834656049726804fb9138ab7d673d2 Mon Sep 17 00:00:00 2001 From: Xhofe Date: Tue, 8 Feb 2022 18:07:13 +0800 Subject: [PATCH] :sparkler: close #512 favicon redirect --- bootstrap/setting.go | 2 +- conf/var.go | 2 +- model/setting.go | 2 +- server/controllers/other.go | 10 ++++++++++ server/router.go | 1 + 5 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 server/controllers/other.go diff --git a/bootstrap/setting.go b/bootstrap/setting.go index a91cadf0..198cade2 100644 --- a/bootstrap/setting.go +++ b/bootstrap/setting.go @@ -74,7 +74,7 @@ func InitSettings() { }, { Key: "music cover", - Value: "https://store.heytapimage.com/cdo-portal/feedback/202110/30/d43c41c5d257c9bc36366e310374fb19.png", + Value: "https://cdn.jsdelivr.net/gh/alist-org/logo@main/circle_center.svg", Description: "music cover image", Type: "string", Access: model.PUBLIC, diff --git a/conf/var.go b/conf/var.go index 79bd71e8..56c43e86 100644 --- a/conf/var.go +++ b/conf/var.go @@ -78,7 +78,7 @@ var ( "check parent folder", "check down link", "WebDAV username", "WebDAV password", "Visitor WebDAV username", "Visitor WebDAV password", "default page size", "load type", - "ocr api", + "ocr api", "favicon", } ) diff --git a/model/setting.go b/model/setting.go index dfb57d2d..b70fbd72 100644 --- a/model/setting.go +++ b/model/setting.go @@ -97,7 +97,7 @@ func LoadSettings() { favicon, err := GetSettingByKey("favicon") if err == nil { //conf.Favicon = favicon.Value - conf.ManageHtml = strings.Replace(conf.RawIndexHtml, "https://store.heytapimage.com/cdo-portal/feedback/202110/30/d43c41c5d257c9bc36366e310374fb19.png", favicon.Value, 1) + conf.ManageHtml = strings.Replace(conf.RawIndexHtml, "https://cdn.jsdelivr.net/gh/alist-org/logo@main/logo.svg", favicon.Value, 1) } title, err := GetSettingByKey("title") if err == nil { diff --git a/server/controllers/other.go b/server/controllers/other.go new file mode 100644 index 00000000..24cf7dac --- /dev/null +++ b/server/controllers/other.go @@ -0,0 +1,10 @@ +package controllers + +import ( + "github.com/Xhofe/alist/conf" + "github.com/gin-gonic/gin" +) + +func Favicon(c *gin.Context) { + c.Redirect(302, conf.GetStr("favicon")) +} diff --git a/server/router.go b/server/router.go index 4fb62f6d..2f0aae0d 100644 --- a/server/router.go +++ b/server/router.go @@ -15,6 +15,7 @@ func InitApiRouter(r *gin.Engine) { Cors(r) r.GET("/d/*path", middlewares.DownCheck, controllers.Down) r.GET("/p/*path", middlewares.DownCheck, controllers.Proxy) + r.GET("/favicon.ico", controllers.Favicon) api := r.Group("/api") public := api.Group("/public")