diff --git a/static/js/chat-lang.js b/cmd/js/chat-lang.js similarity index 90% rename from static/js/chat-lang.js rename to cmd/js/chat-lang.js index a0fc4f3..d91d058 100644 --- a/static/js/chat-lang.js +++ b/cmd/js/chat-lang.js @@ -6,7 +6,7 @@ var GOFLY_LANG={ "chating":"正在与您沟通!", "historymes":"—— 以上是历史消息 ——", "moremessage":" 点击加载更多记录", - "copyright":"GO-FLY0.3.8客服陶士涵提供技术支持", + "copyright":"GO-FLY0.3.9客服陶士涵提供技术支持", "textarea":"请输入内容", "closemes":"系统自动关闭连接!点击会重连", "forceclosemes":"客服关闭连接!请重新打开页面", @@ -19,7 +19,7 @@ var GOFLY_LANG={ "chating":"chating with you!", "historymes":"—— Today ——", "moremessage":" click buuton show more messages", - "copyright":"We run on GOFLY0.3.8", + "copyright":"We run on GOFLY0.3.9", "textarea":"Enter your message", "closemes":"The system automatically closes the connection!", "forceclosemes":"Admin closes the connection! please reload", diff --git a/static/js/chat-main.js b/cmd/js/chat-main.js similarity index 100% rename from static/js/chat-main.js rename to cmd/js/chat-main.js diff --git a/static/js/chat-page.js b/cmd/js/chat-page.js similarity index 100% rename from static/js/chat-page.js rename to cmd/js/chat-page.js diff --git a/static/js/functions.js b/cmd/js/functions.js similarity index 100% rename from static/js/functions.js rename to cmd/js/functions.js diff --git a/static/js/gofly-front.js b/cmd/js/gofly-front.js similarity index 99% rename from static/js/gofly-front.js rename to cmd/js/gofly-front.js index 69a1317..632503d 100644 --- a/static/js/gofly-front.js +++ b/cmd/js/gofly-front.js @@ -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+"/static/js/functions.js?v=1",function(){ + this.dynamicLoadJs(this.GOFLY_URL+"/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/index.js b/cmd/js/index.js similarity index 100% rename from static/js/index.js rename to cmd/js/index.js diff --git a/cmd/server.go b/cmd/server.go index 132469e..d1ddd02 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -1,6 +1,7 @@ package cmd import ( + "embed" "github.com/gin-contrib/pprof" "github.com/gin-gonic/gin" "github.com/spf13/cobra" @@ -9,7 +10,9 @@ import ( "github.com/taoshihan1991/imaptool/router" "github.com/taoshihan1991/imaptool/tools" "github.com/zh-five/xdaemon" + "html/template" "log" + "net/http" "os" ) @@ -26,6 +29,12 @@ var serverCmd = &cobra.Command{ }, } +//go:embed templates/* +var templatesEmbed embed.FS + +//go:embed js/* +var jsEmbed embed.FS + func init() { serverCmd.PersistentFlags().StringVarP(&Port, "port", "p", "8081", "监听端口号") serverCmd.PersistentFlags().BoolVarP(&daemon, "daemon", "d", false, "是否为守护进程模式") @@ -53,7 +62,10 @@ func run() { tools.Logger().Println("start server...\r\ngo:http://" + baseServer) engine := gin.Default() - engine.LoadHTMLGlob("static/html/*") + //engine.LoadHTMLGlob("static/html/*") + templ := template.Must(template.New("").ParseFS(templatesEmbed, "templates/*.html")) + engine.SetHTMLTemplate(templ) + engine.StaticFS("/assets", http.FS(jsEmbed)) engine.Static("/static", "./static") engine.Use(tools.Session("gofly")) engine.Use(middleware.CrossSite) diff --git a/static/html/chat_main.html b/cmd/templates/chat_main.html similarity index 99% rename from static/html/chat_main.html rename to cmd/templates/chat_main.html index ce0d893..2013e2a 100644 --- a/static/html/chat_main.html +++ b/cmd/templates/chat_main.html @@ -6,7 +6,7 @@ GO语言开源客服系统-GOFLY - + @@ -274,5 +274,5 @@ - + diff --git a/static/html/chat_page.html b/cmd/templates/chat_page.html similarity index 95% rename from static/html/chat_page.html rename to cmd/templates/chat_page.html index 52646f1..78a9a8d 100644 --- a/static/html/chat_page.html +++ b/cmd/templates/chat_page.html @@ -7,9 +7,9 @@ GO语言开源客服系统-GOFLY - + - + @@ -90,6 +90,6 @@ var REFER='{{.Refer}}'; var LANG=checkLang(); - - + + diff --git a/static/html/chat_video.html b/cmd/templates/chat_video.html similarity index 100% rename from static/html/chat_video.html rename to cmd/templates/chat_video.html diff --git a/static/html/detail.html b/cmd/templates/detail.html similarity index 100% rename from static/html/detail.html rename to cmd/templates/detail.html diff --git a/static/html/header.html b/cmd/templates/header.html similarity index 100% rename from static/html/header.html rename to cmd/templates/header.html diff --git a/static/html/index.html b/cmd/templates/index.html similarity index 100% rename from static/html/index.html rename to cmd/templates/index.html diff --git a/static/html/index_demo.html b/cmd/templates/index_demo.html similarity index 100% rename from static/html/index_demo.html rename to cmd/templates/index_demo.html diff --git a/static/html/index_new.html b/cmd/templates/index_new.html similarity index 98% rename from static/html/index_new.html rename to cmd/templates/index_new.html index cefe98b..b692d86 100644 --- a/static/html/index_new.html +++ b/cmd/templates/index_new.html @@ -20,7 +20,7 @@ - + - + ', -'

:)

你好 GOFLY0.3.9 在线客服系统 !

Administrator English 中文

', -' +