From 6f6033775be355a70066e89a72c3097e28895698 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=B6=E5=A3=AB=E6=B6=B5?= <630892807@qq.com>
Date: Tue, 13 Oct 2020 21:26:58 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=A6=96=E9=A1=B5=E5=86=85?=
=?UTF-8?q?=E5=AE=B9=E4=BB=8E=E6=95=B0=E6=8D=AE=E5=BA=93=E8=AF=BB=E5=8F=96?=
=?UTF-8?q?=E7=AD=89=E5=BE=85=E5=90=8E=E5=8F=B0=E7=BC=96=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
cmd/install.go | 2 +-
config/go-fly.sql | 63 +++++++++++-------
models/abouts.go | 20 ++++++
static/html/index.html | 142 ++---------------------------------------
tmpl/common.go | 19 ++++++
5 files changed, 86 insertions(+), 160 deletions(-)
create mode 100644 models/abouts.go
diff --git a/cmd/install.go b/cmd/install.go
index e025e5c..ff20d45 100644
--- a/cmd/install.go
+++ b/cmd/install.go
@@ -28,7 +28,7 @@ func install() {
os.Exit(1)
}
sqls, _ := ioutil.ReadFile(sqlFile)
- sqlArr := strings.Split(string(sqls), ";")
+ sqlArr := strings.Split(string(sqls), "|")
for _, sql := range sqlArr {
if sql == "" {
continue
diff --git a/config/go-fly.sql b/config/go-fly.sql
index 1e8c16e..a342e36 100644
--- a/config/go-fly.sql
+++ b/config/go-fly.sql
@@ -1,4 +1,4 @@
-DROP TABLE IF EXISTS `user`;
+DROP TABLE IF EXISTS `user`|
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL DEFAULT '',
@@ -10,13 +10,13 @@ CREATE TABLE `user` (
`avator` varchar(100) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `idx_name` (`name`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-TRUNCATE TABLE `user`;
+) 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');
+(2, 'kefu3', '202cb962ac59075b964b07152d234b70', '中白菜', '2020-07-02 14:36:46', '2020-07-05 08:46:57', NULL, '/static/images/11.jpg')|
-DROP TABLE IF EXISTS `visitor`;
+DROP TABLE IF EXISTS `visitor`|
CREATE TABLE `visitor` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL DEFAULT '',
@@ -33,9 +33,9 @@ CREATE TABLE `visitor` (
`client_ip` varchar(100) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `visitor_id` (`visitor_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8|
-DROP TABLE IF EXISTS `message`;
+DROP TABLE IF EXISTS `message`|
CREATE TABLE `message` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`kefu_id` varchar(100) NOT NULL DEFAULT '',
@@ -49,32 +49,32 @@ CREATE TABLE `message` (
PRIMARY KEY (`id`),
KEY `kefu_id` (`kefu_id`),
KEY `visitor_id` (`visitor_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8|
-DROP TABLE IF EXISTS `user_role`;
+DROP TABLE IF EXISTS `user_role`|
CREATE TABLE `user_role` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL DEFAULT '0',
`role_id` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8|
INSERT INTO `user_role` (`id`, `user_id`, `role_id`) VALUES
(1, 1, 1),
-(2, 2, 2);
+(2, 2, 2)|
-DROP TABLE IF EXISTS `role`;
+DROP TABLE IF EXISTS `role`|
CREATE TABLE `role` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL DEFAULT '',
`method` varchar(100) NOT NULL DEFAULT '',
`path` varchar(2048) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8|
INSERT INTO `role` (`id`, `name`, `method`, `path`) VALUES
(1, '普通客服', 'GET', '/kefuinfo,/kefulist,/roles'),
-(2, '管理员', '*', '*');
+(2, '管理员', '*', '*')|
-DROP TABLE IF EXISTS `welcome`;
+DROP TABLE IF EXISTS `welcome`|
CREATE TABLE `welcome` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_id` varchar(100) NOT NULL DEFAULT '',
@@ -83,11 +83,11 @@ CREATE TABLE `welcome` (
`ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8|
INSERT INTO `welcome` (`id`, `user_id`, `content`, `is_default`, `ctime`) VALUES
-(1, 'kefu2', '本客服代码开源,欢迎star,开源地址:https://github.com/taoshihan1991/go-fly', 1, '2020-08-24 02:57:49');
+(1, 'kefu2', '本客服代码开源,欢迎star,开源地址:https://github.com/taoshihan1991/go-fly', 1, '2020-08-24 02:57:49')|
-DROP TABLE IF EXISTS `ipblack`;
+DROP TABLE IF EXISTS `ipblack`|
CREATE TABLE `ipblack` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip` varchar(100) NOT NULL DEFAULT '',
@@ -95,9 +95,9 @@ CREATE TABLE `ipblack` (
`kefu_id` varchar(100) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `ip` (`ip`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8|
-DROP TABLE IF EXISTS `config`;
+DROP TABLE IF EXISTS `config`|
CREATE TABLE `config` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`conf_name` varchar(255) NOT NULL DEFAULT '',
@@ -105,7 +105,26 @@ CREATE TABLE `config` (
`conf_value` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `conf_key` (`conf_key`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+) 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', '');
\ No newline at end of file
+INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '微信小程序Token', 'WeixinToken', '');
+
+DROP TABLE IF EXISTS `about`|
+CREATE TABLE `about` (
+ `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `title_cn` varchar(255) NOT NULL DEFAULT '',
+ `title_en` varchar(255) NOT NULL DEFAULT '',
+ `keywords_cn` varchar(255) NOT NULL DEFAULT '',
+ `keywords_en` varchar(255) NOT NULL DEFAULT '',
+ `desc_cn` varchar(1024) NOT NULL DEFAULT '',
+ `desc_en` varchar(1024) NOT NULL DEFAULT '',
+ `css_js` text NOT NULL,
+ `html_cn` text NOT NULL,
+ `html_en` text NOT NULL,
+ `page` varchar(50) NOT NULL DEFAULT '',
+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
+(1, 'GO-FLY - 极简强大的Go语言在线客服系统', 'GO-FLY - Simple and Powerful Go language online customer chat system', 'GO-FLY,GO-FLY', 'GO-FLY,GO-FLY', 'GO-FLY,GO-FLY,一套为PHP工程师、Golang工程师准备的基于 Vue 2.0的在线客服即时通讯系统', 'GO-FLY,GO-FLY, a Vue 2.0-based online customer service instant messaging system for PHP engineers and Golang engineers', ' ', '
\r\n
极简强大的Go语言在线客服系统
\r\n
GO-FLY,一套为PHP工程师、Golang工程师准备的基于 Vue 2.0的在线客服即时通讯系统
\r\n
\r\n\r\n \r\n
\r\n \r\n
\r\n\r\n
\r\n
主要技术架构
\r\n
github.com/dgrijalva/jwt-go
\r\n
github.com/gin-gonic/gin
\r\n
github.com/go-sql-driver/mysql
\r\n
github.com/gobuffalo/packr/v2
\r\n
github.com/gorilla/websocket
\r\n
github.com/ipipdotnet/ipdb-go
\r\n
github.com/jinzhu/gorm
\r\n
github.com/satori/go.uuid
\r\n
github.com/spf13/cobra
\r\n
github.com/swaggo/gin-swagger
\r\n
github.com/swaggo/swag\r\n
\r\n
\r\n
\r\n
', ' Simple and Powerful Go language online customer chat system
GO-FLY, a Vue 2.0-based online customer service instant messaging system for PHP engineers and Golang engineers
Main technical architecture
github.com/dgrijalva/jwt-go
github.com/gin-gonic/gin
github.com/go-sql-driver/mysql
github.com/gobuffalo/packr/v2
github.com/gorilla/websocket
github.com/ipipdotnet/ipdb-go
github.com/jinzhu/gorm
github.com/satori/go.uuid
github.com/spf13/cobra
github.com/swaggo/gin-swagger
github.com/swaggo/swag
','index');
\ No newline at end of file
diff --git a/models/abouts.go b/models/abouts.go
new file mode 100644
index 0000000..eec333e
--- /dev/null
+++ b/models/abouts.go
@@ -0,0 +1,20 @@
+package models
+
+type About struct {
+ ID uint `gorm:"primary_key" json:"id"`
+ TitleCn string `json:"title_cn"`
+ TitleEn string `json:"title_en"`
+ KeywordsCn string `json:"keywords_cn"`
+ KeywordsEn string `json:"keywords_en"`
+ DescCn string `json:"desc_cn"`
+ DescEn string `json:"desc_en"`
+ CssJs string `json:"css_js"`
+ HtmlCn string `json:"html_cn"`
+ HtmlEn string `json:"html_en"`
+}
+
+func FindAboutByPage(page interface{}) About {
+ var a About
+ DB.Where("page = ?", page).First(&a)
+ return a
+}
diff --git a/static/html/index.html b/static/html/index.html
index 87c23f4..1c1c701 100644
--- a/static/html/index.html
+++ b/static/html/index.html
@@ -4,115 +4,11 @@
- GO-FLY - {{.WebDesc}}
-
+ {{.Title}}
+
+
-
+ {{.CssJs}}
-
-
{{.WebDesc}}
-
{{.SubIntro}}
-
-
- {{if eq .Lang "en"}}
-
- {{else}}
-
- {{end}}
-
-
-
-
{{.Maintech}}
-
github.com/dgrijalva/jwt-go
-
github.com/gin-gonic/gin
-
github.com/go-sql-driver/mysql
-
github.com/gobuffalo/packr/v2
-
github.com/gorilla/websocket
-
github.com/ipipdotnet/ipdb-go
-
github.com/jinzhu/gorm
-
github.com/satori/go.uuid
-
github.com/spf13/cobra
-
github.com/swaggo/gin-swagger
-
github.com/swaggo/swag
-
-
-
-
+{{.Content}}