mirror of
https://github.com/dromara/tianai-captcha.git
synced 2026-05-07 06:04:34 +08:00
25bf75b804
- 移除了 AbstractResourceStore 类 - 新增了 CrudResourceStore 接口,定义了 CRUD操作 - 修改了 DefaultImageCaptchaResourceManager,支持批量获取资源和模板 - 重构了 FontCache 类,改为实现 ResourceStore 接口 - 更新了相关应用类,使用新的资源管理逻辑
27 lines
1.4 KiB
Java
27 lines
1.4 KiB
Java
package example.readme;
|
|
|
|
import cloud.tianai.captcha.common.constant.CaptchaTypeConstant;
|
|
import cloud.tianai.captcha.resource.CrudResourceStore;
|
|
import cloud.tianai.captcha.resource.ImageCaptchaResourceManager;
|
|
import cloud.tianai.captcha.resource.ResourceStore;
|
|
import cloud.tianai.captcha.resource.common.model.dto.Resource;
|
|
import cloud.tianai.captcha.resource.impl.DefaultImageCaptchaResourceManager;
|
|
import cloud.tianai.captcha.resource.impl.provider.ClassPathResourceProvider;
|
|
import cloud.tianai.captcha.resource.impl.provider.URLResourceProvider;
|
|
|
|
/**
|
|
* 图片验证码测试
|
|
*/
|
|
public class TestImageCaptcha {
|
|
public static void main(String[] args) {
|
|
ImageCaptchaResourceManager imageCaptchaResourceManager = new DefaultImageCaptchaResourceManager();
|
|
// 通过资源管理器或者资源存储器
|
|
CrudResourceStore resourceStore = (CrudResourceStore) imageCaptchaResourceManager.getResourceStore();
|
|
// 添加classpath目录下的 aa.jpg 图片
|
|
resourceStore.addResource(CaptchaTypeConstant.SLIDER, new Resource(ClassPathResourceProvider.NAME, "/aa.jpg"));
|
|
// 添加远程url图片资源
|
|
resourceStore.addResource(CaptchaTypeConstant.SLIDER,new Resource(URLResourceProvider.NAME, "http://www.xx.com/aa.jpg"));
|
|
// 内置了通过url 和 classpath读取图片资源,如果想扩展可实现 ResourceProvider 接口,进行自定义扩展
|
|
}
|
|
}
|