gf2版本同步升级到v2.0.4,修复验证器兼容问题

This commit is contained in:
孟帅
2022-03-22 09:49:17 +08:00
parent 4dc278f9cb
commit c9383334b4
45 changed files with 410 additions and 303 deletions

View File

@@ -11,12 +11,10 @@ import (
"github.com/gogf/gf/v2/os/gcache"
)
type cache struct {
}
// 缓存
var Cache = new(cache)
var (
Cache = new(cache)
)
type cache struct{}
func (component *cache) New() *gcache.Cache {
c := gcache.New()

View File

@@ -13,13 +13,14 @@ import (
"github.com/mojocn/base64Captcha"
)
// 验证码
var Captcha = new(captcha)
type captcha struct{}
//
//  @Title  获取字母数字混合验证码
//  @Description 
//  @Description
//  @Author  Ms <133814250@qq.com>
//  @Param   ctx
//  @Return  idKeyC
@@ -27,27 +28,27 @@ type captcha struct{}
//
func (component *captcha) GetVerifyImgString(ctx context.Context) (idKeyC string, base64stringC string) {
driver := &base64Captcha.DriverString{
Height: 80,
Width: 240,
Height: 80,
Width: 240,
//NoiseCount: 50,
//ShowLineOptions: 20,
Length: 4,
Source: "abcdefghjkmnpqrstuvwxyz23456789",
Fonts: []string{"chromohv.ttf"},
Length: 4,
Source: "abcdefghjkmnpqrstuvwxyz23456789",
Fonts: []string{"chromohv.ttf"},
}
driver = driver.ConvertFonts()
store := base64Captcha.DefaultMemStore
c := base64Captcha.NewCaptcha(driver, store)
idKeyC, base64stringC, err := c.Generate()
if err != nil {
g.Log().Error(ctx,err)
g.Log().Error(ctx, err)
}
return
}
//
//  @Title  验证输入的验证码是否正确
//  @Description 
//  @Description
//  @Author  Ms <133814250@qq.com>
//  @Param   id
//  @Param   answer
@@ -59,4 +60,4 @@ func (component *captcha) VerifyString(id, answer string) bool {
c := base64Captcha.NewCaptcha(driver, store)
answer = gstr.ToLower(answer)
return c.Verify(id, answer, true)
}
}

View File

@@ -13,10 +13,11 @@ import (
"github.com/gogf/gf/v2/net/ghttp"
)
type comContext struct{}
// 上下文
var Context = new(comContext)
type comContext struct{}
//
//  @Title  初始化上下文对象指针到上下文对象中,以便后续的请求流程中可以修改
//  @Description

View File

@@ -19,6 +19,7 @@ import (
"time"
)
// IP归属地
var Ip = new(ip)
type ip struct{}

View File

@@ -21,6 +21,7 @@ import (
"time"
)
// jwt鉴权
type JWT struct{}
var Jwt = new(JWT)

View File

@@ -14,6 +14,7 @@ import (
"time"
)
// 统一响应
var Response = new(response)
type response struct{}