From a4536b9bd61ca15484283fa1e4e029f210950e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A9=E7=88=B1=E6=9C=89=E6=83=85?= Date: Mon, 15 Jul 2024 13:52:10 +0800 Subject: [PATCH] =?UTF-8?q?1.5.0=E6=AD=A3=E5=BC=8F=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 2 +- .../java/example/readme/TACBuilderTest.java | 2 + .../java/example/readme/TACBuilderTest2.java | 44 +++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/main/test/java/example/readme/TACBuilderTest2.java diff --git a/readme.md b/readme.md index b9d5b8b..95dfde6 100644 --- a/readme.md +++ b/readme.md @@ -85,7 +85,7 @@ public class ApplicationTest { } ``` - +### 详细文档请点击 [在线文档](http://doc.captcha.tianai.cloud) # qq群: 305532064 # 微信群: diff --git a/src/main/test/java/example/readme/TACBuilderTest.java b/src/main/test/java/example/readme/TACBuilderTest.java index 89a5205..61df8d5 100644 --- a/src/main/test/java/example/readme/TACBuilderTest.java +++ b/src/main/test/java/example/readme/TACBuilderTest.java @@ -11,6 +11,8 @@ public class TACBuilderTest { public static void main(String[] args) { ImageCaptchaApplication application = TACBuilder.builder() .addDefaultTemplate() + .expire("default", 10000L) + .expire("WORD_IMAGE_CLICK", 60000L) .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")) diff --git a/src/main/test/java/example/readme/TACBuilderTest2.java b/src/main/test/java/example/readme/TACBuilderTest2.java new file mode 100644 index 0000000..5cf3e99 --- /dev/null +++ b/src/main/test/java/example/readme/TACBuilderTest2.java @@ -0,0 +1,44 @@ +package example.readme; + +import cloud.tianai.captcha.application.ImageCaptchaApplication; +import cloud.tianai.captcha.application.TACBuilder; +import cloud.tianai.captcha.application.vo.CaptchaResponse; +import cloud.tianai.captcha.application.vo.ImageCaptchaVO; +import cloud.tianai.captcha.generator.common.model.dto.GenerateParam; +import cloud.tianai.captcha.interceptor.CaptchaInterceptor; +import cloud.tianai.captcha.interceptor.Context; +import cloud.tianai.captcha.resource.common.model.dto.Resource; + +import java.awt.*; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; + +public class TACBuilderTest2 { + + public static void main(String[] args) throws IOException, FontFormatException { + FileInputStream fileInputStream = new FileInputStream("C:\\Users\\Thinkpad\\Desktop\\captcha\\手写字体\\ttf\\千图小兔体.ttf"); + Font font = Font.createFont(Font.TRUETYPE_FONT, fileInputStream); + fileInputStream.close(); + ImageCaptchaApplication application = TACBuilder.builder() + .addDefaultTemplate() + .expire("default", 10000L) + .expire("WORD_IMAGE_CLICK", 60000L) + .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")) + .setInterceptor(new CaptchaInterceptor() { + @Override + public CaptchaResponse beforeGenerateCaptcha(Context context, String type, GenerateParam param) { + System.out.println("before generator"); + return CaptchaInterceptor.super.beforeGenerateCaptcha(context, type, param); + } + }) + .addFont(font) + .build(); + CaptchaResponse response = application.generateCaptcha("WORD_IMAGE_CLICK"); + System.out.println(response); + + } +} +