diff --git a/conf/app.conf b/conf/app.conf index 8fae0e5..3667cfd 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -1,6 +1,6 @@ appname = beeblog -runmode = "prod" +runmode = "dev" sessionon = true sessiongcmaxlifetime = 36000 @@ -13,10 +13,17 @@ host = aiprose.com httpport = 8082 uploadDir = "static/upload/" imgUrlPrefix = "http://localhost:8082/static/upload/" -dburl = "yasaka@tcp(localhost:3306)" +dburl = "Yasaka.00@tcp(192.168.0.105:3308)" +eshost = http://192.168.0.105:9200/ +redisHost = 192.168.0.105 +redisPort = 6379 [prod] httpport = 8082 uploadDir = "/root/oss/aiprose/" imgUrlPrefix = "https://oss.aiprose.com/aiprose/" -dburl = "Yasaka.00@tcp(localhost:3308)" \ No newline at end of file +dburl = "Yasaka.00@tcp(localhost:3308)" +eshost = http://127.0.0.1:9200/ +redisHost = 127.0.0.1 +redisPort = 9379 +redisPwd = aiprose \ No newline at end of file diff --git a/controllers/UserController.go b/controllers/UserController.go index 4f924b3..3dacc62 100644 --- a/controllers/UserController.go +++ b/controllers/UserController.go @@ -3,9 +3,12 @@ package controllers import ( "beeblog/models" "beeblog/service" + "beeblog/utils" "crypto/md5" "encoding/hex" + "fmt" beego "github.com/beego/beego/v2/server/web" + "github.com/mojocn/base64Captcha" "strconv" "strings" "time" @@ -318,3 +321,28 @@ func (this *UserController) Logout() { this.Redirect("/", 302) return } + +var store = utils.RedisStore{} + +func (u *UserController) Captcha() { + type CaptchaResult struct { + Id string `json:"captchaId"` + Base64Blob string `json:"img"` + } + driver := base64Captcha.NewDriverMath(40, 150, 0, 0, nil, nil, nil) + //driver := base64Captcha.DefaultDriverDigit + c := base64Captcha.NewCaptcha(driver, store) + id, b64s, err := c.Generate() + if err != nil { + fmt.Println(err) + u.Data["json"] = models.ReurnError(500, "验证码获取异常") + u.ServeJSON() + return + } + detail := make(map[string]string, 2) + detail["captchaId"] = id + detail["img"] = b64s + u.Data["json"] = models.ReurnData("ok", detail) + u.ServeJSON() + return +} diff --git a/go.mod b/go.mod index c86b744..9e71805 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,13 @@ module beeblog require ( github.com/beego/beego/v2 v2.0.1 github.com/fortytw2/leaktest v1.3.0 // indirect + github.com/go-redis/redis v6.15.9+incompatible github.com/go-sql-driver/mysql v1.5.0 github.com/lib/pq v1.7.0 // indirect github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e // indirect + github.com/mojocn/base64Captcha v1.3.5 github.com/olivere/elastic v6.2.22+incompatible + golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d // indirect gopkg.in/yaml.v2 v2.3.0 // indirect ) diff --git a/routers/UserRouter.go b/routers/UserRouter.go index c146674..7059155 100644 --- a/routers/UserRouter.go +++ b/routers/UserRouter.go @@ -11,6 +11,8 @@ func init() { beego.Router("/regist", &controllers.UserController{}, "get:RegistPage") beego.Router("/u/:id([0-9]+)", &controllers.UserController{}, "get:UserInfo") + beego.Router("/api/authc/captcha", &controllers.UserController{}, "get:Captcha") + beego.Router("/api/user/edit", &controllers.UserController{}, "post:Edit") beego.Router("/api/login", &controllers.UserController{}, "post:Login") beego.Router("/api/regist", &controllers.UserController{}, "post:Regist") diff --git a/static/css/common.css b/static/css/common.css index 5721ffe..cbe9a0d 100644 --- a/static/css/common.css +++ b/static/css/common.css @@ -342,7 +342,6 @@ img { } .login-root { - background: #f0e7db url("/static/img/login.png") no-repeat; position: absolute; min-height: 100%; width: 100%; @@ -403,81 +402,6 @@ img { border-right: none; } -.login-footer{ - position: absolute; - bottom: 0; - left: 0; - width: 100%; - height: 110px; -} - -.login-root { - background: #f0e7db url("/static/img/login.png") no-repeat; - position: absolute; - min-height: 100%; - width: 100%; - overflow: hidden; -} - -.login-root .input-container{ - position: fixed; - left: 65%; - top: 33px; - background: url("/static/img/loginbg.png") no-repeat center top; -} -.login-root .input-container .input-root{ - width: 370px; - height: 500px; -} -.login-root .input-container .input-root p { - font-size: 21px; - text-align: center; - padding-top: 195px; -} -.login-root .input-container .input-root .inputs-class{ - padding: 0 50px; -} -.login-root .input-container .input-root .input-group{ - display: table; - border-collapse: separate; -} -.login-root .input-container .input-root .inputs-class .input-class{ - height: 32px; - margin: 18px 0; - display: flex; -} -.login-root .input-container .input-root .inputs-class .input-class input{ - flex: 1; - height: 26px !important; - padding: 2px 14px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; - border-top-left-radius: 0; - border-bottom-left-radius: 0; - display: table-cell; - border: 1px solid #ccc; -} -.login-root .input-container .input-root .inputs-class .input-class .input-group-addon{ - color: #555; - line-height: 26px !important; - font-size: 12px; - padding: 2px 14px; - line-height: 1.5; - border-radius: 3px; - display: table-cell; - border: 1px solid #ccc; - border-right: none; -} - -.login-footer{ - position: absolute; - bottom: 0; - left: 0; - width: 100%; - height: 110px; -} - .me-menu { position: fixed; top: 60px; diff --git a/static/css/common.min.css b/static/css/common.min.css index 166a540..82a93ee 100644 --- a/static/css/common.min.css +++ b/static/css/common.min.css @@ -1 +1 @@ -html,body{font-size:14px !important;background:#fff;color:#353535;height:100%;width:100%;}#cnzz_stat_icon_1277992374{text-align:center;display:block;}#cnzz_stat_icon_1277992374 a{color:rgba(255,255,255,.7) !important;}a{text-decoration:none;}.layui-nav{text-align:right;}.navbar-default{border-color:#f8d9ea !important;}.img-circle-large{width:110px;height:110px;}.root-container{height:100%;width:100%;max-width:100%;}.nav-container{max-height:50px;position:fixed;width:100%;z-index:1000;left:0;top:0;}.nav-container li a:hover{transform:rotate(5deg) scale(1.1);}.nav-container p{display:inline-block;float:left;line-height:48px;font-size:20px;}::-webkit-scrollbar{width:1px;}::-webkit-scrollbar-track-piece{background-color:rgba(0,0,0,0);-webkit-border-radius:6px;}.cursor{cursor:pointer}.footer-root{color:rgba(255,255,255,.7);position:relative;width:100%;height:105px;display:flex;}.footer-friend{text-align:center;height:25px;line-height:25px;}.footer-friend a{color:rgba(255,255,255,.7);text-decoration:none;}.img-circle{width:31px;height:31px;border-radius:50%;}.login-footer .wxcode{margin-right:20px;}.layui-nav .layui-nav-item{line-height:49px !important;}.layui-nav .layui-nav-item a{height:49px !important;line-height:49px;}.layui-nav .layui-this:after,.layui-nav-bar,.layui-nav-tree .layui-nav-itemed:after{height:1px;}.footer-container{background-color:#393D49;padding:30px 5% 0 5%;}.pagination{margin:18px 0;}.pagination ul li{line-height:20px;width:20px;height:20px;display:inline-block;border-color:#28a3ef;font-size:16px;}.pagination ul li .next .prev{font-size:20px !important;}.pagination ul .active{background-color:#28a3ef;}.pagination ul .active a{color:#fff;}.breadcrumb-container{padding:20px;}.blog-root{width:68%;margin:40px auto;}.blog-root a{color:#28a3ef !important;}.blog-root .blog-title{display:block;margin:60px 0 20px 0;text-align:center}.blog-root .blog-detaile{color:#2f2f2f;}.blog-root .blog-detaile pre{border:1px #d2e8b9 solid;box-shadow:1px 1px 2px 2px #d2e8b9;margin:5px 0;}.blog-root .blog-detaile h4{font-size:20px;font-weight:500;}.blog-user{position:fixed;top:60px;left:5px;width:100px;height:100%;background-color:#f9f9f9;}.blog-info{padding:15px;}.blog-info .blog-author{display:flex;}.blog-info .blog-author .author-headimg{display:inline-block;width:48px;height:48px;}.blog-info .blog-author .blog-label{flex:1;height:22px;line-height:22px;text-align:right;padding-top:26px;}.blog-info .blog-author .blog-label label{color:#888;border:1px dotted #aaa;padding:5px;border-radius:5px;font-size:10px;}.blog-info .blog-author .author-headimg .img-circle{width:48px !important;height:48px !important;margin-top:0px !important;}.blog-info .blog-author .author-info{display:inline-block;height:48px !important;vertical-align:bottom;text-align:left;margin-left:5px;}.blog-info .blog-author .author-info a{display:inline-block;height:28px;line-height:28px;font-size:16px;}.blog-info .blog-author .author-info span{display:inline-block;height:20px;line-height:20px;font-size:12px;color:#888;padding-right:8px;}.blog-info em{padding:0 8px !important;}.comms-root{width:68%;margin:0 auto;}.comms-root a{text-decoration:none;}img{max-width:100% !important;}.blog-referral{width:100%;margin:40px auto;}.blog-referral p{padding:3px 0;}.layui-code-view .layui-code-ol li{margin-left:0px !important;}.home-container{height:100%;margin:50px 5% 60px 5%;}.home-container hr{margin:0;}.home-hearder{margin:10px 0;display:flex;height:30px;line-height:30px;}.home-hearder .m-select{color:#353535;width:150px;display:inline-block;height:32px;border-radius:3px;padding:4px 14px;}.home-hearder .layui-btn-group .active a{color:#fff;}.home-hearder .layui-btn-group a{color:#353535;text-decoration:none;}.nelson-btn{color:#ec6149 !important;border-radius:15px;border:1px solid #bbb !important;}.nelson-btn:hover{background:#fff !important;color:#ec6149 !important;border-radius:15px;border:1px solid #ec6149 !important;}.home-content{display:flex;min-height:36px;line-height:36px;}.home-content-title{display:inline-block;flex:1;}.home-content-desc{display:flex}.home-content-desc span{display:inline-block;text-align:center}.blog-root h5{color:#888;font-size:14px;margin:9px 0;font-family:inherit;font-weight:700;line-height:1.5;}.blog-root a{text-decoration:none;}.blog-root p{margin:1px 0 9px;}.login-root{background:#f0e7db url("/static/img/login.png") no-repeat;position:absolute;min-height:100%;width:100%;overflow:hidden;}.login-root .input-container{position:fixed;left:65%;top:33px;background:url("/static/img/loginbg.png") no-repeat center top;}.login-root .input-container .input-root{width:370px;height:500px;}.login-root .input-container .input-root .inputs-class{margin-top:220px;padding:10px 50px 10px 50px;}.login-root .input-container .input-root .regist{margin-top:200px;}.login-root .input-container .input-root .inputs-class .login-bottom{margin-top:10px;text-align:right;}.login-root .input-container .input-root .input-group{display:table;border-collapse:separate;}.login-root .input-container .input-root .inputs-class .input-class{height:32px;margin:18px 0;display:flex;}.login-root .input-container .input-root .inputs-class .input-class input{flex:1;height:26px !important;padding:2px 14px;font-size:12px;line-height:1.5;border-radius:3px;border-top-left-radius:0;border-bottom-left-radius:0;display:table-cell;border:1px solid #ccc;}.login-root .input-container .input-root .inputs-class .input-class .input-group-addon{color:#555;line-height:26px !important;font-size:12px;padding:2px 14px;line-height:1.5;border-radius:3px;display:table-cell;border:1px solid #ccc;border-right:none;}.login-footer{position:absolute;bottom:0;left:0;width:100%;height:110px;}.login-root{background:#f0e7db url("/static/img/login.png") no-repeat;position:absolute;min-height:100%;width:100%;overflow:hidden;}.login-root .input-container{position:fixed;left:65%;top:33px;background:url("/static/img/loginbg.png") no-repeat center top;}.login-root .input-container .input-root{width:370px;height:500px;}.login-root .input-container .input-root p{font-size:21px;text-align:center;padding-top:195px;}.login-root .input-container .input-root .inputs-class{padding:0 50px;}.login-root .input-container .input-root .input-group{display:table;border-collapse:separate;}.login-root .input-container .input-root .inputs-class .input-class{height:32px;margin:18px 0;display:flex;}.login-root .input-container .input-root .inputs-class .input-class input{flex:1;height:26px !important;padding:2px 14px;font-size:12px;line-height:1.5;border-radius:3px;border-top-left-radius:0;border-bottom-left-radius:0;display:table-cell;border:1px solid #ccc;}.login-root .input-container .input-root .inputs-class .input-class .input-group-addon{color:#555;line-height:26px !important;font-size:12px;padding:2px 14px;line-height:1.5;border-radius:3px;display:table-cell;border:1px solid #ccc;border-right:none;}.login-footer{position:absolute;bottom:0;left:0;width:100%;height:110px;}.me-menu{position:fixed;top:60px;left:20px;width:260px;height:100%;background-color:#f9f9f9;}.me-menu p{cursor:pointer;font-size:15px;color:#555;margin:0;height:32px;line-height:32px;}.me-menu .active{color:#3CBEF8 !important}.me-menu p a{margin-left:5px;color:#555;text-decoration:none;}.me-menu .active span{display:inline-block;height:100%;width:2px;background-color:#3CBEF8;}.me-menu .active a{color:#3CBEF8;vertical-align:top;height:32px;line-height:32px;display:inline-block;}.me-blog-root{height:100%;margin:50px 4% 0 0;}.me-blog-list{margin-left:300px;}.me-blog-list p{height:30px;line-height:30px;margin:0;font-size:15px;}.me-footer{position:absolute;bottom:0;left:0;width:100%;height:110px;padding:0 4%;}.me-blog-footer{height:110px;padding:0 4%;margin-left:290px;}.info-header{flex:1;}.info-header span{margin-right:6px;}.uinfo{color:#515a6e;margin:5px;}.udesc span{margin-right:8px;}.blog-list{display:flex;font-size:16px;min-height:35px;line-height:35px;}.us-root{margin-top:50px;display:flex;margin-left:5%;font-size:16px;min-height:720px;height:100%;}.us-root p{padding:5px 0;color:#323232;}.us-root a{color:#28a3ef !important;}.blog-title{display:flex;height:50px;line-height:50px;}.blog-title input{padding-left:12px;flex:1;height:44px;border:0;}.blog-title button{height:32px;color:#fff;margin-top:9px;}.w-e-toolbar{height:40px;line-height:30px;}.map-root{position:absolute;width:100%;height:100%;left:0;top:0;}.map-root .map-container{width:100%;height:100%;}.amap-logo,.amap-copyright{display:none !important;visibility:hidden !important;}.blog-detaile p code{color:red;padding:2px 5px;}.search-root{margin-top:50px;}.search-root .input-class{display:table;border-collapse:separate;}.search-root .input-class{width:50%;height:32px;margin:18px auto;display:flex;}.search-root .input-class input{flex:1;height:36px !important;padding:2px 14px;font-size:12px;line-height:1.5;border-radius:3px;border-top-right-radius:0;border-bottom-right-radius:0;display:table-cell;border:1px solid #3385ff;}.search-root .input-class .input-group-addon{color:#555;height:36px;line-height:36px !important;font-size:17px !important;font-size:12px;padding:2px 14px;line-height:36px;border-radius:3px;display:table-cell;background-color:#3385ff;border-top-left-radius:0;border-bottom-left-radius:0;color:#fff;border:1px solid #3385ff;border-left:none;cursor:pointer;}.search-result{margin:35px 15%;}.search-item{padding:7px 15px;}.search-result a{display:block;cursor:pointer;height:25px;line-height:25px;font-size:16px;text-decoration:#00c6ff;flex:1;}.search-result .search-title{display:flex;}.search-result span{cursor:pointer;font-size:12px;height:25px;line-height:25px;}.search-content{font-size:12px;}.v-note-wrapper{height:100%;z-index:99 !important;}.modal_form{display:flex;margin-bottom:10px;}.modal_form .span-lable{display:inline-block;width:100px;height:30px;line-height:30px;} \ No newline at end of file +html,body{font-size:14px !important;background:#fff;color:#353535;height:100%;width:100%;}#cnzz_stat_icon_1277992374{text-align:center;display:block;}#cnzz_stat_icon_1277992374 a{color:rgba(255,255,255,.7) !important;}a{text-decoration:none;}.layui-nav{text-align:right;}.navbar-default{border-color:#f8d9ea !important;}.img-circle-large{width:110px;height:110px;}.root-container{height:100%;width:100%;max-width:100%;}.nav-container{max-height:50px;position:fixed;width:100%;z-index:1000;left:0;top:0;}.nav-container li a:hover{transform:rotate(5deg) scale(1.1);}.nav-container p{display:inline-block;float:left;line-height:48px;font-size:20px;}::-webkit-scrollbar{width:1px;}::-webkit-scrollbar-track-piece{background-color:rgba(0,0,0,0);-webkit-border-radius:6px;}.cursor{cursor:pointer}.footer-root{color:rgba(255,255,255,.7);position:relative;width:100%;height:105px;display:flex;}.footer-friend{text-align:center;height:25px;line-height:25px;}.footer-friend a{color:rgba(255,255,255,.7);text-decoration:none;}.img-circle{width:31px;height:31px;border-radius:50%;}.login-footer .wxcode{margin-right:20px;}.layui-nav .layui-nav-item{line-height:49px !important;}.layui-nav .layui-nav-item a{height:49px !important;line-height:49px;}.layui-nav .layui-this:after,.layui-nav-bar,.layui-nav-tree .layui-nav-itemed:after{height:1px;}.footer-container{background-color:#393D49;padding:30px 5% 0 5%;}.pagination{margin:18px 0;}.pagination ul li{line-height:20px;width:20px;height:20px;display:inline-block;border-color:#28a3ef;font-size:16px;}.pagination ul li .next .prev{font-size:20px !important;}.pagination ul .active{background-color:#28a3ef;}.pagination ul .active a{color:#fff;}.breadcrumb-container{padding:20px;}.blog-root{width:68%;margin:40px auto;}.blog-root a{color:#28a3ef !important;}.blog-root .blog-title{display:block;margin:60px 0 20px 0;text-align:center}.blog-root .blog-detaile{color:#2f2f2f;}.blog-root .blog-detaile pre{border:1px #d2e8b9 solid;box-shadow:1px 1px 2px 2px #d2e8b9;margin:5px 0;}.blog-root .blog-detaile h4{font-size:20px;font-weight:500;}.blog-user{position:fixed;top:60px;left:5px;width:100px;height:100%;background-color:#f9f9f9;}.blog-info{padding:15px;}.blog-info .blog-author{display:flex;}.blog-info .blog-author .author-headimg{display:inline-block;width:48px;height:48px;}.blog-info .blog-author .blog-label{flex:1;height:22px;line-height:22px;text-align:right;padding-top:26px;}.blog-info .blog-author .blog-label label{color:#888;border:1px dotted #aaa;padding:5px;border-radius:5px;font-size:10px;}.blog-info .blog-author .author-headimg .img-circle{width:48px !important;height:48px !important;margin-top:0px !important;}.blog-info .blog-author .author-info{display:inline-block;height:48px !important;vertical-align:bottom;text-align:left;margin-left:5px;}.blog-info .blog-author .author-info a{display:inline-block;height:28px;line-height:28px;font-size:16px;}.blog-info .blog-author .author-info span{display:inline-block;height:20px;line-height:20px;font-size:12px;color:#888;padding-right:8px;}.blog-info em{padding:0 8px !important;}.comms-root{width:68%;margin:0 auto;}.comms-root a{text-decoration:none;}img{max-width:100% !important;}.blog-referral{width:100%;margin:40px auto;}.blog-referral p{padding:3px 0;}.layui-code-view .layui-code-ol li{margin-left:0px !important;}.home-container{height:100%;margin:50px 5% 60px 5%;}.home-container hr{margin:0;}.home-hearder{margin:10px 0;display:flex;height:30px;line-height:30px;}.home-hearder .m-select{color:#353535;width:150px;display:inline-block;height:32px;border-radius:3px;padding:4px 14px;}.home-hearder .layui-btn-group .active a{color:#fff;}.home-hearder .layui-btn-group a{color:#353535;text-decoration:none;}.nelson-btn{color:#ec6149 !important;border-radius:15px;border:1px solid #bbb !important;}.nelson-btn:hover{background:#fff !important;color:#ec6149 !important;border-radius:15px;border:1px solid #ec6149 !important;}.home-content{display:flex;min-height:36px;line-height:36px;}.home-content-title{display:inline-block;flex:1;}.home-content-desc{display:flex}.home-content-desc span{display:inline-block;text-align:center}.blog-root h5{color:#888;font-size:14px;margin:9px 0;font-family:inherit;font-weight:700;line-height:1.5;}.blog-root a{text-decoration:none;}.blog-root p{margin:1px 0 9px;}.login-root{position:absolute;min-height:100%;width:100%;overflow:hidden;}.login-root .input-container{position:fixed;left:65%;top:33px;background:url("/static/img/loginbg.png") no-repeat center top;}.login-root .input-container .input-root{width:370px;height:500px;}.login-root .input-container .input-root .inputs-class{margin-top:220px;padding:10px 50px 10px 50px;}.login-root .input-container .input-root .regist{margin-top:200px;}.login-root .input-container .input-root .inputs-class .login-bottom{margin-top:10px;text-align:right;}.login-root .input-container .input-root .input-group{display:table;border-collapse:separate;}.login-root .input-container .input-root .inputs-class .input-class{height:32px;margin:18px 0;display:flex;}.login-root .input-container .input-root .inputs-class .input-class input{flex:1;height:26px !important;padding:2px 14px;font-size:12px;line-height:1.5;border-radius:3px;border-top-left-radius:0;border-bottom-left-radius:0;display:table-cell;border:1px solid #ccc;}.login-root .input-container .input-root .inputs-class .input-class .input-group-addon{color:#555;line-height:26px !important;font-size:12px;padding:2px 14px;line-height:1.5;border-radius:3px;display:table-cell;border:1px solid #ccc;border-right:none;}.login-footer{position:absolute;bottom:0;left:0;width:100%;height:110px;}.login-root{position:absolute;min-height:100%;width:100%;overflow:hidden;}.login-root .input-container{position:fixed;left:65%;top:33px;background:url("/static/img/loginbg.png") no-repeat center top;}.login-root .input-container .input-root{width:370px;height:500px;}.login-root .input-container .input-root p{font-size:21px;text-align:center;padding-top:195px;}.login-root .input-container .input-root .inputs-class{padding:0 50px;}.login-root .input-container .input-root .input-group{display:table;border-collapse:separate;}.login-root .input-container .input-root .inputs-class .input-class{height:32px;margin:18px 0;display:flex;}.login-root .input-container .input-root .inputs-class .input-class input{flex:1;height:26px !important;padding:2px 14px;font-size:12px;line-height:1.5;border-radius:3px;border-top-left-radius:0;border-bottom-left-radius:0;display:table-cell;border:1px solid #ccc;}.login-root .input-container .input-root .inputs-class .input-class .input-group-addon{color:#555;line-height:26px !important;font-size:12px;padding:2px 14px;line-height:1.5;border-radius:3px;display:table-cell;border:1px solid #ccc;border-right:none;}.login-footer{position:absolute;bottom:0;left:0;width:100%;height:110px;}.me-menu{position:fixed;top:60px;left:20px;width:260px;height:100%;background-color:#f9f9f9;}.me-menu p{cursor:pointer;font-size:15px;color:#555;margin:0;height:32px;line-height:32px;}.me-menu .active{color:#3CBEF8 !important}.me-menu p a{margin-left:5px;color:#555;text-decoration:none;}.me-menu .active span{display:inline-block;height:100%;width:2px;background-color:#3CBEF8;}.me-menu .active a{color:#3CBEF8;vertical-align:top;height:32px;line-height:32px;display:inline-block;}.me-blog-root{height:100%;margin:50px 4% 0 0;}.me-blog-list{margin-left:300px;}.me-blog-list p{height:30px;line-height:30px;margin:0;font-size:15px;}.me-footer{position:absolute;bottom:0;left:0;width:100%;height:110px;padding:0 4%;}.me-blog-footer{height:110px;padding:0 4%;margin-left:290px;}.info-header{flex:1;}.info-header span{margin-right:6px;}.uinfo{color:#515a6e;margin:5px;}.udesc span{margin-right:8px;}.blog-list{display:flex;font-size:16px;min-height:35px;line-height:35px;}.us-root{margin-top:50px;display:flex;margin-left:5%;font-size:16px;min-height:720px;height:100%;}.us-root p{padding:5px 0;color:#323232;}.us-root a{color:#28a3ef !important;}.blog-title{display:flex;height:50px;line-height:50px;}.blog-title input{padding-left:12px;flex:1;height:44px;border:0;}.blog-title button{height:32px;color:#fff;margin-top:9px;}.w-e-toolbar{height:40px;line-height:30px;}.map-root{position:absolute;width:100%;height:100%;left:0;top:0;}.map-root .map-container{width:100%;height:100%;}.amap-logo,.amap-copyright{display:none !important;visibility:hidden !important;}.blog-detaile p code{color:red;padding:2px 5px;}.search-root{margin-top:50px;}.search-root .input-class{display:table;border-collapse:separate;}.search-root .input-class{width:50%;height:32px;margin:18px auto;display:flex;}.search-root .input-class input{flex:1;height:36px !important;padding:2px 14px;font-size:12px;line-height:1.5;border-radius:3px;border-top-right-radius:0;border-bottom-right-radius:0;display:table-cell;border:1px solid #3385ff;}.search-root .input-class .input-group-addon{color:#555;height:36px;line-height:36px !important;font-size:17px !important;font-size:12px;padding:2px 14px;line-height:36px;border-radius:3px;display:table-cell;background-color:#3385ff;border-top-left-radius:0;border-bottom-left-radius:0;color:#fff;border:1px solid #3385ff;border-left:none;cursor:pointer;}.search-result{margin:35px 15%;}.search-item{padding:7px 15px;}.search-result a{display:block;cursor:pointer;height:25px;line-height:25px;font-size:16px;text-decoration:#00c6ff;flex:1;}.search-result .search-title{display:flex;}.search-result span{cursor:pointer;font-size:12px;height:25px;line-height:25px;}.search-content{font-size:12px;}.v-note-wrapper{height:100%;z-index:99 !important;}.modal_form{display:flex;margin-bottom:10px;}.modal_form .span-lable{display:inline-block;width:100px;height:30px;line-height:30px;} \ No newline at end of file diff --git a/static/img/alipay.png b/static/img/alipay.png deleted file mode 100644 index 7c67f41..0000000 Binary files a/static/img/alipay.png and /dev/null differ diff --git a/static/img/login.png b/static/img/login.png deleted file mode 100644 index 7b8ce0d..0000000 Binary files a/static/img/login.png and /dev/null differ diff --git a/utils/EsUtil.go b/utils/EsUtil.go index 95e32ba..ef9a90f 100644 --- a/utils/EsUtil.go +++ b/utils/EsUtil.go @@ -4,6 +4,7 @@ import ( "beeblog/models" "context" "fmt" + beego "github.com/beego/beego/v2/server/web" "github.com/olivere/elastic" "log" "os" @@ -13,7 +14,6 @@ import ( ) var client *elastic.Client -var host = "http://127.0.0.1:9200/" const mapping = ` { @@ -49,6 +49,7 @@ const mapping = ` }` func init() { + host, _ := beego.AppConfig.String("eshost") var err error client, err = elastic.NewClient( elastic.SetURL(host), diff --git a/utils/redis.go b/utils/redis.go new file mode 100644 index 0000000..7ad70a1 --- /dev/null +++ b/utils/redis.go @@ -0,0 +1,49 @@ +package utils + +import ( + "fmt" + "github.com/beego/beego/v2/server/web" + "github.com/go-redis/redis" +) + +const ( + REDIS_NETWORK = "tcp" + REDIS_DB = 7 +) + +type RedisClient struct { +} + +func (r RedisClient) GetClient() *redis.Client { + REDIS_HOST, _ := web.AppConfig.String("redisHost") + REDIS_PORT, _ := web.AppConfig.String("redisPort") + REDIS_PASSWORD, _ := web.AppConfig.String("redisPwd") + options := redis.Options{ + Network: REDIS_NETWORK, + Addr: fmt.Sprintf("%s:%s", REDIS_HOST, REDIS_PORT), + Dialer: nil, + OnConnect: nil, + Password: REDIS_PASSWORD, + DB: REDIS_DB, + MaxRetries: 0, + MinRetryBackoff: 0, + MaxRetryBackoff: 0, + DialTimeout: 0, + ReadTimeout: 0, + WriteTimeout: 0, + PoolSize: 0, + MinIdleConns: 0, + MaxConnAge: 0, + PoolTimeout: 0, + IdleTimeout: 0, + IdleCheckFrequency: 0, + TLSConfig: nil, + } + // 新建一个client + clientRedis := redis.NewClient(&options) + return clientRedis +} + +func (r RedisClient) CloseClient(client *redis.Client) { + defer client.Close() +} diff --git a/utils/redisStore.go b/utils/redisStore.go new file mode 100644 index 0000000..1d5b57a --- /dev/null +++ b/utils/redisStore.go @@ -0,0 +1,66 @@ +package utils + +import ( + "fmt" + "github.com/mojocn/base64Captcha" + "time" +) + +const CAPTCHA = "captcha:" + +type RedisStore struct { + base64Captcha.Store +} + +var redisObj = new(RedisClient) + +//set a capt +func (r RedisStore) Set(id string, value string) error { + key := CAPTCHA + id + client := redisObj.GetClient() + _, err := client.Set(key, value, time.Minute*2).Result() + if err != nil { + return err + } + redisObj.CloseClient(client) + return nil +} + +//get a capt +func (r RedisStore) Get(id string, clear bool) string { + key := CAPTCHA + id + client := redisObj.GetClient() + val, err := client.Get(key).Result() + if err != nil { + fmt.Println(err) + return "" + } + if clear { + client.Del(key) + } + redisObj.CloseClient(client) + return val +} + +//verify a capt +func (r RedisStore) Verify(id, answer string, clear bool) bool { + v := RedisStore{}.Get(id, clear) + fmt.Println("key:" + id + ";value:" + v + ";answer:" + answer) + return v == answer +} + +//get a capt +func (r RedisStore) Has(id string) int { + key := CAPTCHA + id + client := redisObj.GetClient() + val, err := client.Get(key).Result() + redisObj.CloseClient(client) + if err != nil { + fmt.Println(err) + return 0 + } + if val == "" { + return 0 + } + return 1 +} diff --git a/views/T.footer.tpl b/views/T.footer.tpl index 1687156..bcf25dc 100644 --- a/views/T.footer.tpl +++ b/views/T.footer.tpl @@ -12,7 +12,7 @@ © 2018 - © 2020 码农随笔 版权所有    ICP证: - 陕ICP备18016846号 + 陕ICP备18016846号-1

我的博客

-

笔记文件夹

-

我的收藏

我的资料

{{end}} \ No newline at end of file diff --git a/views/T.nav.tpl b/views/T.nav.tpl index 11641d1..03a2790 100644 --- a/views/T.nav.tpl +++ b/views/T.nav.tpl @@ -16,13 +16,7 @@ 博客
  • - 笔记 -
  • -
  • - 新版笔记 -
  • -
  • - 福利 + 免费笔记
  • 个人中心 @@ -40,9 +34,6 @@
  • 登录
  • -
  • - 注册 -
  • {{end}} diff --git a/views/login.html b/views/login.html index b3125c7..e2945af 100644 --- a/views/login.html +++ b/views/login.html @@ -1,67 +1,304 @@ {{template "header" .}} + + 登录 - 码农随笔 +
    -{{template "nav" .}} + {{template "nav" .}}
    -
    -
    -
    - - - - - - - - - - - - 快速登录 - -
    - \ No newline at end of file