优化代码结构

master
taoshihan 2 years ago
parent f621266291
commit 3e1ac34650

@ -12,9 +12,8 @@ CREATE TABLE `user` (
UNIQUE KEY `idx_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8|
TRUNCATE TABLE `user`|
INSERT INTO `user` (`id`, `name`, `password`, `nickname`, `created_at`, `updated_at`, `deleted_at`, `avator`) VALUES
(1, 'kefu2', '202cb962ac59075b964b07152d234b70', '小白菜', '2020-06-27 19:32:41', '2020-07-04 09:32:20', NULL, '/static/images/4.jpg'),
(2, 'kefu3', '202cb962ac59075b964b07152d234b70', '中白菜', '2020-07-02 14:36:46', '2020-07-05 08:46:57', NULL, '/static/images/11.jpg')|
INSERT INTO `user` (`id`, `name`, `password`, `nickname`, `created_at`, `updated_at`, `deleted_at`, `avator`) VALUE
(1, 'kefu2', '202cb962ac59075b964b07152d234b70', '智能客服系统', '2020-06-27 19:32:41', '2020-07-04 09:32:20', NULL, '/static/images/4.jpg')|
DROP TABLE IF EXISTS `visitor`|
CREATE TABLE `visitor` (
@ -61,9 +60,8 @@ CREATE TABLE `user_role` (
`role_id` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8|
INSERT INTO `user_role` (`id`, `user_id`, `role_id`) VALUES
(1, 1, 2),
(2, 2, 2)|
INSERT INTO `user_role` (`id`, `user_id`, `role_id`) VALUE
(1, 1, 2)|
DROP TABLE IF EXISTS `role`|
CREATE TABLE `role` (
@ -74,8 +72,7 @@ CREATE TABLE `role` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8|
INSERT INTO `role` (`id`, `name`, `method`, `path`) VALUES
(1, '普通客服', 'GET', 'GET:/kefuinfo,GET:/kefulist,GET:/roles,POST:/notice_save,POST:/notice'),
(2, '管理员', '*', '*')|
(1, '普通客服', 'GET', 'GET:/kefuinfo,GET:/kefulist,GET:/roles,POST:/notice_save,POST:/notice')|
DROP TABLE IF EXISTS `welcome`|
CREATE TABLE `welcome` (
@ -113,19 +110,9 @@ CREATE TABLE `config` (
PRIMARY KEY (`id`),
UNIQUE KEY `conf_key` (`conf_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8|
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '是否开启Server酱微信提醒', 'NoticeServerJiang', 'false')|
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, 'Server酱API', 'ServerJiangAPI', '')|
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '微信小程序Token', 'WeixinToken', '')|
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '当前小程序审核状态', 'MiniAppAudit', 'yes')|
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '是否允许上传附件', 'SendAttachment', 'true')|
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '发送通知邮件(SMTP地址)', 'NoticeEmailSmtp', '')|
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '发送通知邮件(邮箱)', 'NoticeEmailAddress', '')|
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '发送通知邮件(密码)', 'NoticeEmailPassword', '')|
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, 'App个推(Token)', 'GetuiToken', '')|
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, 'App个推(AppID)', 'GetuiAppID', '')|
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, 'App个推(AppKey)', 'GetuiAppKey', '')|
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, 'App个推(AppSecret)', 'GetuiAppSecret', '')|
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, 'App个推(AppMasterSecret)', 'GetuiMasterSecret', '')|
DROP TABLE IF EXISTS `about`|
CREATE TABLE `about` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
@ -142,33 +129,6 @@ CREATE TABLE `about` (
PRIMARY KEY (`id`),
UNIQUE KEY `page` (`page`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8|
INSERT INTO `about` (`id`, `title_cn`, `title_en`, `keywords_cn`, `keywords_en`, `desc_cn`, `desc_en`, `css_js`, `html_cn`, `html_en`, `page`) VALUES
(NULL, '免费开源客服系统GOFLY0.4.1-演示页',
'Free Customer Live Chat GOFLY0.4.1-demo',
'GOFLYGO-FLY',
'GOFLYGO-FLY',
'一款开箱即用的在线客服系统',
'a free customer live chat',
'<style>body{color: #333;padding-left: 40px;}h1{font-size: 6em;}h2{font-size: 3em;font-weight: normal;}a{color: #333;}</style>',
'<script src="/assets/js/gofly-front.js?v=1"></script><script>
GOFLY.init({
GOFLY_URL:"",
GOFLY_KEFU_ID: "kefu2",
GOFLY_BTN_TEXT: "GOFLY 在线客服!",
GOFLY_LANG:"cn",
})
</script>
<h1>:)</h1><h2> <a href="https://gofly.sopans.com">GOFLY0.4.1</a> 线 !</h2><h3><a href="/login">Administrator</a>&nbsp;<a href="/index_en">English</a>&nbsp;<a href="/index_cn"></a></h3>',
'<script src="/assets/js/gofly-front.js?v=1"></script><script>
GOFLY.init({
GOFLY_URL:"",
GOFLY_KEFU_ID: "kefu2",
GOFLY_BTN_TEXT: "GOFLY LIVE CHAT!",
GOFLY_LANG:"en",
})
</script>
<h1>:)</h1><h2>HELLO <a href="https://gofly.sopans.com">GOFLY0.4.1</a> LIVE CHAT !</h2><h3><a href="/login">Administrator</a>&nbsp;<a href="/index_en">English</a>&nbsp;<a href="/index_cn"></a></h3>',
'index')|
DROP TABLE IF EXISTS `reply_group`|
CREATE TABLE `reply_group` (
`id` int(11) NOT NULL AUTO_INCREMENT,

@ -1,16 +0,0 @@
package middleware
import (
"github.com/gin-gonic/gin"
)
func SetLanguage(c *gin.Context) {
var lang string
if lang = c.Param("lang"); lang == "" {
lang = c.Query("lang")
}
if lang == "" || lang != "cn" {
lang = "en"
}
c.Set("lang", lang)
}

@ -8,8 +8,6 @@ import (
)
func InitApiRouter(engine *gin.Engine) {
//首页
engine.GET("/", controller.Index)
//路由分组
v2 := engine.Group("/2")
{
@ -68,7 +66,7 @@ func InitApiRouter(engine *gin.Engine) {
engine.GET("/about", controller.GetAbout)
engine.POST("/about", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.PostAbout)
engine.GET("/aboutpages", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.GetAbouts)
engine.GET("/notice", middleware.SetLanguage, controller.GetNotice)
engine.GET("/notice",controller.GetNotice)
engine.POST("/notice", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.PostNotice)
engine.DELETE("/notice", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.DelNotice)
engine.POST("/notice_save", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.PostNoticeSave)

@ -7,12 +7,13 @@ import (
)
func InitViewRouter(engine *gin.Engine) {
engine.GET("/index_:lang", middleware.SetLanguage, tmpl.PageIndex)
engine.GET("/", tmpl.PageIndex)
engine.GET("/index_:lang", tmpl.PageIndex)
engine.GET("/install", tmpl.PageInstall)
engine.GET("/detail_:page", middleware.SetLanguage, tmpl.PageDetail)
engine.GET("/detail_:page",tmpl.PageDetail)
engine.GET("/login", tmpl.PageLogin)
engine.GET("/chat_page", middleware.SetLanguage, tmpl.PageChat)
engine.GET("/chatIndex", middleware.SetLanguage, tmpl.PageChat)
engine.GET("/chat_page",tmpl.PageChat)
engine.GET("/chatIndex",tmpl.PageChat)
engine.GET("/chatKfIndex", tmpl.PageKfChat)
engine.GET("/main", middleware.JwtPageMiddleware, tmpl.PageMain)
engine.GET("/chat_main", middleware.JwtPageMiddleware, tmpl.PageChatMain)

File diff suppressed because one or more lines are too long

@ -4,12 +4,29 @@
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title>{{.Title}}</title>
<meta name="keywords" content="{{.Keywords}}" />
<meta name="description" content="{{.Desc}}" />
{{.CssJs}}
<title>独立私有化智能在线客服系统</title>
<link rel="stylesheet" type="text/css" href="static/css/bootstrap.min.css?v=0.5.5" />
</head>
<body>
{{.Content}}
<style>
.deployLink {
width: 800px;
margin: 150px auto;
background-color: #ecf5ff;
padding: 25px;
color: #0061c5;
border: 1px solid #d9ecff;
line-height: 20px;
font-size: 12px;
font-size: 20px;
}
</style>
<div class="deployLink">
<h1>智能在线客服系统,欢迎您</h1>
<a class="btn btn-primary mt-4" href="/chatIndex?kefu_id=kefu2" target="_blank">访客地址</a>
<a class="btn btn-primary mt-4" href="/login" target="_blank">登录后台</a>
</div>
</body>
</html>

@ -8,7 +8,6 @@ import (
//咨询界面
func PageChat(c *gin.Context) {
kefuId := c.Query("kefu_id")
lang, _ := c.Get("lang")
refer := c.Query("refer")
if refer == "" {
refer = c.Request.Referer()
@ -18,7 +17,6 @@ func PageChat(c *gin.Context) {
}
c.HTML(http.StatusOK, "chat_page.html", gin.H{
"KEFU_ID": kefuId,
"Lang": lang.(string),
"Refer": refer,
})
}

@ -2,9 +2,7 @@ package tmpl
import (
"github.com/gin-gonic/gin"
"github.com/taoshihan1991/imaptool/models"
"github.com/taoshihan1991/imaptool/tools"
"html"
"html/template"
"net/http"
)
@ -51,26 +49,7 @@ func PageIndex(c *gin.Context) {
if noExist, _ := tools.IsFileNotExist("./install.lock"); noExist {
c.Redirect(302, "/install")
}
lang, _ := c.Get("lang")
about := models.FindAboutByPageLanguage("index", 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, "index.html", gin.H{
"Lang": lang,
"Title": title,
"Keywords": keywords,
"Desc": desc,
"Content": template.HTML(content),
"CssJs": template.HTML(cssJs),
})
}

Loading…
Cancel
Save