taoshihan 3 weeks ago
parent 96a05e8258
commit d142d04443

@ -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)
}

@ -1,30 +0,0 @@
{{define "setting_left"}}
<el-aside width="200px">
<el-menu
default-active="{{.tab_index}}" :default-openeds="openIndex"
:unique-opened=true>
<el-submenu index="1">
<template slot="title">
<i class="el-icon-s-custom"></i>
<span>账户设置</span>
</template>
<el-menu-item-group>
<el-menu-item index="1-1" v-on:click="openUrl('/setting_statistics')">统计信息</el-menu-item>
<el-menu-item index="1-3" v-on:click="openUrl('/setting_modifypass')">修改密码</el-menu-item>
<el-menu-item index="1-4" v-on:click="openUrl('/setting_avator')">修改资料</el-menu-item>
</el-menu-item-group>
</el-submenu>
<el-submenu index="2">
<template slot="title">
<i class="el-icon-s-tools"></i>
<span>系统设置</span>
</template>
<el-menu-item-group>
<el-menu-item index="4-6" v-on:click="openUrl('/setting_config')">配置参数</el-menu-item>
<el-menu-item index="4-5" v-on:click="openUrl('/setting_ipblack')">IP黑名单</el-menu-item>
<el-menu-item index="2-5" v-on:click="openUrl('/setting_deploy')">网页部署</el-menu-item>
</el-menu-item-group>
</el-submenu>
</el-menu>
</el-aside>
{{end}}

@ -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,
})
}

@ -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)
}

@ -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),
})
}

@ -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
}

@ -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{})
}

@ -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{})
}

@ -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",
})
}
Loading…
Cancel
Save