mirror of
https://github.com/dromara/tianai-captcha.git
synced 2026-05-07 06:04:34 +08:00
1.5.0正式版
This commit is contained in:
@@ -54,9 +54,11 @@ public class ApplicationTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ImageCaptchaApplication application = TACBuilder.builder()
|
||||
.addDefaultTemplate()
|
||||
.addDefaultTemplate() // 添加默认模板
|
||||
// 给滑块验证码 添加背景图片,宽高为600*360, Resource 参数1为 classpath/file/url , 参数2 为具体url
|
||||
.addResource("SLIDER", new Resource("classpath", "META-INF/cut-image/resource/1.jpg"))
|
||||
.addResource("SLIDER", new Resource("classpath", "META-INF/cut-image/resource/1.jpg")) // 滑块验证的背景图
|
||||
.addResource("WORD_IMAGE_CLICK", new Resource("classpath", "META-INF/cut-image/resource/1.jpg")) // 文字点选的背景图
|
||||
.addResource("ROTATE", new Resource("classpath", "META-INF/cut-image/resource/1.jpg")) // 旋转验证的背景图
|
||||
.build();
|
||||
// 生成验证码数据, 可以将该数据直接返回给前端 , 可配合 tianai-captcha-web-sdk 使用
|
||||
// 支持生成 滑动验证码(SLIDER)、旋转验证码(ROTATE)、滑动还原验证码(CONCAT)、文字点选验证码(WORD_IMAGE_CLICK)
|
||||
|
||||
@@ -59,7 +59,9 @@ public class CacheImageCaptchaGenerator implements ImageCaptchaGenerator {
|
||||
this.size = size;
|
||||
this.waitTime = waitTime;
|
||||
this.period = period;
|
||||
this.expireTime = expireTime;
|
||||
if (expireTime != null){
|
||||
this.expireTime = expireTime;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,8 +12,10 @@ public class TACBuilderTest {
|
||||
ImageCaptchaApplication application = TACBuilder.builder()
|
||||
.addDefaultTemplate()
|
||||
.addResource("SLIDER", new Resource("classpath", "META-INF/cut-image/resource/1.jpg"))
|
||||
.addResource("WORD_IMAGE_CLICK", new Resource("classpath", "META-INF/cut-image/resource/1.jpg"))
|
||||
.addResource("ROTATE", new Resource("classpath", "META-INF/cut-image/resource/1.jpg"))
|
||||
.build();
|
||||
CaptchaResponse<ImageCaptchaVO> response = application.generateCaptcha("SLIDER");
|
||||
CaptchaResponse<ImageCaptchaVO> response = application.generateCaptcha("ROTATE");
|
||||
System.out.println(response);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user