diff --git a/router/view.go b/router/view.go index 6c6268a..1148284 100644 --- a/router/view.go +++ b/router/view.go @@ -2,26 +2,56 @@ package router import ( "github.com/gin-gonic/gin" - "goflylivechat/middleware" - "goflylivechat/tmpl" + "net/http" ) func InitViewRouter(engine *gin.Engine) { //engine.GET("/", tmpl.PageIndex) + engine.GET("/login", PageLogin) + engine.GET("/pannel", PagePannel) + engine.GET("/livechat", PageChat) + engine.GET("/main", PageMain) + engine.GET("/chat_main", PageChatMain) + engine.GET("/setting", PageSetting) +} + +// 登陆界面 +func PageLogin(c *gin.Context) { + c.HTML(http.StatusOK, "login.html", nil) +} + +// 面板界面 +func PagePannel(c *gin.Context) { + c.HTML(http.StatusOK, "pannel.html", nil) +} + +// 后台界面 +func PageMain(c *gin.Context) { + c.HTML(http.StatusOK, "main.html", nil) +} + +// 咨询界面 +func PageChat(c *gin.Context) { + kefuId := c.Query("user_id") + refer := c.Query("refer") + if refer == "" { + refer = c.Request.Referer() + } + if refer == "" { + refer = "​​Direct Link" + } + c.HTML(http.StatusOK, "chat_page.html", gin.H{ + "KEFU_ID": kefuId, + "Refer": refer, + }) +} + +// 客服界面 +func PageChatMain(c *gin.Context) { + c.HTML(http.StatusOK, "chat_main.html", nil) +} - engine.GET("/login", tmpl.PageLogin) - engine.GET("/pannel", tmpl.PagePannel) - engine.GET("/chatIndex", tmpl.PageChat) - engine.GET("/livechat", tmpl.PageChat) - engine.GET("/main", middleware.JwtPageMiddleware, tmpl.PageMain) - engine.GET("/chat_main", middleware.JwtPageMiddleware, middleware.DomainLimitMiddleware, tmpl.PageChatMain) - engine.GET("/setting", middleware.DomainLimitMiddleware, tmpl.PageSetting) - engine.GET("/setting_statistics", tmpl.PageSettingStatis) - engine.GET("/setting_welcome", tmpl.PageSettingWelcome) - engine.GET("/setting_deploy", tmpl.PageSettingDeploy) - engine.GET("/setting_kefu_list", tmpl.PageKefuList) - engine.GET("/setting_avator", tmpl.PageAvator) - engine.GET("/setting_modifypass", tmpl.PageModifypass) - engine.GET("/setting_ipblack", tmpl.PageIpblack) - engine.GET("/setting_config", tmpl.PageConfig) +// 设置界面 +func PageSetting(c *gin.Context) { + c.HTML(http.StatusOK, "setting.html", nil) } diff --git a/static/templates/setting_left.html b/static/templates/setting_left.html deleted file mode 100644 index acddeea..0000000 --- a/static/templates/setting_left.html +++ /dev/null @@ -1,30 +0,0 @@ -{{define "setting_left"}} - - - - - - 统计信息 - 修改密码 - 修改资料 - - - - - - 配置参数 - IP黑名单 - 网页部署 - - - - -{{end}} \ No newline at end of file diff --git a/tmpl/chat.go b/tmpl/chat.go deleted file mode 100644 index 683c4e8..0000000 --- a/tmpl/chat.go +++ /dev/null @@ -1,22 +0,0 @@ -package tmpl - -import ( - "github.com/gin-gonic/gin" - "net/http" -) - -// 咨询界面 -func PageChat(c *gin.Context) { - kefuId := c.Query("kefu_id") - refer := c.Query("refer") - if refer == "" { - refer = c.Request.Referer() - } - if refer == "" { - refer = "​​Direct Link" - } - c.HTML(http.StatusOK, "chat_page.html", gin.H{ - "KEFU_ID": kefuId, - "Refer": refer, - }) -} diff --git a/tmpl/common.go b/tmpl/common.go deleted file mode 100644 index 8057109..0000000 --- a/tmpl/common.go +++ /dev/null @@ -1,79 +0,0 @@ -package tmpl - -import ( - "github.com/gin-gonic/gin" - "goflylivechat/tools" - "html/template" - "net/http" -) - -type CommonHtml struct { - Header template.HTML - Nav template.HTML - Left template.HTML - Bottom template.HTML - Rw http.ResponseWriter -} - -func NewRender(rw http.ResponseWriter) *CommonHtml { - obj := new(CommonHtml) - obj.Rw = rw - header := tools.FileGetContent("html/header.html") - nav := tools.FileGetContent("html/nav.html") - obj.Header = template.HTML(header) - obj.Nav = template.HTML(nav) - return obj -} -func (obj *CommonHtml) SetLeft(file string) { - leftStr := tools.FileGetContent("html/" + file + ".html") - obj.Left = template.HTML(leftStr) -} -func (obj *CommonHtml) SetBottom(file string) { - str := tools.FileGetContent("html/" + file + ".html") - obj.Bottom = template.HTML(str) -} -func (obj *CommonHtml) Display(file string, data interface{}) { - if data == nil { - data = obj - } - main := tools.FileGetContent("html/" + file + ".html") - t, _ := template.New(file).Parse(main) - t.Execute(obj.Rw, data) -} - -// 首页 -func PageIndex(c *gin.Context) { - if c.Request.RequestURI == "/favicon.ico" { - return - } - if noExist, _ := tools.IsFileNotExist("./install.lock"); noExist { - c.Redirect(302, "/install") - } - c.HTML(http.StatusOK, "index.html", gin.H{}) -} - -// 登陆界面 -func PageMain(c *gin.Context) { - nav := tools.FileGetContent("html/nav.html") - c.HTML(http.StatusOK, "main.html", gin.H{ - "Nav": template.HTML(nav), - }) -} - -// 客服界面 -func PageChatMain(c *gin.Context) { - c.HTML(http.StatusOK, "chat_main.html", nil) -} - -// 安装界面 -func PageInstall(c *gin.Context) { - if noExist, _ := tools.IsFileNotExist("./install.lock"); !noExist { - c.Redirect(302, "/login") - } - c.HTML(http.StatusOK, "install.html", nil) -} - -// 面板界面 -func PagePannel(c *gin.Context) { - c.HTML(http.StatusOK, "pannel.html", nil) -} diff --git a/tmpl/detail.go b/tmpl/detail.go deleted file mode 100644 index a4a0ee8..0000000 --- a/tmpl/detail.go +++ /dev/null @@ -1,37 +0,0 @@ -package tmpl - -import ( - "github.com/gin-gonic/gin" - "goflylivechat/models" - "html" - "html/template" - "net/http" -) - -func PageDetail(c *gin.Context) { - if c.Request.RequestURI == "/favicon.ico" { - return - } - page := c.Param("page") - lang, _ := c.Get("lang") - about := models.FindAboutByPageLanguage(page, lang.(string)) - cssJs := html.UnescapeString(about.CssJs) - title := about.TitleCn - keywords := about.KeywordsCn - desc := html.UnescapeString(about.DescCn) - content := html.UnescapeString(about.HtmlCn) - if lang == "en" { - title = about.TitleEn - keywords = about.KeywordsEn - desc = html.UnescapeString(about.DescEn) - content = html.UnescapeString(about.HtmlEn) - } - c.HTML(http.StatusOK, "detail.html", gin.H{ - "Lang": lang, - "Title": title, - "Keywords": keywords, - "Desc": desc, - "Content": template.HTML(content), - "CssJs": template.HTML(cssJs), - }) -} diff --git a/tmpl/folder.go b/tmpl/folder.go deleted file mode 100644 index d9fb677..0000000 --- a/tmpl/folder.go +++ /dev/null @@ -1,16 +0,0 @@ -package tmpl - -import "net/http" - -type FolderHtml struct { - *CommonHtml - CurrentPage int - Fid string -} - -func NewFolderHtml(w http.ResponseWriter) *FolderHtml { - obj := new(FolderHtml) - parent := NewRender(w) - obj.CommonHtml = parent - return obj -} diff --git a/tmpl/login.go b/tmpl/login.go deleted file mode 100644 index 355952c..0000000 --- a/tmpl/login.go +++ /dev/null @@ -1,20 +0,0 @@ -package tmpl - -import ( - "github.com/gin-gonic/gin" - "goflylivechat/tools" - "net/http" -) - -// 登陆界面 -func PageLogin(c *gin.Context) { - if noExist, _ := tools.IsFileNotExist("./install.lock"); noExist { - c.Redirect(302, "/install") - } - c.HTML(http.StatusOK, "login.html", nil) -} - -// 绑定界面 -func PageBind(c *gin.Context) { - c.HTML(http.StatusOK, "bind.html", gin.H{}) -} diff --git a/tmpl/mail.go b/tmpl/mail.go deleted file mode 100644 index 0c63771..0000000 --- a/tmpl/mail.go +++ /dev/null @@ -1,12 +0,0 @@ -package tmpl - -import ( - "github.com/gin-gonic/gin" - "net/http" -) - -//邮箱列表界面 -func PageMailList(c *gin.Context) { - return - c.HTML(http.StatusOK, "list.html", gin.H{}) -} diff --git a/tmpl/setting.go b/tmpl/setting.go deleted file mode 100644 index 7e90acd..0000000 --- a/tmpl/setting.go +++ /dev/null @@ -1,105 +0,0 @@ -package tmpl - -import ( - "github.com/gin-gonic/gin" - "net/http" -) - -//设置界面 -func PageSetting(c *gin.Context) { - c.HTML(http.StatusOK, "setting.html", gin.H{ - "tab_index": "1-1", - "action": "setting", - }) -} - -//设置欢迎 -func PageSettingWelcome(c *gin.Context) { - c.HTML(http.StatusOK, "setting_welcome.html", gin.H{ - "tab_index": "1-2", - "action": "setting_welcome", - }) -} - -//统计 -func PageSettingStatis(c *gin.Context) { - c.HTML(http.StatusOK, "setting_statistics.html", gin.H{ - "tab_index": "1-3", - "action": "setting_statistics", - }) -} - -//设置mysql -func PageSettingMysql(c *gin.Context) { - c.HTML(http.StatusOK, "setting_mysql.html", gin.H{ - "tab_index": "2-4", - "action": "setting_mysql", - }) -} - -//设置部署 -func PageSettingDeploy(c *gin.Context) { - c.HTML(http.StatusOK, "setting_deploy.html", gin.H{ - "tab_index": "2-5", - "action": "setting_deploy", - }) -} - -func PageKefuList(c *gin.Context) { - c.HTML(http.StatusOK, "setting_kefu_list.html", gin.H{ - "tab_index": "3-2", - "action": "setting_kefu_list", - }) -} -func PageAvator(c *gin.Context) { - c.HTML(http.StatusOK, "setting_avator.html", gin.H{ - "tab_index": "3-2", - "action": "setting_avator", - }) -} -func PageModifypass(c *gin.Context) { - c.HTML(http.StatusOK, "setting_modifypass.html", gin.H{ - "tab_index": "3-2", - "action": "setting_modifypass", - }) -} - -//角色列表 -func PageRoleList(c *gin.Context) { - c.HTML(http.StatusOK, "setting_role_list.html", gin.H{ - "tab_index": "3-1", - "action": "roles_list", - }) -} - -//角色列表 -func PageIpblack(c *gin.Context) { - c.HTML(http.StatusOK, "setting_ipblack.html", gin.H{ - "tab_index": "4-5", - "action": "setting_ipblack", - }) -} - -//配置项列表 -func PageConfig(c *gin.Context) { - c.HTML(http.StatusOK, "setting_config.html", gin.H{ - "tab_index": "4-6", - "action": "setting_config", - }) -} - -//配置项编辑首页 -func PageSettingIndexPage(c *gin.Context) { - c.HTML(http.StatusOK, "setting_pageindex.html", gin.H{ - "tab_index": "4-7", - "action": "setting_pageindex", - }) -} - -//配置项编辑首页 -func PageSettingIndexPages(c *gin.Context) { - c.HTML(http.StatusOK, "setting_indexpages.html", gin.H{ - "tab_index": "4-7", - "action": "setting_indexpages", - }) -}