package loginVerify import ( "key_performance_indicators/overall" "key_performance_indicators/overall/publicmethod" "github.com/gin-gonic/gin" "github.com/mojocn/base64Captcha" ) var store = base64Captcha.DefaultMemStore func (a *ApiMethod) Captcha(c *gin.Context) { // 字符,公式,验证码配置 // 生成默认数字的driver driver := base64Captcha.NewDriverDigit(overall.CONSTANT_CONFIG.Captcha.ImgHeight, overall.CONSTANT_CONFIG.Captcha.ImgWidth, overall.CONSTANT_CONFIG.Captcha.KeyLong, 0.7, 80) //coder := base64Captcha.NewCaptcha(driver, store.UseWithCtx(c)) // v8下使用redis coder := base64Captcha.NewCaptcha(driver, store) if id, b64s, err := coder.Generate(); err != nil { publicmethod.Result(1, err, c, "验证码获取失败") } else { publicmethod.Result(0, SysCaptchaResponse{ CaptchaId: id, PicPath: b64s, }, c) } }