From 3323767dad4c892615ae239871d39f371a030255 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=BB=84=E6=B5=B7?= <10402852@qq.com>
Date: Wed, 11 Aug 2021 11:42:56 +0800
Subject: [PATCH] commit
---
dsSzxy/.idea/workspace.xml | 19 ---------
.../CaptchaController/CaptchaController.go | 41 ++++++-------------
2 files changed, 12 insertions(+), 48 deletions(-)
diff --git a/dsSzxy/.idea/workspace.xml b/dsSzxy/.idea/workspace.xml
index 63afc7e7..6b42eb67 100644
--- a/dsSzxy/.idea/workspace.xml
+++ b/dsSzxy/.idea/workspace.xml
@@ -5,10 +5,8 @@
-
-
@@ -68,14 +66,6 @@
-
-
-
-
-
-
-
-
@@ -94,15 +84,6 @@
-
-
-
-
-
-
-
-
-
diff --git a/dsSzxy/Business/CaptchaRelate/CaptchaController/CaptchaController.go b/dsSzxy/Business/CaptchaRelate/CaptchaController/CaptchaController.go
index 71406d74..ac1e473a 100644
--- a/dsSzxy/Business/CaptchaRelate/CaptchaController/CaptchaController.go
+++ b/dsSzxy/Business/CaptchaRelate/CaptchaController/CaptchaController.go
@@ -6,7 +6,6 @@ import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/mojocn/base64Captcha"
- "image/color"
"net/http"
)
@@ -31,10 +30,7 @@ type CaptchaResult struct {
// GetOne 生成图形化验证码
func getCaptcha(c *gin.Context) {
- id, b64s, err := CaptMake()
- if err != nil {
- c.JSON(http.StatusOK, gin.H{"success": false, "info": "发生错误!"})
- }
+ id, b64s := CaptMake()
captchaResult := CaptchaResult{
Id: id,
Base64Blob: b64s,
@@ -59,31 +55,18 @@ func verifyCaptcha(c *gin.Context) {
}
// CaptMake 生成验证码
-func CaptMake() (id, b64s string, err error) {
- var driver base64Captcha.Driver
- var driverString base64Captcha.DriverString
-
- // 配置验证码信息
- captchaConfig := base64Captcha.DriverString{
- Height: 60,
- Width: 200,
- NoiseCount: 0,
- ShowLineOptions: 2 | 4,
- Length: 4,
- Source: "1234567890qwertyuioplkjhgfdsazxcvbnm",
- BgColor: &color.RGBA{
- R: 3,
- G: 102,
- B: 214,
- A: 125,
- },
- Fonts: []string{"wqy-microhei.ttc"},
+func CaptMake() (string, string) {
+ // 生成默认数字
+ driver := base64Captcha.DefaultDriverDigit
+ // 生成base64图片
+ c := base64Captcha.NewCaptcha(driver, store)
+ // 获取
+ id, b64s, err := c.Generate()
+ if err != nil {
+ fmt.Println("Register GetCaptchaPhoto get base64Captcha has err:", err)
+ return "", ""
}
- driverString = captchaConfig
- driver = driverString.ConvertFonts()
- captcha := base64Captcha.NewCaptcha(driver, store)
- lid, lb64s, lerr := captcha.Generate()
- return lid, lb64s, lerr
+ return id, b64s
}
// CaptVerify 验证captcha是否正确