🏗️ microservice fabric splitting
This commit is contained in:
44
common/captcha/initialize/slide_captcha.go
Normal file
44
common/captcha/initialize/slide_captcha.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"github.com/wenlng/go-captcha-assets/resources/images"
|
||||
"github.com/wenlng/go-captcha-assets/resources/tiles"
|
||||
"github.com/wenlng/go-captcha/v2/slide"
|
||||
)
|
||||
|
||||
// NewSlideCaptcha 初始化滑动验证码
|
||||
func NewSlideCaptcha() slide.Captcha {
|
||||
builder := slide.NewBuilder(
|
||||
// slide.WithGenGraphNumber(2),
|
||||
slide.WithEnableGraphVerticalRandom(true),
|
||||
)
|
||||
|
||||
// background images
|
||||
imgs, err := images.GetImages()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
graphs, err := tiles.GetTiles()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var newGraphs = make([]*slide.GraphImage, 0, len(graphs))
|
||||
for i := 0; i < len(graphs); i++ {
|
||||
graph := graphs[i]
|
||||
newGraphs = append(newGraphs, &slide.GraphImage{
|
||||
OverlayImage: graph.OverlayImage,
|
||||
MaskImage: graph.MaskImage,
|
||||
ShadowImage: graph.ShadowImage,
|
||||
})
|
||||
}
|
||||
|
||||
// set resources
|
||||
builder.SetResources(
|
||||
slide.WithGraphImages(newGraphs),
|
||||
slide.WithBackgrounds(imgs),
|
||||
)
|
||||
|
||||
return builder.Make()
|
||||
}
|
Reference in New Issue
Block a user