From 01736764161115ffa2291be73dfb85663785d48b Mon Sep 17 00:00:00 2001 From: QM303176530 <303176530@qq.com> Date: Wed, 18 Mar 2020 20:34:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E9=AA=8C=E8=AF=81=E7=A0=81=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=88=B0=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=AD?= =?UTF-8?q?=20=E5=A2=9E=E5=8A=A0ie=E9=80=82=E9=85=8Dcss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QMPlusServer/config/config.go | 7 +++++++ QMPlusServer/controller/api/sys_captcha.go | 18 ++++++------------ QMPlusServer/controller/servers/captcha.go | 4 ++-- QMPlusServer/static/config/config.json | 5 +++++ QMPlusVuePage/src/view/login/login.vue | 4 +++- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/QMPlusServer/config/config.go b/QMPlusServer/config/config.go index 331af5ff..60d116fa 100644 --- a/QMPlusServer/config/config.go +++ b/QMPlusServer/config/config.go @@ -13,6 +13,7 @@ type Config struct { RedisAdmin RedisAdmin `json:"redisAdmin"` System System `json:"system"` JWT JWT `json:"jwt"` + Captcha Captcha `json:"captcha"` } type System struct { // 系统配置 @@ -47,6 +48,12 @@ type Qiniu struct { // 七牛 密钥配置 SecretKey string `json:"secretKey"` } +type Captcha struct { // 验证码配置 + KeyLong int `json:"keyLong"` + ImgWidth int `json:"imgWidth"` + ImgHeight int `json:"imgHeight"` +} + var GinVueAdminconfig Config var VTool *viper.Viper diff --git a/QMPlusServer/controller/api/sys_captcha.go b/QMPlusServer/controller/api/sys_captcha.go index 237cb5d6..42068a0d 100644 --- a/QMPlusServer/controller/api/sys_captcha.go +++ b/QMPlusServer/controller/api/sys_captcha.go @@ -1,6 +1,7 @@ package api import ( + "gin-vue-admin/config" "gin-vue-admin/controller/servers" "github.com/dchest/captcha" "github.com/gin-gonic/gin" @@ -15,11 +16,11 @@ import ( // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /base/captcha [post] func Captcha(c *gin.Context) { - captchaId := captcha.NewLen(6) - servers.ReportFormat(c,true,"验证码获取成功",gin.H{ - "captchaId":captchaId, - "picPath":"/base/captcha/"+captchaId+".png", - }) + captchaId := captcha.NewLen(config.GinVueAdminconfig.Captcha.KeyLong) + servers.ReportFormat(c, true, "验证码获取成功", gin.H{ + "captchaId": captchaId, + "picPath": "/base/captcha/" + captchaId + ".png", + }) } // @Tags base @@ -32,10 +33,3 @@ func Captcha(c *gin.Context) { func CaptchaImg(c *gin.Context) { servers.GinCapthcaServeHTTP(c.Writer, c.Request) } - - - - - - - diff --git a/QMPlusServer/controller/servers/captcha.go b/QMPlusServer/controller/servers/captcha.go index f7be5b9e..e92b8401 100644 --- a/QMPlusServer/controller/servers/captcha.go +++ b/QMPlusServer/controller/servers/captcha.go @@ -3,6 +3,7 @@ package servers import ( "bytes" "fmt" + "gin-vue-admin/config" "github.com/dchest/captcha" "net/http" "path" @@ -25,7 +26,7 @@ func GinCapthcaServeHTTP(w http.ResponseWriter, r *http.Request) { } lang := strings.ToLower(r.FormValue("lang")) download := path.Base(dir) == "download" - if Serve(w, r, id, ext, lang, download, 120, 40) == captcha.ErrNotFound { + if Serve(w, r, id, ext, lang, download, config.GinVueAdminconfig.Captcha.ImgWidth, config.GinVueAdminconfig.Captcha.ImgHeight) == captcha.ErrNotFound { http.NotFound(w, r) } } @@ -52,4 +53,3 @@ func Serve(w http.ResponseWriter, r *http.Request, id, ext, lang string, downloa http.ServeContent(w, r, id+ext, time.Time{}, bytes.NewReader(content.Bytes())) return nil } - diff --git a/QMPlusServer/static/config/config.json b/QMPlusServer/static/config/config.json index 78acfd3b..ccdec3c7 100644 --- a/QMPlusServer/static/config/config.json +++ b/QMPlusServer/static/config/config.json @@ -25,5 +25,10 @@ "useMultipoint": false, "env": "develop", "addr": 8888 + }, + "captcha": { + "keyLong": 6, + "imgWidth": 120, + "imgHeight": 40 } } \ No newline at end of file diff --git a/QMPlusVuePage/src/view/login/login.vue b/QMPlusVuePage/src/view/login/login.vue index f84a81d9..ac988385 100644 --- a/QMPlusVuePage/src/view/login/login.vue +++ b/QMPlusVuePage/src/view/login/login.vue @@ -16,10 +16,11 @@ - + 请输入验证码 @@ -121,6 +122,7 @@ export default { .vPic{ position: absolute; right: 10px; + bottom: 0px; // 适配ie } }