Skip to content

Commit

Permalink
Merge pull request pig-mesh#1 from ChunMengLu/master
Browse files Browse the repository at this point in the history
✨ 优化配置.
  • Loading branch information
lltx authored Jul 31, 2020
2 parents c2cd4dd + 4e912f3 commit 0053ba4
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 44 deletions.
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# http://editorconfig.org
root = true

# 空格替代Tab缩进在各种编辑工具下效果一致
[*]
indent_style = space
indent_size = 4
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

[*.java]
indent_style = tab

[*.{json,yml}]
indent_size = 2

[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
18 changes: 3 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,35 +55,23 @@
### 3.1.gradle方式的引入
```text
dependencies {
compile 'com.github.whvcse:easy-captcha:1.6.2'
compile 'com.pig4cloud.plugin:easy-captcha:1.6.2'
}
```

### 3.2.maven方式引入
```xml
<dependencies>
<dependency>
<groupId>com.github.whvcse</groupId>
<groupId>com.pig4cloud.plugin</groupId>
<artifactId>easy-captcha</artifactId>
<version>1.6.2</version>
</dependency>
</dependencies>
```

### 3.3.jar包下载
[easy-captcha-1.6.2.jar](https://gitee.com/whvse/EasyCaptcha/releases)

maven导入jar包,在项目根目录创建`libs`文件夹,然后pom.xml添加如下:
```
<dependency>
<groupId>com.github.whvcse</groupId>
<artifactId>easy-captcha</artifactId>
<version>1.6.1</version>
<systemPath>${basedir}/libs/easy-captcha-1.6.2.jar</systemPath>
</dependency>
```

---
[easy-captcha](https://repo1.maven.org/maven2/com/pig4cloud/plugin/easy-captcha)

## 4.使用方法

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
* <p>
* 验证码配置类
*/
@Configuration
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(CaptchaProperties.class)
public class CaptchaAutoConfiguration {

@Bean
@ConditionalOnWebApplication
public CaptchaEndpoint captchaEndpoint(CaptchaProperties properties) {
return new CaptchaEndpoint(properties);
}
@Bean
@ConditionalOnWebApplication
public CaptchaEndpoint captchaEndpoint(CaptchaProperties properties) {
return new CaptchaEndpoint(properties);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@
@RequiredArgsConstructor
public class CaptchaEndpoint {

private final CaptchaProperties properties;
private final CaptchaProperties properties;

/**
* 生成验证码
*
* @param response 响应流
*/
@SneakyThrows
@GetMapping("${captcha.create.path:/create}")
public void create(HttpServletResponse response) {
ArithmeticCaptcha captcha = new ArithmeticCaptcha(properties.getWidth(), properties.getHeight());
String result = captcha.text();
// 设置响应头
response.setContentType(captcha.getContentType());
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
// 转换流信息写出
captcha.out(response.getOutputStream());
}
/**
* 生成验证码
*
* @param response 响应流
*/
@SneakyThrows
@GetMapping("${captcha.create.path:/create}")
public void create(HttpServletResponse response) {
ArithmeticCaptcha captcha = new ArithmeticCaptcha(properties.getWidth(), properties.getHeight());
String result = captcha.text();
// 设置响应头
response.setContentType(captcha.getContentType());
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
// 转换流信息写出
captcha.out(response.getOutputStream());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
"description": "生成验证码请求路径",
"defaultValue": "/create"
}
],
"hints": []
]
}

This file was deleted.

0 comments on commit 0053ba4

Please sign in to comment.