A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
update favicon.ico
aichy1261486c416f94d
diff --git a/internal/router/ui.go b/internal/router/ui.goindex bbb48e55..49042712 100644--- a/internal/router/ui.go+++ b/internal/router/ui.go@@ -3,15 +3,17 @@ package routerimport ("embed""fmt"- "github.com/gin-gonic/gin"- "github.com/segmentfault/answer/ui"- "github.com/segmentfault/pacman/log""io/fs""net/http""os"++ "github.com/gin-gonic/gin"+ "github.com/segmentfault/answer/ui"+ "github.com/segmentfault/pacman/log")const UIIndexFilePath = "build/index.html"+const UIRootFilePath = "build"const UIStaticPath = "build/static"// UIRouter is an interface that provides ui static file routers@@ -66,14 +68,28 @@ func (a *UIRouter) Register(r *gin.Engine) {// specify the not router for default routes and redirectr.NoRoute(func(c *gin.Context) {- index, err := ui.Build.ReadFile(UIIndexFilePath)+ name := c.Request.URL.Path+ filePath := ""+ var file []byte+ var err error+ switch name {+ case "/favicon.ico":+ c.Header("content-type", "image/vnd.microsoft.icon")+ filePath = UIRootFilePath + name+ case "/logo192.png":+ filePath = UIRootFilePath + name+ case "/logo512.png":+ filePath = UIRootFilePath + name+ default:+ filePath = UIIndexFilePath+ c.Header("content-type", "text/html;charset=utf-8")+ }+ file, err = ui.Build.ReadFile(filePath)if err != nil {log.Error(err)c.Status(http.StatusNotFound)return}-- c.Header("content-type", "text/html;charset=utf-8")- c.String(http.StatusOK, string(index))+ c.String(http.StatusOK, string(file))})}