From 2e7fb387cf1aa28235bd6533fe5b11cb0130f8dd Mon Sep 17 00:00:00 2001 From: goder-zhang Date: Sat, 14 Feb 2026 15:44:21 +0000 Subject: [PATCH] fix: add aicss path prefix --- cmd/server.go | 15 +++-- controller/kefu.go | 2 +- controller/notice.go | 1 + controller/visitor.go | 4 +- router/api.go | 2 +- router/view.go | 3 +- static/js/functions.js | 32 +++++----- static/js/gofly-front.js | 4 +- static/js/kefu-front.js | 10 ++-- static/templates/bind.html | 4 +- static/templates/chat_main.html | 78 ++++++++++++------------- static/templates/chat_page.html | 37 ++++++------ static/templates/header.html | 12 ++-- static/templates/install.html | 2 +- static/templates/login.html | 16 ++--- static/templates/main.html | 34 +++++------ static/templates/setting_bottom.html | 13 ++--- static/templates/setting_kefu_list.html | 4 +- 18 files changed, 139 insertions(+), 134 deletions(-) diff --git a/cmd/server.go b/cmd/server.go index 915e88a..c56cf6a 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -10,6 +10,7 @@ import ( "log" "net/http" "os" + "path" "github.com/gin-gonic/gin" "github.com/spf13/cobra" @@ -54,10 +55,13 @@ func run() { log.Println("start server...\r\ngo:http://" + baseServer) tools.Logger().Println("start server...\r\ngo:http://" + baseServer) - engine := gin.Default() + var ( + engine = gin.Default() + basePath = "aicss" + ) engine.LoadHTMLGlob("static/templates/*") - engine.Static("/assets", "./static") - engine.Static("/static", "./static") + engine.Static(path.Join(basePath, "/assets"), "./static") + engine.Static(path.Join(basePath, "/static"), "./static") engine.Use(tools.Session("gofly")) engine.Use(middleware.CrossSite) //性能监控 @@ -66,8 +70,9 @@ func run() { //记录日志 engine.Use(middleware.NewMidLogger()) engine.Use(xpink_auth.MiddlewareSetIdentity) - router.InitViewRouter(engine) - router.InitApiRouter(engine) + routerGroup := engine.Group(basePath) + router.InitViewRouter(routerGroup) + router.InitApiRouter(routerGroup) //记录pid os.WriteFile("gofly.sock", []byte(fmt.Sprintf("%d,%d", os.Getppid(), os.Getpid())), 0666) //限流类 diff --git a/controller/kefu.go b/controller/kefu.go index 1e92c08..5e72c97 100644 --- a/controller/kefu.go +++ b/controller/kefu.go @@ -183,7 +183,7 @@ func PostKefuRegister(c *gin.Context) { name := c.PostForm("username") password := c.PostForm("password") nickname := c.PostForm("nickname") - avatar := "/static/images/4.jpg" + avatar := "/aicss/static/images/4.jpg" if name == "" || password == "" { c.JSON(http.StatusOK, gin.H{ diff --git a/controller/notice.go b/controller/notice.go index c34f9a9..fe9fde7 100644 --- a/controller/notice.go +++ b/controller/notice.go @@ -2,6 +2,7 @@ package controller import ( "ai-css/models" + "github.com/gin-gonic/gin" ) diff --git a/controller/visitor.go b/controller/visitor.go index 3254b2e..95aceeb 100644 --- a/controller/visitor.go +++ b/controller/visitor.go @@ -64,9 +64,9 @@ func PostVisitorLogin(c *gin.Context) { avator := "" userAgent := c.GetHeader("User-Agent") if tools.IsMobile(userAgent) { - avator = "/static/images/1.png" + avator = "/aicss/static/images/1.png" } else { - avator = "/static/images/2.png" + avator = "/aicss/static/images/2.png" } toId := c.PostForm("to_id") diff --git a/router/api.go b/router/api.go index db79088..0d7232b 100644 --- a/router/api.go +++ b/router/api.go @@ -8,7 +8,7 @@ import ( "github.com/gin-gonic/gin" ) -func InitApiRouter(engine *gin.Engine) { +func InitApiRouter(engine *gin.RouterGroup) { //路由分组 v2 := engine.Group("/2") { diff --git a/router/view.go b/router/view.go index 2935ab4..8d416d6 100644 --- a/router/view.go +++ b/router/view.go @@ -3,10 +3,11 @@ package router import ( "ai-css/middleware" "ai-css/tmpl" + "github.com/gin-gonic/gin" ) -func InitViewRouter(engine *gin.Engine) { +func InitViewRouter(engine *gin.RouterGroup) { engine.GET("/", tmpl.PageIndex) engine.GET("/login", tmpl.PageLogin) diff --git a/static/js/functions.js b/static/js/functions.js index 263041d..9af81a5 100644 --- a/static/js/functions.js +++ b/static/js/functions.js @@ -94,7 +94,7 @@ var faceTitles = ["[微笑]", "[嘻嘻]", "[哈哈]", "[可爱]", "[可怜]", "[ function placeFace() { var faces=[]; for(var i=0;i diff --git a/static/js/gofly-front.js b/static/js/gofly-front.js index 455fc3f..8ec21f5 100644 --- a/static/js/gofly-front.js +++ b/static/js/gofly-front.js @@ -25,7 +25,7 @@ GOFLY.init=function(config){ if (typeof config.GOFLY_URL!="undefined"){ this.GOFLY_URL=config.GOFLY_URL.replace(/([\w\W]+)\/$/,"$1"); } - this.dynamicLoadCss(this.GOFLY_URL+"/static/css/gofly-front.css?v=1"); + this.dynamicLoadCss(this.GOFLY_URL+"/aicss/static/css/gofly-front.css?v=1"); if (typeof config.GOFLY_KEFU_ID!="undefined"){ this.GOFLY_KEFU_ID=config.GOFLY_KEFU_ID; @@ -50,7 +50,7 @@ GOFLY.init=function(config){ this.GOFLY_EXTRA.host=document.location.href; this.GOFLY_EXTRA=JSON.stringify(_this.GOFLY_EXTRA); - this.dynamicLoadJs(this.GOFLY_URL+"/assets/js/functions.js?v=1",function(){ + this.dynamicLoadJs(this.GOFLY_URL+"/aicss/assets/js/functions.js?v=1",function(){ if (typeof config.GOFLY_LANG!="undefined"){ _this.GOFLY_LANG=config.GOFLY_LANG; }else{ diff --git a/static/js/kefu-front.js b/static/js/kefu-front.js index fc9f129..8be0189 100644 --- a/static/js/kefu-front.js +++ b/static/js/kefu-front.js @@ -54,19 +54,19 @@ KEFU.init=function(config){ if (typeof config.KEFU_URL!="undefined"){ this.KEFU_URL=config.KEFU_URL.replace(/([\w\W]+)\/$/,"$1"); } - this.dynamicLoadCss(this.KEFU_URL+"/static/css/kefu-front.css?v="+Date.now()); - this.dynamicLoadCss(this.KEFU_URL+"/static/css/layui/css/layui.css?v="+Date.now()); + this.dynamicLoadCss(this.KEFU_URL+"/aicss/static/css/kefu-front.css?v="+Date.now()); + this.dynamicLoadCss(this.KEFU_URL+"/aicss/static/css/layui/css/layui.css?v="+Date.now()); var refer=document.referrer?document.referrer:"none"; this.KEFU_EXTRA.refer=refer; this.KEFU_EXTRA.host=document.location.href; this.KEFU_EXTRA=JSON.stringify(_this.KEFU_EXTRA); - this.dynamicLoadJs(this.KEFU_URL+"/static/js/functions.js?v=1",function(){ + this.dynamicLoadJs(this.KEFU_URL+"/aicss/static/js/functions.js?v=1",function(){ _this.dynamicLoadJs("https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js",function () { jQuery.noConflict(); - _this.dynamicLoadJs(_this.KEFU_URL+"/static/js/layer/layer.js",function () { + _this.dynamicLoadJs(_this.KEFU_URL+"/aicss/static/js/layer/layer.js",function () { _this.jsCallBack(); }); }); @@ -292,7 +292,7 @@ KEFU.layerOpen=function (width,height,offset){ var title=`
- +
diff --git a/static/templates/bind.html b/static/templates/bind.html index 4885fdc..1cbdc20 100644 --- a/static/templates/bind.html +++ b/static/templates/bind.html @@ -62,7 +62,7 @@ } } - +