🏗️ microservice fabric splitting
This commit is contained in:
97
common/captcha/initialize/text_captcha.go
Normal file
97
common/captcha/initialize/text_captcha.go
Normal file
@@ -0,0 +1,97 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"github.com/golang/freetype/truetype"
|
||||
"github.com/wenlng/go-captcha-assets/resources/fonts/fzshengsksjw"
|
||||
"github.com/wenlng/go-captcha-assets/resources/images"
|
||||
"github.com/wenlng/go-captcha-assets/sourcedata/chars"
|
||||
"github.com/wenlng/go-captcha/v2/base/option"
|
||||
"github.com/wenlng/go-captcha/v2/click"
|
||||
)
|
||||
|
||||
// NewTextCaptcha 初始化点选验证码
|
||||
func NewTextCaptcha() click.Captcha {
|
||||
builder := click.NewBuilder(
|
||||
click.WithRangeLen(option.RangeVal{Min: 4, Max: 6}),
|
||||
click.WithRangeVerifyLen(option.RangeVal{Min: 2, Max: 4}),
|
||||
click.WithRangeThumbColors([]string{
|
||||
"#1f55c4",
|
||||
"#780592",
|
||||
"#2f6b00",
|
||||
"#910000",
|
||||
"#864401",
|
||||
"#675901",
|
||||
"#016e5c",
|
||||
}),
|
||||
click.WithRangeColors([]string{
|
||||
"#fde98e",
|
||||
"#60c1ff",
|
||||
"#fcb08e",
|
||||
"#fb88ff",
|
||||
"#b4fed4",
|
||||
"#cbfaa9",
|
||||
"#78d6f8",
|
||||
}),
|
||||
)
|
||||
|
||||
// fonts
|
||||
fonts, err := fzshengsksjw.GetFont()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// background images
|
||||
imgs, err := images.GetImages()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// thumb images
|
||||
// thumbImages, err := thumbs.GetThumbs()
|
||||
// if err != nil {
|
||||
// log.Fatalln(err)
|
||||
// }
|
||||
|
||||
// set resources
|
||||
builder.SetResources(
|
||||
click.WithChars(chars.GetChineseChars()),
|
||||
// click.WithChars([]string{
|
||||
// "1A",
|
||||
// "5E",
|
||||
// "3d",
|
||||
// "0p",
|
||||
// "78",
|
||||
// "DL",
|
||||
// "CB",
|
||||
// "9M",
|
||||
// }),
|
||||
// click.WithChars(chars.GetAlphaChars()),
|
||||
click.WithFonts([]*truetype.Font{fonts}),
|
||||
click.WithBackgrounds(imgs),
|
||||
// click.WithThumbBackgrounds(thumbImages),
|
||||
)
|
||||
// global.TextCaptcha = builder.Make()
|
||||
|
||||
// ============================
|
||||
|
||||
builder.Clear()
|
||||
builder.SetOptions(
|
||||
click.WithRangeLen(option.RangeVal{Min: 4, Max: 6}),
|
||||
click.WithRangeVerifyLen(option.RangeVal{Min: 2, Max: 4}),
|
||||
click.WithRangeThumbColors([]string{
|
||||
"#4a85fb",
|
||||
"#d93ffb",
|
||||
"#56be01",
|
||||
"#ee2b2b",
|
||||
"#cd6904",
|
||||
"#b49b03",
|
||||
"#01ad90",
|
||||
}),
|
||||
)
|
||||
builder.SetResources(
|
||||
click.WithChars(chars.GetChineseChars()),
|
||||
click.WithFonts([]*truetype.Font{fonts}),
|
||||
click.WithBackgrounds(imgs),
|
||||
)
|
||||
return builder.Make()
|
||||
}
|
Reference in New Issue
Block a user